-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Overview
While migrating the Spring Framework test suite from JUnit 4 and Hamcrest to JUnit Jupiter and AssertJ, entire projects in Spring's test suite started reporting zero tests after removing the dependency on Hamcrest even though the tests no longer used Hamcrest. Adding Hamcrest back as a test runtime dependency allowed the tests to execute again.
Analysis
Thanks to some investigative work by @marcphilipp, we came to the following conclusion.
The JupiterTestEngine fails with a NoClassDefFoundError if JUnit 4 is on the classpath but Hamcrest is not. The underlying reason is that OpenTest4JAndJUnit4AwareThrowableCollector has a static initialization block that checks if the org.junit.internal.AssumptionViolatedException class can be loaded. However, since AssumptionViolatedException has a direct dependency on org.hamcrest.Matcher, a NoClassDefFoundError is thrown when attempting to load AssumptionViolatedException.
Deliverables
- Refactor
OpenTest4JAndJUnit4AwareThrowableCollectorso that a failed attempt to detect the presence ofAssumptionViolatedExceptionin the classpath does not crash the entireJupiterTestEngine. - Document in the Release Notes.