eclipse-ee4j / eclipse-ee4j/jersey
JerseyTest is not compatible with JUnit 5
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
When using JerseyTest with JUnit 5 a null pointer exception gets thrown:
```
java.lang.NullPointerException
at org.glassfish.jersey.test.JerseyTest.target(JerseyTest.java:564)
at org.glassfish.jersey.test.JerseyTest.target(JerseyTest.java:578)
```
The issue seems to be that the setup() and tearDown() functions in the JerseyTest class are not called in JUnit 5 as they would be in JUnit 4. JUnit 5 uses the convention of @Before and @After annotations.
Here is my workaround, in the test class that extends JerseyTest add the following two methods:
```java
// do not name this setup()
@BeforeAll
public void before() throws Exception {
super.setUp();
}
// do not name this tearDown()
@AfterAll
public void after() throws Exception {
super.tearDown();
}
Contributor guide
Assessment
This issue has not been assessed yet.