Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for DoNotParallelize for MSTest V2 parallelism #996

Conversation

Blackbaud-ChrisKessel
Copy link
Contributor

Adding feature @mstest:DoNotParallize to utilize MsTest V2's DoNotParallelize attribute.
Tag can be added to feature or scenario.
Running the Features/Scenarios using this attribute requires MsTest.TestFramework version > 1.2.0.
Just the generation of the '*.feature.cs' does not carry the dependency on MsTest.TestFramework version > 1.2.0.

@SabotageAndi
Copy link
Contributor

As this attribute is only available in MSTest V2 (according to your description, could you put a link to the docs of it here?), please add this to the MSTestV2 Test Generator you added.

Copy link
Contributor

@SabotageAndi SabotageAndi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move it to the MSTest V2 Generator Provider

@Blackbaud-ChrisKessel
Copy link
Contributor Author

@SabotageAndi - here is the link to the mstest v2 doc containing the description for '[DoNotParallelize()]'
https://github.com/Microsoft/testfx-docs/blob/master/RFCs/004-In-Assembly-Parallel-Execution.md

@SabotageAndi
Copy link
Contributor

I will have a look at it on friday.

Copy link
Contributor

@SabotageAndi SabotageAndi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you change the base class from MsTestGeneratorProvider to MsTest2010GeneratorProvider you can remove a lot of code and use it from the baseclass.


namespace TechTalk.SpecFlow.Generator.UnitTestProvider
{
public class MsTestV2GeneratorProvider : MsTestGeneratorProvider
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inherit from MsTest2010GeneratorProvider, so you can reuse much more code

{
public class MsTestV2GeneratorProvider : MsTestGeneratorProvider
{
private const string CATEGORY_ATTR = "Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make the fields on MsTest2010GeneratorProvider protected if you need them in this class


public override void SetTestClassCategories(TestClassGenerationContext generationContext, IEnumerable<string> featureCategories)
{
generationContext.CustomData["featureCategories"] = GetNonMSTestSpecificTags(featureCategories).ToArray();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you change the base class, this could be a simple base.SetTestClassCategories(generationContext, featureCategories).
No need to copy the whole function.


public override void SetTestMethod(TestClassGenerationContext generationContext, CodeMemberMethod testMethod, string friendlyTestName)
{
base.SetTestMethod(generationContext, testMethod, friendlyTestName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above,
call base.SetTestMethod on MsTest2010GeneratorProvider


public override void SetTestMethodCategories(TestClassGenerationContext generationContext, CodeMemberMethod testMethod, IEnumerable<string> scenarioCategories)
{
IEnumerable<string> tags = scenarioCategories.ToList();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, base.SetTestMethodCategories on MsTest2010GeneratorProvider and only add the code you need

@SabotageAndi SabotageAndi merged commit f093eb6 into SpecFlowOSS:master Jan 16, 2018
@Blackbaud-ChrisKessel Blackbaud-ChrisKessel deleted the mstestv2_DoNotParallelize_984 branch January 16, 2018 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants