Now I have a complete project and I wanted to parallel the testing in maven. If I set the parallel option, mine tests fails cause of DirtiesContexts
. (Even if I annotate the testclasses with @DirtiesContext(classMode=ClassMode.AFTER_CLASS)
)
现在我有一个完整的项目,我想在maven中并行测试。如果我设置了并行选项,则我的测试失败导致DirtiesContexts。 (即使我用@DirtiesContext注释测试类(classMode = ClassMode.AFTER_CLASS))
I'm not putting the stacktrace here but its failed to load applicationcontext cause he can't register the applicationcontext cause its already there.
我没有把堆栈跟踪放在这里,但是它无法加载applicationcontext,因为他无法注册applicationcontext,因为它已经存在。
If I use reusefork it tests succeeds even without annotating the DirtiesContext
.
如果我使用reusefork,即使没有注释DirtiesContext,测试也会成功。
When you use reusefork you will create always new VM for each fork (and that's the reason why it is succesfull). (see doc here : http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html)
当您使用reusefork时,您将为每个fork创建总是新的VM(这就是为什么它成功的原因)。 (请参阅此处的文档:http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html)
With parallel you will not do this so normally this would have less resources needed.
通过并行,您将不会这样做,所以通常这将需要更少的资源。
So now of to the question :
那么现在问题是:
- The link of doc says with parallel for TestNG only, but here they speak of JUnit 4.7 and higher so I'm confused, what's the correct documentation?
- doc的链接仅与TestNG并行,但在这里他们谈到JUnit 4.7及更高版本,所以我很困惑,什么是正确的文档?
- Is parallel testing better dan reusefork?
- 并行测试是否更好dan reusefork?
- If its better, how can I fix the
DirtiesContext
? - 如果它更好,我该如何修复DirtiesContext?
Thx in advance.
Thx提前。
1 个解决方案
#1
0
this blog post might answer some of your questions http://incodewetrustinc.blogspot.com/2010/01/run-your-junit-tests-concurrently-with.html
这篇博文可能会回答你的一些问题http://incodewetrustinc.blogspot.com/2010/01/run-your-junit-tests-concurrently-with.html
#1
0
this blog post might answer some of your questions http://incodewetrustinc.blogspot.com/2010/01/run-your-junit-tests-concurrently-with.html
这篇博文可能会回答你的一些问题http://incodewetrustinc.blogspot.com/2010/01/run-your-junit-tests-concurrently-with.html