'How to run one test inside a nested class with 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?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source