admin 管理员组文章数量: 1086019
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.
本文标签: cCan setup methods run in parallel for NonParallelizable testsStack Overflow
版权声明:本文标题:c# - Can setup methods run in parallel for NonParallelizable tests? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744017072a2519113.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论