java - Maven Surefire : run a single unit test

标签 java maven maven-surefire-plugin unit-testing

我知道可以使用 -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/

相关文章:

java - 不使用日期的嵌入式文档索引

java - 使用 build.xml 通过 ANT 构建 AspectJ 应用程序

java - 添加aspectJ语言来定义连接点

java - Spring Boot SLF4J 错误

maven - 使用 native 库进行Surefire JUnit测试

JUnit 可选/必需测试

执行 jacoco 准备代理时,使用反射捕获的 Java 注释将不起作用

java - 有什么方法可以在tomcat中的不同应用程序之间共享 session 状态?

java - Netty编码器未执行

java - 深度优先搜索错误