Пример #1
0
        string GetStepKeyword(string keyword)
        {
            string keyword_orig = BDDUtil.RemoveAllWhiteSpaces(keyword);

            if (GherkinKeyword.IsStepKeyword(keyword_orig, BDDStepImplBuilderContext.GherkinDialect.GivenStepKeywords))
            {
                return("Given");
            }
            else if (GherkinKeyword.IsStepKeyword(keyword_orig, BDDStepImplBuilderContext.GherkinDialect.WhenStepKeywords))
            {
                return("When");
            }
            else if (GherkinKeyword.IsStepKeyword(keyword_orig, BDDStepImplBuilderContext.GherkinDialect.ThenStepKeywords))
            {
                return("Then");
            }
            else if (GherkinKeyword.IsStepKeyword(keyword_orig, BDDStepImplBuilderContext.GherkinDialect.AndStepKeywords))
            {
                return("And");
            }
            else if (GherkinKeyword.IsStepKeyword(keyword_orig, BDDStepImplBuilderContext.GherkinDialect.ButStepKeywords))
            {
                return("But");
            }

            return(keyword_orig);
        }
Пример #2
0
        public ILanguageSyntax <GherkinKeyword> Get(GherkinKeyword value)
        {
            switch (value)
            {
            case GherkinKeyword.Background:
                return(this.keyword(value, "Background"));

            case GherkinKeyword.Feature:
                return(this.keyword(value, "Feature"));

            case GherkinKeyword.Scenario:
                return(this.keyword(value, "Scenario"));

            case GherkinKeyword.ScenarioOutline:
                return(this.keyword(value, "ScenarioOutline"));

            case GherkinKeyword.Scenarios:
                return(this.keyword(value, "Scenarios"));

            case GherkinKeyword.Examples:
                return(this.keyword(value, "Examples"));

            case GherkinKeyword.Where:
                return(this.keyword(value, "Where"));
            }

            return(this.keyword(value, string.Empty));
        }
Пример #3
0
 public static ExtentTest CreateTest(GherkinKeyword keyword, string testName, string description = null)
 {
     lock (_synclock)
     {
         _parentTest.Value    = ExtentReportContext.Instance.CreateTest(keyword, testName, description);
         _testHierarchy.Value = new TestHierarchyModel <ExtentTest>(_parentTest.Value);
         return(_parentTest.Value);
     }
 }
 public void Node(ExtentTest Test, GherkinKeyword gherkinKeyword, string stepText, Status status, string logReport)
 {
     if (ConfigurationManager.AppSettings["Reporting"].ToLower() == "false")
     {
         Debug.WriteLine("STATUS: " + status + ": " + logReport);
     }
     else
     {
         Test.CreateNode(gherkinKeyword, stepText, logReport);
     }
 }
Пример #5
0
        public static IFixtureStepParent Create(GherkinKeyword keyword, string description)
        {
            switch (keyword)
            {
            case GherkinKeyword.Feature:
                return(new FixtureStep(typeof(FeatureAttribute), description));

            case GherkinKeyword.Background:
                return(new FixtureStep(typeof(BackgroundAttribute), description));
            }

            return(null);
        }
        /// <summary>
        /// Determines whether the beginning of the <paramref name="line"/> matches the <paramref name="keyword"/>.
        /// </summary>
        /// <param name="line">The line to match.</param>
        /// <param name="keyword">The gherkin keyword.</param>
        /// <returns><c>true</c> to indicate a match; otherwise <c>false</c>.</returns>
        public static bool StartsWith(this string line, GherkinKeyword keyword)
        {
            switch (keyword)
            {
            case GherkinKeyword.Where:
                return(line.TrimStart().StartsWith("where", true, CultureInfo.CurrentCulture));

            case GherkinKeyword.ScenarioOutline:
                return(line.TrimStart().StartsWith("scenario outline:", true, CultureInfo.CurrentCulture));

            default:
                return(line.TrimStart().StartsWith(keyword + ":", true, CultureInfo.CurrentCulture));
            }
        }
Пример #7
0
 public static ExtentTest CreateMethod(string parentName, GherkinKeyword keyword, string testName, string description = null)
 {
     lock (_synclock)
     {
         //ExtentTest parentTest = _testHierarchy.Value.Search(parentName);
         ExtentTest parentTest = _testHierarchy.Value.Search((t) => t.Model.Name, parentName);
         if (parentTest == null)
         {
             parentTest = CreateTest(keyword, testName);
         }
         _parentTest.Value = parentTest;
         _childTest.Value  = parentTest.CreateNode(keyword, testName, description);
         _testHierarchy.Value.AddChild(_childTest.Value);
         return(_childTest.Value);
     }
 }
Пример #8
0
        public static void GenerateTestReport()
        {
            if (Properties.Test.Default.GenerateReport)
            {
                _v3HtmlReporter.Stop();
                _extent.AddSystemInfo("Azure Calculator API endpoint",
                                      $"{Properties.Test.Default.AzureCalculatorHost} ({Properties.Test.Default.AzureCalculatorPath})");
                foreach (var feature in _report.Features)
                {
                    var featureNode = _extent.CreateTest <Feature>(feature.Name);

                    foreach (var scenario in feature.Scenarios)
                    {
                        var scenarioNode = featureNode.CreateNode <Scenario>(scenario.Name);

                        foreach (var tag in scenario.Tags)
                        {
                            scenarioNode.AssignCategory(tag);
                        }

                        foreach (var step in scenario.Steps)
                        {
                            var gherkinKeyword = new GherkinKeyword(step.Keyword.Trim());

                            var stepNode = scenarioNode.CreateNode(gherkinKeyword, step.Keyword + step.Name);

                            foreach (var log in step.Logs)
                            {
                                stepNode.Info(log);
                            }

                            if (!step.Pass && !_report.Name.Contains("API"))
                            {
                                stepNode.Fail(step.ErrorMessage).AddScreenCaptureFromPath(step.Screenshot);
                            }
                        }
                    }
                }

                _extent.Flush();
            }
        }
        /// <summary>
        /// Returns the name part of the <paramref name="value"/> after matching the <paramref name="keyword"/>.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="keyword">The gherkin keyword.</param>
        /// <returns>A string representation of the name value.</returns>
        public static string Name(this string value, GherkinKeyword keyword)
        {
            if (!value.Contains(":"))
            {
                if (keyword == GherkinKeyword.Where)
                {
                    return(string.Empty);
                }

                var msg = string.Format(CultureInfo.CurrentCulture, "The Gherkin keyword {0} was not followed by a ':' character", keyword);
                throw new GherkinException(GherkinExceptionType.InvalidGherkin, msg);
            }

            return(value.Split(':')[1]
                   .Replace("-", " ")
                   .Replace("'", " ")
                   .Replace("/", " ")
                   .Replace(">", " ")
                   .Trim());
        }
        public static void GenerateTestReport()
        {
            _v3HtmlReporter.Stop();

            foreach (var feature in _report.Features)
            {
                var _featureNode = _extent.CreateTest <Feature>(feature.Name);

                foreach (var scenario in feature.Scenarios)
                {
                    var _scenarioNode = _featureNode.CreateNode <Scenario>(scenario.Name);

                    foreach (var tag in scenario.Tags)
                    {
                        _scenarioNode.AssignCategory(tag);
                    }

                    foreach (var step in scenario.Steps)
                    {
                        var gherkinKeyword = new GherkinKeyword(step.Keyword.Trim());

                        var stepNode = _scenarioNode.CreateNode(gherkinKeyword, step.Keyword + step.Name);

                        foreach (var log in step.Logs)
                        {
                            stepNode.Info(log);
                        }

                        if (!step.Pass)
                        {
                            stepNode.Fail(step.ErrorMessage);
                        }
                    }
                }
            }

            _extent.Flush();
        }
Пример #11
0
        protected GherkinKeywordBase(ILanguageInfo info, GherkinKeyword keyword, string name, string description)
        {
#if PREFER_GEHERKIN_PLUS
            switch (keyword)
            {
            case GherkinKeyword.ScenarioOutline:
                this.Keyword = info.Get(GherkinKeyword.Scenarios);
                break;

            case GherkinKeyword.Examples:
                this.Keyword = info.Get(GherkinKeyword.Where);
                break;

            default:
                this.Keyword = info.Get(keyword);
                break;
            }
#else
            Keyword = info.Get(keyword);
#endif
            this.Name        = name ?? string.Empty;
            this.Description = description ?? string.Empty;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="GherkinStepBuilder{T}" /> class.
 /// </summary>
 /// <param name="info">The information.</param>
 /// <param name="keyword">The keyword.</param>
 protected GherkinStepBuilder(ILanguageInfo info, GherkinKeyword keyword)
     : base(info, keyword)
 {
 }
Пример #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GherkinBuilder{T}" /> class.
 /// </summary>
 /// <param name="info">The information.</param>
 /// <param name="keyword">The block keyword.</param>
 protected GherkinBuilder(ILanguageInfo info, GherkinKeyword keyword)
 {
     this.Keyword      = info.Get(keyword);
     this.LanguageInfo = info;
 }
Пример #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GherkinBuilder{T}" /> class.
 /// </summary>
 /// <param name="info">The information.</param>
 /// <param name="keyword">The keyword.</param>
 /// <param name="source">The source.</param>
 /// <param name="language">The language.</param>
 protected GherkinBuilder(ILanguageInfo info, GherkinKeyword keyword, string source, string language)
     : this(info, keyword)
 {
     this.comments.Add(new Comment(Lang + ": " + language));
     this.comments.Add(new Comment("source: " + source));
 }
 public static string Format(this GherkinKeyword keyword, string start, string end)
 {
     return(string.Format(CultureInfo.CurrentCulture, "{0}{1}{2}", start, keyword, end));
 }
 public static string Format(this GherkinKeyword keyword)
 {
     return(keyword.Format("[", "]"));
 }
Пример #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScenarioBuilder"/> class.
 /// </summary>
 /// <param name="info">The information.</param>
 /// <param name="title">The title.</param>
 /// <param name="keyword">The keyword.</param>
 protected ScenarioBuilder(ILanguageInfo info, string title, GherkinKeyword keyword)
     : base(info, keyword)
 {
     this.Title = title;
 }
Пример #18
0
 public TestStepDTO(GherkinKeyword step)
 {
     this.Keyword = step;
 }