线程 Maven 通过顺序单元测试构建?
使用 Maven 3,可以构建具有多个线程的项目,例如,
mvn -T 4 clean install
由于我们在一致的数据库上设置了单元测试(并在执行期间操作数据),因此我们需要确保这些单元测试不会在并行执行。我知道 Maven-Surefire-Plugin 有一个配置选项可以顺序执行测试或启用并行执行:
<configuration>
<parallel>classes</parallel>
</configuration>
当我将此配置留空时,测试应该顺序执行,对吗?但是,当像上面那样使用多个 Maven 线程(-T)调用 Build 时,执行仍然是顺序的吗?
With Maven 3 it`s possible to build Projects with multiple Threads, like
mvn -T 4 clean install
Since we have Unit-Tests setting up on a consistent Database (and manipulating the data during execution), we need to make sure, that these Unit Tests are not running in parallel execution. I know that there is a configuration-option for Maven-Surefire-Plugin to execute Tests sequentially or enable parallel execution:
<configuration>
<parallel>classes</parallel>
</configuration>
When I leave this configuration empty Tests should be executed sequentially, right? But is execution still sequentially when calling the Build with multiple Maven-Threads (-T) like above?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想你要找的可能是这里。这是关于 Surefire 如何分叉和/或运行并行线程的问题。
I think what you're looking for might be here. It's about how surefire forks and or runs parallel threads.
据我了解并从 文档 中,并行构建并行运行
模块
,而不是每个模块内的目标
。在这种情况下,模块中的单元测试将按顺序运行,除非在 Surefire 中配置为并行运行。As far as I understand and from the documentation, parallel build runs
modules
in parallel and not thegoals
within each module. That being the case, the unit tests in a module will run sequentially unless configured in surefire to run in parallel.