maven :: 在多模块项目中仅运行单个测试 [英] maven :: run only single test in multi-module project

查看:23
本文介绍了maven :: 在多模块项目中仅运行单个测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么方法可以提供一些命令行参数来跳过所有测试,除了某个模块上的一个?所以我不需要在每次需要运行另一个测试时更改 pom.xml?

Is there any way to provide some command-line argument in order to skip all tests but one on some module? So I will not need to change pom.xml every time I will need to run another test?

例如,我想在 TeamCity 上创建构建配置,并提供命令行参数以在某个模块中仅运行单个测试.下次我需要更改它并运行另一个测试,等等.

For example, I want to create build configuration on TeamCity, and provide command-line arguments to run only single test in some module. Next time I will need to change it and run another test, and so on.

也许这不是 CI 的预期用途,但仍然如此.

Perhaps it is not how CI is intended to be used, but still.

推荐答案

我假设你已经阅读了关于 在万无一失的情况下运行单个测试?他们没有告诉你的是如何在子模块中做到这一点:

I assume you've read the docs about running a single test under surefire? What they don't tell you is how to do that in a sub-module:

mvn test -Dtest=testname -pl subproject

其中 subproject 是包含该测试的项目.从 mvn 手册页:

Where subproject is the project containing that test. From the mvn man page:

-pl,--projects arg 要构建的指定反应器项目的逗号分隔列表,而不是所有项目.项目可以通过 [groupId]:artifactId 或其相对路径指定.

-pl,--projects arg Comma-delimited list of specified reactor projects to build instead of all projects. A project can be specified by [groupId]:artifactId or by its relative path.

这篇关于maven :: 在多模块项目中仅运行单个测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆