Hey all, I encountered a project using the @Nested annotation for test classes;

class ProjectTests {
        @Nested
        class HappyPath {
                @Test
                void test_this_happy() {
                        System.out.println(“Happiness);
                }
        }
        @Nested
        class SadPath {
                @Test
                void test_this_sad() {
                        System.out.println(“Sadness);
                }
        }
}

I was attempting to debug one of the nested tests and noted that nothing is 
executed. I have the surefire config;

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude/>
                    </excludes>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.junit.jupiter</groupId>
                        <artifactId>junit-jupiter-engine</artifactId>
                        <version>${junit.jupiter.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            
NetBeans is executing;
        mvn 
-Dtest=com.cerner.ukdev.mars.dataaccess.ProjectTests#test_this_happy 
-Pdevelopment process-test-classes surefire:test
        
This means the test is not found. On the command line I can run;
        mvn 
-Dtest=com.cerner.ukdev.mars.dataaccess.ProjectTests\$HappyPath#test_this_happy 
-Pdevelopment process-test-classes surefire:test
        
I saw this PR[1] from some time ago but it looks to have been abandoned. Was 
there any other work on this or should I have a look at getting this working? 
From a surefire pov it looks to simply be a case of class scanning for the 
nested annotation and ensuring the inner class is inserted into the command?

Thoughts welcome.
Chris

[1]: https://github.com/apache/netbeans/pull/1069

Reply via email to