コード例 #1
0
 public void SetTestClassParallelize(TestClassGenerationContext generationContext)
 {
     _codeDomHelper.AddAttribute(generationContext.TestClass, "Xunit.CollectionAttribute", new CodeAttributeArgument[1]
     {
         new CodeAttributeArgument(new CodePrimitiveExpression(Guid.NewGuid()))
     });
 }
        public void SetTestClass(TechTalk.SpecFlow.Generator.TestClassGenerationContext generationContext, string featureTitle, string featureDescription)
        {
            codeDomHelper.AddAttribute(generationContext.TestClass, TESTFIXTURE_ATTR);
            codeDomHelper.AddAttribute(generationContext.TestClass, DESCRIPTION_ATTR, featureTitle);

            generationContext.Namespace.Imports.Add(new CodeNamespaceImport("Autofac"));
            generationContext.Namespace.Imports.Add(new CodeNamespaceImport("Autofac.Configuration"));

            generationContext.TestClass.Members.Add(new CodeMemberField("OpenQA.Selenium.IWebDriver", "driver"));
            generationContext.TestClass.Members.Add(new CodeMemberField("IContainer", "container"));

            CreateInitializeSeleniumMethod(generationContext);
        }
コード例 #3
0
        public void SetTestMethodCategories(TestClassGenerationContext generationContext, CodeMemberMethod testMethod,
                                            IEnumerable <string> scenarioCategories)
        {
            List <string> ignoreParameters = new List <string>();

            foreach (string category in scenarioCategories)
            {
                int IndexOfAttributeIdentifier   = category.IndexOf(CATEOGRY_WITH_COLON);
                int IndexOfCategoryWithSemicolon = category.IndexOf(CATEOGRY_WITH_SEMICOLON);

                if (IndexOfAttributeIdentifier > 0)
                {
                    if (category.StartsWith(TIMEOUT_TAG_PREFIX))
                    {
                        string TimeoutAttributeIdentifier = category.Substring(0, IndexOfAttributeIdentifier);
                        string TimeoutAttributeParameters = category.Substring(IndexOfAttributeIdentifier + 1);
                        AddNUnitAttributes(testMethod, TimeoutAttributeIdentifier, TimeoutAttributeParameters);
                    }
                    else
                    {
                        string IgnoreAttributeFirstParameter = category.Substring(IndexOfAttributeIdentifier + 1);
                        ignoreParameters.Add(IgnoreAttributeFirstParameter);
                        flagForCategoryWithSemicolon = true;
                    }
                }
                else if (flagForCategoryWithSemicolon)
                {
                    if (category.Contains(CATEOGRY_WITH_SEMICOLON))
                    {
                        string CategoryAttributeWithoutSemicolon = category.Substring(0, IndexOfCategoryWithSemicolon);
                        ignoreParameters.Add(CategoryAttributeWithoutSemicolon);
                        flagForCategoryWithSemicolon = false;
                    }
                    else
                    {
                        ignoreParameters.Add(category);
                    }
                }
                else
                {
                    codeDomHelper.AddAttribute(testMethod, CATEGORY_ATTR, category);
                }
            }
            string combindedIgnoreParameter = string.Join(" ", ignoreParameters.ToArray());

            if (!String.IsNullOrWhiteSpace(combindedIgnoreParameter))
            {
                AddNUnitAttributes(testMethod, "Ignore", combindedIgnoreParameter);
            }
        }
コード例 #4
0
        public void SetTestMethod(TestClassGenerationContext generationContext, CodeMemberMethod testMethod, string scenarioTitle)
        {
            SetProperty(testMethod, FeatureTitlePropertyName, generationContext.Feature.Title);
            SetDescription(testMethod, scenarioTitle);

            bool isOptionallyIgnoreTagAdded = false;

            foreach (Scenario scenario in generationContext.Feature.Scenarios.Where(a => a.Title == scenarioTitle))
            {
                if (scenario.Tags == null)
                {
                    CodeDomHelper.AddAttribute(testMethod, factAttribute);
                    return;
                }

                foreach (Tag tag in scenario.Tags)
                {
                    if (String.Equals(tag.Name, IgnoreTagName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        CodeDomHelper.AddAttribute(testMethod, ignorableFactAttribute);
                        isOptionallyIgnoreTagAdded = true;
                    }
                }

                if (!isOptionallyIgnoreTagAdded)
                {
                    CodeDomHelper.AddAttribute(testMethod, factAttribute);
                }
            }
        }
 protected override CodeAttributeDeclaration InternalProvideAttribute(CodeDomHelper codeDomHelper,
                                                                      CodeMemberMethod method,
                                                                      string nCrunchAttributeParameters)
 {
     object[] ncrunchAttributeValues = nCrunchAttributeParameters.Split('_').AsEnumerable <object>().ToArray();
     return(codeDomHelper.AddAttribute(method, AttributeName(), ncrunchAttributeValues));
 }
コード例 #6
0
        public void SetRowTest(TestClassGenerationContext generationContext, CodeMemberMethod testMethod, string scenarioTitle)
        {
            CodeDomHelper.AddAttribute(testMethod, theoryAttribute);

            SetProperty(testMethod, FeatureTitlePropertyName, generationContext.Feature.Title);
            SetDescription(testMethod, scenarioTitle);
        }
コード例 #7
0
        public override void SetTestMethod(TestClassGenerationContext generationContext, CodeMemberMethod testMethod, string scenarioTitle)
        {
            //       [TestMethod, DataSource("Microsoft.VisualStudio.TestTools.DataSource.TestCase", "http://tfs-win2012:8080/tfs/StuCollection;SpecflowDemo, "297860", DataAccessMethod.Sequential)]


            foreach (var scenario in generationContext.Feature.Scenarios)
            {
                if (scenario.Title == scenarioTitle)
                {
                    if (scenario.Tags != null)
                    {
                        Tag WorkItemId = scenario.Tags.FirstOrDefault(x => x.Name.StartsWith("workitem"));
                        if (WorkItemId != null)
                        {
                            scenario.Tags.Remove(WorkItemId);

                            var WorkItemIdText = WorkItemId.Name.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries)[1];

                            CodeTypeReferenceExpression dataAccessMethodCodeTypeRefExpr = new CodeTypeReferenceExpression("Microsoft.VisualStudio.TestTools.UnitTesting.DataAccessMethod");

                            var datasourceArgs = new CodeAttributeArgument[] {
                                new CodeAttributeArgument(new CodePrimitiveExpression("Microsoft.VisualStudio.TestTools.DataSource.TestCase")),
                                new CodeAttributeArgument(new CodePrimitiveExpression(string.Format("http://tfs-win2012:8080/tfs/StuCollection;{0}", "SpecflowDemo"))),
                                new CodeAttributeArgument(new CodePrimitiveExpression(WorkItemIdText)),
                                new CodeAttributeArgument(new CodeFieldReferenceExpression(dataAccessMethodCodeTypeRefExpr, "Sequential"))
                            };

                            CodeDomHelper.AddAttribute(testMethod, DATASOURCE_ATTR, datasourceArgs);
                        }
                    }
                }
            }

            base.SetTestMethod(generationContext, testMethod, scenarioTitle);
        }
コード例 #8
0
        public virtual void SetTestClass(TestClassGenerationContext generationContext, string featureTitle, string featureDescription)
        {
            CodeDomHelper.AddAttribute(generationContext.TestClass, TESTFIXTURE_ATTR);

            // Add a TestContext field
            generationContext.TestClass.Members.Add(new CodeMemberField(TESTCONTEXT_TYPE, TESTCONTEXT_FIELD_NAME));

            // Add a TestContext property
            var testContextProperty = new CodeMemberProperty
            {
                Attributes = MemberAttributes.Public,
                Name       = TESTCONTEXT_PROPERTY_NAME,
                HasGet     = true,
                HasSet     = true,
                Type       = new CodeTypeReference(TESTCONTEXT_TYPE)
            };

            testContextProperty.GetStatements.Add(new CodeMethodReturnStatement(
                                                      new CodeFieldReferenceExpression(
                                                          new CodeThisReferenceExpression(), TESTCONTEXT_FIELD_NAME)));
            testContextProperty.SetStatements.Add(new CodeAssignStatement(
                                                      new CodeFieldReferenceExpression(
                                                          new CodeThisReferenceExpression(), TESTCONTEXT_FIELD_NAME), new CodePropertySetValueReferenceExpression()));

            generationContext.TestClass.Members.Add(testContextProperty);
        }
コード例 #9
0
        public override void SetTestMethodCategories(TestClassGenerationContext generationContext, CodeMemberMethod testMethod, IEnumerable <string> scenarioCategories)
        {
            IEnumerable <string> tags = scenarioCategories.ToList();

            IEnumerable <string> ownerTags = tags.Where(t => t.StartsWith(OWNER_TAG, StringComparison.InvariantCultureIgnoreCase)).Select(t => t);

            if (ownerTags.Any())
            {
                string ownerName = ownerTags.Select(t => t.Substring(OWNER_TAG.Length).Trim('\"')).FirstOrDefault();
                if (!String.IsNullOrEmpty(ownerName))
                {
                    CodeDomHelper.AddAttribute(testMethod, OWNER_ATTR, ownerName);
                }
            }

            IEnumerable <string> workitemTags = tags.Where(t => t.StartsWith(WORKITEM_TAG, StringComparison.InvariantCultureIgnoreCase)).Select(t => t);

            if (workitemTags.Any())
            {
                int temp;
                IEnumerable <string> workitemsAsStrings = workitemTags.Select(t => t.Substring(WORKITEM_TAG.Length).Trim('\"'));
                IEnumerable <int>    workitems          = workitemsAsStrings.Where(t => int.TryParse(t, out temp)).Select(t => int.Parse(t));
                foreach (int workitem in workitems)
                {
                    CodeDomHelper.AddAttribute(testMethod, WORKITEM_ATTR, workitem);
                }
            }

            CodeDomHelper.AddAttributeForEachValue(testMethod, CATEGORY_ATTR, GetNonMSTestSpecificTags(tags));
        }
コード例 #10
0
 private void SetBrowsers(CodeMemberMethod testMethod)
 {
     foreach (var item in Browsers)
     {
         CodeDomHelper.AddAttribute(testMethod, InlineDataAttribute, item);
     }
 }
コード例 #11
0
        public virtual void AddTestCaseAttributeForEachBrowser(CodeMemberMethod testMethod, string browser,
                                                               string rowDataAsString = null,
                                                               IEnumerable <CodeAttributeArgument> attributeArguments = null)
        {
            var keyName = $"{CategorySelection.BrowserTagName}{browser}";

            if (!testMethod.UserData.Contains(keyName))
            {
                testMethod.UserData.Add(keyName, browser);
            }

            var browserSpecifications = browser.UserFriendlyBrowserConfiguration();
            var testName = $"{testMethod.GetDescription()} on {browserSpecifications}";

            if (!string.IsNullOrWhiteSpace(rowDataAsString))
            {
                testName += $" with: {rowDataAsString}";
            }

            var withBrowserArgs = new[] { new CodeAttributeArgument(new CodePrimitiveExpression(browser)) }
            .Concat(attributeArguments ?? Enumerable.Empty <CodeAttributeArgument>())
            .Concat(new[]
            {
                new CodeAttributeArgument("Category", new CodePrimitiveExpression(browserSpecifications)),
                new CodeAttributeArgument("TestName", new CodePrimitiveExpression(testName))
            })
            .ToArray();

            CodeDomHelper.AddAttribute(testMethod, ROW_ATTR, withBrowserArgs);
        }
コード例 #12
0
        public void SetTestMethodCategories(TestClassGenerationContext generationContext, CodeMemberMethod testMethod, IEnumerable <string> scenarioCategories)
        {
            //we don't want "@Browser:browser" as separate categories. We only want these categories on the actual test case rows.
            var categories = scenarioCategories.ToArray();
            var categoriesWithoutBrowser = categories.Where(category => !category.StartsWith(BROWSER_TAG_PREFIX)).ToArray();
            var categoriesForAllTests    = LegalizeCategories(categoriesWithoutBrowser).ToArray();

            CodeDomHelper.AddAttributeForEachValue(testMethod, CATEGORY_ATTR, categoriesForAllTests);

            //add Property attributes for all tags containing a ':' separated key value pair (except for browser)
            var properties = this.ExtractProperties(categoriesWithoutBrowser);

            foreach (var property in properties)
            {
                CodeDomHelper.AddAttribute(testMethod, PROPERTY_ATTR, property.Key, property.Value);
            }


            //and finally determine which browsers we should inject
            var browsers = categories
                           .Where(category => category.StartsWith(BROWSER_TAG_PREFIX))
                           .Select(category => category.Replace(BROWSER_TAG_PREFIX, ""))
                           .ToArray();

            if (browsers.Any())
            {
                //if present, get the @Repeat:<number of repeats> value and store it in UserData so we can use it in the scenario outline case later
                var repeats = GetRepeats(properties);
                testMethod.UserData.Add(REPEATS_KEY, repeats + "");

                //inject an argument, string browser, as the first argument in the test method
                testMethod.Parameters.Insert(0, new CodeParameterDeclarationExpression("System.string", "browser"));

                foreach (var browser in browsers)
                {
                    //store browser in user data so we can use it later if this is a row test/scenario ouline
                    testMethod.UserData.Add(BROWSER_TAG_PREFIX + browser, browser);

                    //create a property that contains the test data
                    var testCaseSource = CreateTestCaseSource(generationContext, testMethod.Name, browser, repeats);
                    AddTestCaseSourceRow(generationContext, testCaseSource, new[] { browser });

                    var browserArgument = new[]
                    {
                        // first argument == test case source data
                        new CodeAttributeArgument(new CodePrimitiveExpression(testCaseSource)),
                        // add browser value as category
                        new CodeAttributeArgument("Category", new CodePrimitiveExpression(browser))
                    };
                    this.CodeDomHelper.AddAttribute(testMethod, ROW_SOURCE_ATTR, browserArgument);
                }

                //Yay, we have a browser tag, assign it to the Browser field in the method body
                var assignBrowserStatement = new CodeAssignStatement(
                    new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "Browser"),
                    new CodeArgumentReferenceExpression("browser")
                    );
                testMethod.Statements.Insert(0, assignBrowserStatement);
            }
        }
コード例 #13
0
        public void SetRow(TestClassGenerationContext generationContext, CodeMemberMethod testMethod, IEnumerable <string> arguments, IEnumerable <string> tags, bool isIgnored)
        {
            var args = arguments.Select(
                arg => new CodeAttributeArgument(new CodePrimitiveExpression(arg))).ToList();

            // addressing ReSharper bug: TestCase attribute with empty string[] param causes inconclusive result - https://github.com/techtalk/SpecFlow/issues/116
            bool           hasExampleTags           = tags.Any();
            var            exampleTagExpressionList = tags.Select(t => new CodePrimitiveExpression(t));
            CodeExpression exampleTagsExpression    = hasExampleTags
                ? new CodeArrayCreateExpression(typeof(string[]), exampleTagExpressionList.ToArray())
                : (CodeExpression) new CodePrimitiveExpression(null);

            args.Add(new CodeAttributeArgument(exampleTagsExpression));

            // adds 'Category' named parameter so that NUnit also understands that this test case belongs to the given categories
            if (hasExampleTags)
            {
                CodeExpression exampleTagsStringExpr = new CodePrimitiveExpression(string.Join(",", tags.ToArray()));
                args.Add(new CodeAttributeArgument("Category", exampleTagsStringExpr));
            }

            if (isIgnored)
            {
                args.Add(new CodeAttributeArgument("Ignored", new CodePrimitiveExpression(true)));
            }

            CodeDomHelper.AddAttribute(testMethod, ROW_ATTR, args.ToArray());
        }
コード例 #14
0
        public void SetTestMethod(TestClassGenerationContext generationContext, CodeMemberMethod testMethod, string friendlyTestName)
        {
            CodeDomHelper.AddAttribute(testMethod, FACT_ATTRIBUTE, new CodeAttributeArgument("DisplayName", new CodePrimitiveExpression(friendlyTestName)));

            SetProperty(testMethod, FEATURE_TITLE_PROPERTY_NAME, generationContext.Feature.Name);
            SetDescription(testMethod, friendlyTestName);
        }
コード例 #15
0
        public override void SetRowTest(TestClassGenerationContext generationContext, CodeMemberMethod testMethod, string scenarioTitle)
        {
            CodeDomHelper.AddAttribute(testMethod, THEORY_ATTRIBUTE, new CodeAttributeArgument("DisplayName", new CodePrimitiveExpression(scenarioTitle)));

            SetProperty(testMethod, FEATURE_TITLE_PROPERTY_NAME, generationContext.Feature.Name);
            SetDescription(testMethod, scenarioTitle);
        }
コード例 #16
0
 public void SetTestClassIgnore(TestClassGenerationContext generationContext)
 {
     //NUnit
     CodeDomHelper.AddAttribute(generationContext.TestClass, IGNORE_ATTR);
     //MSTest
     CodeDomHelper.AddAttribute(generationContext.TestClass, MS_IGNORE_ATTR);
 }
コード例 #17
0
        public virtual void SetRowTest(TestClassGenerationContext generationContext, CodeMemberMethod testMethod, string scenarioTitle)
        {
            CodeDomHelper.AddAttribute(testMethod, THEORY_ATTRIBUTE);

            SetProperty(testMethod, FEATURE_TITLE_PROPERTY_NAME, generationContext.Feature.Name);
            SetDescription(testMethod, scenarioTitle);
        }
コード例 #18
0
        public override void SetTestMethod(TestClassGenerationContext generationContext, CodeMemberMethod testMethod, string friendlyTestName)
        {
            base.SetTestMethod(generationContext, testMethod, friendlyTestName);
            if (generationContext.CustomData.ContainsKey("featureCategories"))
            {
                var featureCategories = (string[])generationContext.CustomData["featureCategories"];
                CodeDomHelper.AddAttributeForEachValue(testMethod, CATEGORY_ATTR, featureCategories);
            }

            if (generationContext.CustomData.ContainsKey(OWNER_TAG))
            {
                string ownerName = generationContext.CustomData[OWNER_TAG] as string;
                if (!String.IsNullOrEmpty(ownerName))
                {
                    CodeDomHelper.AddAttribute(testMethod, OWNER_ATTR, ownerName);
                }
            }

            if (generationContext.CustomData.ContainsKey(WORKITEM_TAG))
            {
                IEnumerable <int> workitems = generationContext.CustomData[WORKITEM_TAG] as IEnumerable <int>;
                foreach (int workitem in workitems)
                {
                    CodeDomHelper.AddAttribute(testMethod, WORKITEM_ATTR, workitem);
                }
            }
        }
コード例 #19
0
        public void SetTestMethodIgnore(TestClassGenerationContext generationContext, CodeMemberMethod testMethod)
        {
            //NUnit
            CodeDomHelper.AddAttribute(testMethod, IGNORE_ATTR);

            //MSTest
            CodeDomHelper.AddAttribute(testMethod, MS_IGNORE_ATTR);
        }
コード例 #20
0
        public void SetTestCleanupMethod(TestClassGenerationContext generationContext)
        {
            //NUnit
            CodeDomHelper.AddAttribute(generationContext.TestCleanupMethod, TESTTEARDOWN_ATTR);

            //MSTest
            CodeDomHelper.AddAttribute(generationContext.TestCleanupMethod, MS_TESTTEARDOWN_ATTR);
        }
コード例 #21
0
        public virtual void SetTestClassInitializeMethod(TestClassGenerationContext generationContext)
        {
            generationContext.TestClassInitializeMethod.Attributes |= MemberAttributes.Static;
            generationContext.TestClassInitializeMethod.Parameters.Add(new CodeParameterDeclarationExpression(
                                                                           TESTCONTEXT_TYPE, "testContext"));

            CodeDomHelper.AddAttribute(generationContext.TestClassInitializeMethod, TESTFIXTURESETUP_ATTR);
        }
コード例 #22
0
 public override void SetTestMethod(TestClassGenerationContext generationContext, CodeMemberMethod testMethod, string friendlyTestName)
 {
     if (generationContext.CustomData.ContainsKey(DONOTPARALLELIZE_TAG))
     {
         CodeDomHelper.AddAttribute(testMethod, DONOTPARALLELIZE_ATTR);
     }
     base.SetTestMethod(generationContext, testMethod, friendlyTestName);
 }
コード例 #23
0
 private void AddNcrunchAttributes(CodeMemberMethod testMethod, string nCrunchAttributeIdentifier, string[] nCrunchAttributeValues)
 {
     if (MatchesIdentifier(nCrunchAttributeIdentifier, NCrunchAttributeNames.NCrunchExclusivelyUses))
     {
         codeDomHelper.AddAttribute(testMethod, NCrunchAttributeNames.NCrunchExclusivelyUses, nCrunchAttributeValues);
     }
     if (MatchesIdentifier(nCrunchAttributeIdentifier, NCrunchAttributeNames.NCrunchIsolated))
     {
         codeDomHelper.AddAttribute(testMethod, NCrunchAttributeNames.NCrunchIsolated);
     }
     if (MatchesIdentifier(nCrunchAttributeIdentifier, NCrunchAttributeNames.NCrunchSerial))
     {
         codeDomHelper.AddAttribute(testMethod, NCrunchAttributeNames.NCrunchSerial);
     }
     if (MatchesIdentifier(nCrunchAttributeIdentifier, NCrunchAttributeNames.NCrunchInclusivelyUses))
     {
         codeDomHelper.AddAttribute(testMethod, NCrunchAttributeNames.NCrunchInclusivelyUses, nCrunchAttributeValues);
     }
     if (MatchesIdentifier(nCrunchAttributeIdentifier, NCrunchAttributeNames.NCrunchRequiresCapability))
     {
         codeDomHelper.AddAttribute(testMethod, NCrunchAttributeNames.NCrunchRequiresCapability, nCrunchAttributeValues);
     }
     if (MatchesIdentifier(nCrunchAttributeIdentifier, NCrunchAttributeNames.NCrunchCategory))
     {
         codeDomHelper.AddAttribute(testMethod, NCrunchAttributeNames.NCrunchCategory, nCrunchAttributeValues);
     }
     if (MatchesIdentifier(nCrunchAttributeIdentifier, NCrunchAttributeNames.NCrunchTimeout))
     {
         codeDomHelper.AddAttribute(testMethod, NCrunchAttributeNames.NCrunchTimeout, int.Parse(nCrunchAttributeValues.First(), CultureInfo.InvariantCulture));
     }
 }
コード例 #24
0
        public override void SetTestClass(TestClassGenerationContext generationContext, string featureTitle, string featureDescription)
        {
            if (generationContext.Feature.Tags.Any(t => t.Name.Substring(1).StartsWith(DEPLOYMENTITEM_TAG, StringComparison.InvariantCultureIgnoreCase)))
            {
                CodeDomHelper.AddAttribute(generationContext.TestClass, DEPLOYMENTITEM_ATTR, "TechTalk.SpecFlow.MSTest.SpecFlowPlugin.dll");
            }

            base.SetTestClass(generationContext, featureTitle, featureDescription);
        }
コード例 #25
0
        public void SetTestClassCleanupMethod(TestClassGenerationContext generationContext)
        {
            //Nunit
            CodeDomHelper.AddAttribute(generationContext.TestClassCleanupMethod, TESTFIXTURETEARDOWN_ATTR);

            //MSTest
            generationContext.TestClassCleanupMethod.Attributes |= MemberAttributes.Static;
            CodeDomHelper.AddAttribute(generationContext.TestClassCleanupMethod, MS_TESTFIXTURETEARDOWN_ATTR);
        }
コード例 #26
0
        public void SetTestClassCollection(TestClassGenerationContext generationContext, string collection)
        {
            //No spaces.
            //'-', and '_' are allowed.
            string collectionMatch = $@"(?<={COLLECTION_TAG}[(])[A-Za-z0-9\-_]+.*?(?=[)])";
            string description     = Regex.Match(collection, collectionMatch, RegexOptions.IgnoreCase).Value;

            CodeDomHelper.AddAttribute(generationContext.TestClass, COLLECTION_DEF, description);
        }
コード例 #27
0
        public virtual void SetTestInitializeMethod(TestClassGenerationContext generationContext)
        {
            CodeDomHelper.AddAttribute(generationContext.TestInitializeMethod, TESTSETUP_ATTR);

            //if (FeatureContext.Current != null && FeatureContext.Current.FeatureInfo.Title != "<current_feature_title>")
            //  <TestClass>.<TestClassInitialize>(null);

            FixTestRunOrderingIssue(generationContext);
        }
コード例 #28
0
        public virtual void SetTestMethod(TestClassGenerationContext generationContext, CodeMemberMethod testMethod, string friendlyTestName)
        {
            CodeDomHelper.AddAttribute(testMethod, TEST_ATTR);
            CodeDomHelper.AddAttribute(testMethod, DESCRIPTION_ATTR, friendlyTestName);

            //as in mstest, you cannot mark classes with the description attribute, we
            //just apply it for each test method as a property
            SetProperty(testMethod, FEATURE_TITILE_PROPERTY_NAME, generationContext.Feature.Name);
        }
コード例 #29
0
        public virtual void SetTestInitializeMethod(TestClassGenerationContext generationContext)
        {
            //NUnit
            CodeDomHelper.AddAttribute(generationContext.TestInitializeMethod, TESTSETUP_ATTR);

            //MSTest
            CodeDomHelper.AddAttribute(generationContext.TestInitializeMethod, MS_TESTSETUP_ATTR);

            FixTestRunOrderingIssue(generationContext);
        }
コード例 #30
0
        public override void SetTestInitializeMethod(TestClassGenerationContext generationContext)
        {
            CodeDomHelper.AddAttribute(generationContext.TestInitializeMethod, TestSetupAttr);
            generationContext.Namespace.Imports.Add(new CodeNamespaceImport("Unickq.SpecFlow.Selenium"));

            generationContext.TestClassInitializeMethod.Statements.Add(
                GenerateCodeSnippetStatement("helper = new UnickqSpecFlowSeleniumAllureGeneratorHelper(testRunner);"));
            generationContext.TestClassInitializeMethod.Statements.Add(
                GenerateCodeSnippetStatement("helper.FeatureSetup();"));
            generationContext.TestInitializeMethod.Statements.Add(GenerateCodeSnippetStatement("helper.SetUp();"));
        }