when using maven in CLI, we can run only one test with:
mvn test -Dtest="ExampleTestClass#exampleTestMethod
I was wondering if it is possible to execute a single test based on its displayName
, like so:
@Test
@DisplayName("hello")
public void exampleTestMethod() {
}
mvn test -Dtest="ExampleTestClass#hello"
??
By default, this doesn't execute any test, but perhaps with some configuring?
CodePudding user response:
No, that's not possible (unless you implement it yourself, as it is open source). Keep in mind that surefire is testframework agnostic: they all understand classes and methods. The -Dtest
is used by all testframeworks, while the displayName annotation is JUnit specific.