Maven Surefire:运行单个单元测试

Geo*_*old 4 java unit-testing maven maven-surefire-plugin

我知道可以运行特定的测试类-Dtest=MyTest.但是可以该类中运行特定测试吗?

即如果MyTest定义testFoo()testBar(),有没有办法指定只testfoo()应该运行?

我知道在IDE中执行此操作非常简单,但我偶尔需要在另一台服务器上的命令行上运行测试.

gun*_*mel 5

使用Maven Surefire插件运行单个测试

对于2.7.3版,您只能在一个测试类中运行n个测试.

注意:junit 4.x和TestNG支持它.

您必须使用以下语法

mvn -Dtest=TestCircle#mytest test

你也可以使用模式

mvn -Dtest=TestCircle#test* test