线程 Maven 通过顺序单元测试构建?

发布于 2024-12-27 10:48:32 字数 389 浏览 3 评论 0原文

使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

离不开的别离 2025-01-03 10:48:33

我想你要找的可能是这里。这是关于 Surefire 如何分叉和/或运行并行线程的问题。

I think what you're looking for might be here. It's about how surefire forks and or runs parallel threads.

·深蓝 2025-01-03 10:48:32

据我了解并从 文档 中,并行构建并行运行模块,而不是每个模块内的目标。在这种情况下,模块中的单元测试将按顺序运行,除非在 Surefire 中配置为并行运行。

As far as I understand and from the documentation, parallel build runs modules in parallel and not the goals within each module. That being the case, the unit tests in a module will run sequentially unless configured in surefire to run in parallel.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文