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

Unable to determine lifecycle method name in JUnit Jupiter beforeAll failure

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.0.0-M5
    • None
    • JUnit 5.x support
    • None

    Description

      When a @BeforeAll method fails in a JUnit Jupiter lifecycle method, the surefire-report XML file has an empty value for the testname XML attribute. Although the classname attribute is fully populated, we do not know if this lifecycle error was a result of beforeEach or beforeAll.

       

      Here is sample code to reproduce the issue

       

      import org.junit.jupiter.api.BeforeAll;
      import org.junit.jupiter.api.Test;
      import org.junit.jupiter.api.TestInstance;
      
      import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
      
      @TestInstance(PER_CLASS)
      public class MyFirstTest {
      
        @BeforeAll
        public void setUp() {
            throw new RuntimeException("Exception in JUnit configuration method");
        }
      
        @Test
        public void myFirstTest() {
        }
      
      }
      
      
      

       

      The maven surefire XML file will have below content:

      <testcase name="" classname="com.something.MyFirstTest"

      Any help would be greatly appreciated.

       

      Thanks

      Attachments

        Activity

          People

            Unassigned Unassigned
            dnicholas Dave Nicholas
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: