apache / apache/maven-surefire

[SUREFIRE-1949] Unable to determine lifecycle method name in JUnit Jupiter beforeAll failure

Open
#2,897 3 comments 0 reactions 0 assignees View on GitHub
bug priority:minor
Dominant language
Java
Stars
461
Forks
588
Avg merge
1d 8h
Merged PRs (30d)
19

Description

**[Dave Nicholas](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=dnicholas)** opened **[SUREFIRE-1949](https://issues.apache.org/jira/browse/SUREFIRE-1949?redirect=false)** and commented

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

 

```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() {
}

}

```

 

The maven surefire XML file will have below content:

```java

Contributor guide

Open the contributing guide

Research direction

Start with the provided JUnit Jupiter @BeforeAll reproduction and inspect how the surefire-report XML testcase element is produced. Confirm the failure currently emits an empty name while retaining the classname. Done when the lifecycle method name is represented and a regression test covers the beforeAll failure case.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.