且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 maven 运行单个测试方法

更新时间:2023-01-11 16:29:31

在Maven中运行单个测试方法,需要提供如下命令:

To run a single test method in Maven, you need to provide the command as:

mvn test -Dtest=TestCircle#xyz test

其中 TestCircle 是测试类名,xyz 是测试方法.

where TestCircle is the test class name and xyz is the test method.

通配符也可以使用;在方法名和类名中.

Wild card characters also work; both in the method name and class name.

如果您在多模块项目中进行测试,请使用 -pl 指定测试所在的模块.

If you're testing in a multi-module project, specify the module that the test is in with -pl <module-name>.

对于集成测试,使用 it.test=... 选项而不是 test=...:

For integration tests use it.test=... option instead of test=...:

mvn -pl <module-name> -Dit.test=TestCircle#xyz integration-test