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

Merged
merged 5 commits into from Jan 16, 2018

Conversation

Projects
None yet
2 participants
@Blackbaud-ChrisKessel
Contributor

Blackbaud-ChrisKessel commented Jan 2, 2018

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

This comment has been minimized.

Collaborator

SabotageAndi commented Jan 9, 2018

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.

@SabotageAndi

Please move it to the MSTest V2 Generator Provider

@Blackbaud-ChrisKessel

This comment has been minimized.

Contributor

Blackbaud-ChrisKessel commented Jan 9, 2018

@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

This comment has been minimized.

Collaborator

SabotageAndi commented Jan 10, 2018

I will have a look at it on friday.

@SabotageAndi SabotageAndi self-assigned this Jan 10, 2018

@SabotageAndi SabotageAndi added this to the SpecFlow 2.3 milestone Jan 10, 2018

@SabotageAndi

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

This comment has been minimized.

@SabotageAndi

SabotageAndi Jan 12, 2018

Collaborator

inherit from MsTest2010GeneratorProvider, so you can reuse much more code

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

This comment has been minimized.

@SabotageAndi

SabotageAndi Jan 12, 2018

Collaborator

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();

This comment has been minimized.

@SabotageAndi

SabotageAndi Jan 12, 2018

Collaborator

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);

This comment has been minimized.

@SabotageAndi

SabotageAndi Jan 12, 2018

Collaborator

same as above,
call base.SetTestMethod on MsTest2010GeneratorProvider

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

This comment has been minimized.

@SabotageAndi

SabotageAndi Jan 12, 2018

Collaborator

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

@SabotageAndi SabotageAndi merged commit f093eb6 into techtalk:master Jan 16, 2018

1 check passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details

@Blackbaud-ChrisKessel Blackbaud-ChrisKessel deleted the Blackbaud-ChrisKessel:mstestv2_DoNotParallelize_984 branch Jan 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment