-
Notifications
You must be signed in to change notification settings - Fork 160
NUnit1010
Mikkel Nylander Bundgaard edited this page Apr 25, 2020
·
2 revisions
| Topic | Value |
|---|---|
| Id | NUnit1010 |
| Severity | Error |
| Enabled | True |
| Category | Structure |
| Code | ParallelizableUsageAnalyzer |
One may not specify ParallelScope.Fixtures on a test method.
To prevent tests that will fail at runtime due to improper construction.
[Parallelizable(ParallelScope.Fixtures)]
[Test]
public void NUnit1010SampleTest()
{
Assert.Pass();
}In the sample above, ParallelScope.Fixtures is specified.
However, in the context of a test method, a scope of Fixtures does not make sense. This scope only applies at the assembly or class level.
Remove the attribute:
[Test]
public void NUnit1010SampleTest()
{
Assert.Pass();
}Or apply this attribute at the class level:
[Parallelizable(ParallelScope.Fixtures)]
public class MyTests
{
[Test]
public void NUnit1010SampleTest()
{
Assert.Pass();
}
}Or use a different attribute that applies at the test level:
[Parallelizable(ParallelScope.Self)]
[Test]
public void NUnit1010SampleTest()
{
Assert.Pass();
}Configure the severity per project, for more info see MSDN.
#pragma warning disable NUnit1010 // No ParallelScope.Fixtures on a test method.
Code violating the rule here
#pragma warning restore NUnit1010 // No ParallelScope.Fixtures on a test method.Or put this at the top of the file to disable all instances.
#pragma warning disable NUnit1010 // No ParallelScope.Fixtures on a test method.[System.Diagnostics.CodeAnalysis.SuppressMessage("Structure",
"NUnit1010:No ParallelScope.Fixtures on a test method.",
Justification = "Reason...")]Copyright (c) 2018 The NUnit Project - Licensed under CC BY-NC-SA 4.0