Issue
I'm working in a project that is new to me, but has been around for a while.
I try running the unit tests from the terminal with mvn clean test
and the unit tests run as expected.
Unfortunately for me, I really could use some debugging help from IntelliJ on some of these unit tests. Any time I try to run a unit test from IntelliJ, I get this output:
Internal Error occurred.
org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-vintage' failed to discover tests
Caused by: org.junit.platform.commons.JUnitException: Unsupported version of junit:junit: 3.8.1. Please upgrade to version 4.12 or later.
According to pom.xml, I'm using JUnit 5.7.0, Mockito 3.7.7, and (since some results I've googled suggest it could be a Spring Boot issue) no sign of Spring Boot. I've also tried including junit-vintage, since it is mentioned in the output, but that seems to make no difference, either.
Solution
It's the old StackOverflow curse -- search for a solution for hours and hours, get nowhere; post on StackOverflow, even helpful people don't know what the issue is, but now I can find the answer from Google in a snap.
Despite my having added junit-vintage to my project previously, apparently I was not adding the correct artifact, or version, or something. Because that's the solution here.
Here is a link to the discussion that led me to the answer -- add this dependency:
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
Answered By - REW
Answer Checked By - Pedro (JavaFixing Volunteer)