I have a test method with a NonParallelizable
attribute. The question is:
Can it be, that TestSetup()
method runs in parallel to the running TestMeth()
of previous test case and only TestMeth()
methods are "locked"?
I see NonParallelizable
can be set for each method, also for TestSetup()
.
public class TestClass
{
[SetUp]
public void TestSetup()
{
//some init stuff, which must be done for each test case nonparallel to the running tests/test cases
}
[NonParallelizable, TestCaseSource("SomeTestCaseProvider")]
public void TestMeth()
{
//...
}
}
I have a test method with a NonParallelizable
attribute. The question is:
Can it be, that TestSetup()
method runs in parallel to the running TestMeth()
of previous test case and only TestMeth()
methods are "locked"?
I see NonParallelizable
can be set for each method, also for TestSetup()
.
public class TestClass
{
[SetUp]
public void TestSetup()
{
//some init stuff, which must be done for each test case nonparallel to the running tests/test cases
}
[NonParallelizable, TestCaseSource("SomeTestCaseProvider")]
public void TestMeth()
{
//...
}
}
Share
Improve this question
asked Mar 28 at 19:29
RekshinoRekshino
7,3352 gold badges24 silver badges50 bronze badges
2 Answers
Reset to default 1The documentation about NonParallelizable
says that
When used on a test fixture or method, that test will be queued on the non-parallel queue and will not run while other tests marked as Parallelizable are being run.
Again via the docs the Setup
method is supposed to run "just before each test method is called.".
I haven't explicitly tested/looked at the source code, but logically since Setup
depends on TestMethod
to be "just before runnable" and TestMethod
depends on parallelizable code to have finished, it should follow that Setup
should also depend on other parallelizable tests to have finished before it executes.
SetUp, TearDown and the Test method itself, all run on the same thread. When the docs talk about queuing a "test" it refers to all three. Any Parallelizable` or `NonParallelizable
` attribute that appears on the test method applies to the "test" as a whole.
It has to work that way, since the SetUp prepares the environment in which the test method will run and the TearDown cleans it up.