Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I tell which specific version of JUnit IntelliJ is using?

I've started working on a large project where the IntelliJ environment has already been set up. The environment includes JUnit, and I can successfully run unit tests. I've seen screens where I can specify the usage of JUnit 3 or JUnit 4, but how can I determine which specific JUnit is being used to run my tests, e.g., JUnit 4.11?

I have already tried "Open Module Settings". When I look at the "Dependencies" tab, I don't see anything relating to JUnit, although I can run JUnit tests.

like image 481
kc2001 Avatar asked Feb 07 '13 12:02

kc2001


People also ask

How do I find my JUnit version?

Go to the project properties --> java build path --> in libraries tab you will see the junit jar. see the version on it.

How do I change JUnit 4 to JUnit 5 in IntelliJ?

Use Find Action with ⌘⇧A (macOS), or Ctrl+Shift+A (Windows/Linux), and type Migrate, to see migration options for the code. IntelliJ IDEA offers the option to migrate the code from JUnit 4 to 5. This migration is similar to what we did with the individual test class, but for all test classes.

Does IntelliJ support JUnit 5?

IntelliJ IDEA supports the ability to actually run tests written for JUnit 5 – there's no need to use the additional libraries (like the Gradle or Maven plugins for example), all you need is to include the JUnit 5 dependency.


1 Answers

Which jar is used?

When you run JUnit from IntelliJ, the very first line of the console output displays your classpath. You can use Ctrl+F to find any "junit" references.

junit-rt.jar is a helper library that JetBrains might have written. By opening the jar as an archive with 7-zip, you will find that the only package inside it is under com.intellij

According to Java: Which of multiple resources on classpath JVM takes? the first reference to junit.jar is the one you will use.


What version is that jar?

Once you know which jar is being used, there are a number of ways to find the version. One is to use this code taken from https://stackoverflow.com/a/16729507/1405720

import junit.runner.Version;

System.out.println("JUnit version is: " + Version.id());

Another method might be to open up the jar as an archive and see if you can figure it out from there.

like image 187
mejdev Avatar answered Sep 19 '22 04:09

mejdev