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

查看:205
本文介绍了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天全站免登陆