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

Add an Analyzer to Verify ParallelScope Usage #64

Closed
JasonBock opened this issue Jun 18, 2018 · 1 comment · Fixed by #97
Closed

Add an Analyzer to Verify ParallelScope Usage #64

JasonBock opened this issue Jun 18, 2018 · 1 comment · Fixed by #97

Comments

@JasonBock
Copy link
Contributor

JasonBock commented Jun 18, 2018

According to this doc, values of ParallelScope are only valid based on what member the Parallelizable is being used on. For example, ParalleScope.Children cannot be used on methods. Writing an analyzer to inform the developer of improper value usage would be a nice thing to have.

Edit by mikkelbu: Corrected link.

@mikkelbu
Copy link
Member

mikkelbu commented Jun 30, 2018

See the documentation for more information.

From the code in ParallelizableAttribute.cs and the example below it seems that the validation is only for [Parallelizable(ParallelScope.Children)] and [Parallelizable(ParallelScope.Fixtures)] on test methods.

using NUnit.Framework;

// [assembly: Parallelizable(ParallelScope.Self)] // does not have an effect

namespace ParallelScopeTest
{
  [TestFixture]
  public class Class1
  {
    [Test]
    public void Test1()
    {
      Assert.Pass();
    }

    // [Parallelizable(ParallelScope.Children)] // Message: May not specify ParallelScope.Children on a non-parameterized test method
    [Test]
    public void Test2()
    {
      Assert.Pass();
    }

    // [Parallelizable(ParallelScope.Fixtures)] // Message: May not specify ParallelScope.Fixtures on a test method
    [Test]
    public void Test3()
    {
      Assert.Pass();
    }
  }
}

@mikkelbu mikkelbu self-assigned this Dec 20, 2018
mikkelbu added a commit to mikkelbu/nunit.analyzers that referenced this issue Dec 28, 2018
Verifies and reports the following:
* (Warning) ParallelScope.Self on assembly level as it has no effect
* (Error) ParallelScope.Children on a non-parameterized test method
* (Error) ParallelScope.Fixtures on a test method

Fixes nunit#64
@mikkelbu mikkelbu added this to the Release 0.2 milestone Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants