Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run one test inside a nested class with maven?

Tags:

junit

maven

JUnit Example code:

class OuterClass {

   @Nested
   class InnerClass {

      @Test
      void test() {
      }
   }
}

This command: mvn test -Dtest=OuterClass* runs all tests in the OuterClass.

This command: mvn test -Dtest=OuterClass$InnerClass* runs all tests in the InnerClass.

This command: mvn test -Dtest=OuterClass$InnerClass#test runs no tests. How can I run only this test method?

like image 899
Shaimaa Sabry Avatar asked Oct 25 '25 04:10

Shaimaa Sabry


1 Answers

use quotes:

mvn test -Dtest='OuterClass$InnerClass#test'
like image 116
reg Avatar answered Oct 28 '25 02:10

reg