Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-2115

Unable to execute specific inner class test in Surefire

    XMLWordPrintableJSON

Details

    Description

      Hi I have a nested class hierarchy which is as follows:

      public class NestClassContainer {
      
          @Test
          public static class TestClass1 {
      
              public void testC1_m1() {
                  System.out.println("Should not execute");
              }
          }
      
          @Test
          public static class TestClass2 {
      
              public void testC2_m1() {
                  System.out.println("Should execute");
              }
          }
      
      }

      I want to use Surefire to only execute NestClassContainer$TestClass2, This works just fine in TestNG exeution, but I cannot get it to work in Surefire.

      When I try to execute one of the nested classes TestClass2 , it executes all the tests in the top class. (Tested versions 2.22.1 & 3.0.0-M7)

      Here is my commandline:

      mvn clean test -Dtest=NestClassContainer$TestClass2 

      Expected outcome:

      We execute only testC2_m1

      Actual outcome:

      Both testC1_m1 & testC2_m1 are executed.

      I have even tries setting the annotations on the test methods instead, but the result is the same.

      Attachments

        Activity

          People

            Unassigned Unassigned
            baubakg Baubak Gandomi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: