Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
342 views
in Technique[技术] by (71.8m points)

java - JUnit is fine via command line, fails in IntelliJ

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.

question from:https://stackoverflow.com/questions/66055656/junit-is-fine-via-command-line-fails-in-intellij

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Can you try to add

<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.13.1</version>
</dependency>

to your pom.xml. Maybe you have junit only as a transitive dependency and therefore 3.8.1 is chosen.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...