[ https://issues.apache.org/jira/browse/SUREFIRE-1949?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17477557#comment-17477557 ]
Albert Johnston edited comment on SUREFIRE-1949 at 1/18/22, 4:08 AM: --------------------------------------------------------------------- [~dnicholas] I'm not super familiar with JUnit/Surefire's inner workings/intended functionality beyond the (IMO) small amount of work I've done in the past on it, but just as an educated guess, I would think that {code:java} <testcase name="" classname="com.something.MyFirstTest"{code} actually makes sense for @BeforeAll because @BeforeAll doesn't actually run before a specific test case. It runs a single time before any of them run, so the testcase name doesn't actually make as much sense contextually. Compare this to @BeforeEach, which does set the value for the testcase name, because it is actually running a specific test at the time. Just my thoughts, but again, I'm not an expert. was (Author: ajohnston): [~dnicholas] I'm not super familiar with JUnit/Surefire's inner workings/intended functionality beyond the (IMO) small amount of work I've done in the past on it, but just as an educated guess, I would think that <testcase name="" classname="com.something.MyFirstTest" actually makes sense for @BeforeAll because @BeforeAll doesn't actually run before a specific test case. It runs a single time before any of them run, so the testcase name doesn't actually make as much sense contextually. Compare this to @BeforeEach, which does set the value for the testcase name, because it is actually running a specific test at the time. Just my thoughts, but again, I'm not an expert. > Unable to determine lifecycle method name in JUnit Jupiter beforeAll failure > ---------------------------------------------------------------------------- > > Key: SUREFIRE-1949 > URL: https://issues.apache.org/jira/browse/SUREFIRE-1949 > Project: Maven Surefire > Issue Type: Bug > Components: JUnit 5.x support > Affects Versions: 3.0.0-M5 > Reporter: Dave Nicholas > Priority: Minor > > 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 > > {code:java} > 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() { > } > } > {code} > > The maven surefire XML file will have below content: > {code:java} > <testcase name="" classname="com.something.MyFirstTest"{code} > Any help would be greatly appreciated. > > Thanks -- This message was sent by Atlassian Jira (v8.20.1#820001)