我知道可以使用 -Dtest=MyTest
运行特定的测试类。但是是否可以在该类中运行特定测试?
即如果 MyTest
定义了 testFoo()
和 testBar()
,有没有办法指定只有 testfoo()
应该运行?
我知道在 IDE 中执行此操作非常简单,但我偶尔需要在另一台服务器上的命令行上运行测试。
最佳答案
来自 Running a Single Test Using Maven Surefire Plugin
With version 2.7.3, you can run only n tests in a single Test Class.
NOTE : it's supported for junit 4.x and TestNG.
You must use the following syntax
mvn -Dtest=TestCircle#mytest test
You can use patterns too
mvn -Dtest=TestCircle#test* test
关于java - Maven Surefire : run a single unit test,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5148793/