0
votes

TLDR: I'm new to the Java world. How do I know what .jar files to include in my JUnit directory without receiving errors while running my tests?

So I'm completing a class project have been using the same JUnit5 jars that are found at https://search.maven.org/search?q=g:org.junit.jupiter%20AND%20v:5.7.0 to run my tests. I was recieving an odd error when running some my tests and decided to use the tool that comes with IntelliJ to "add 'JUnit5.4' to the classpath" to see what .jars where pulled in to make it all work. I found that there were a couple discrepancies with what was pulled in using Maven and what existed in the JUnit directory I had been using.

These are the .jars that I had been using:

  • junit-jupiter-5.7.0.jar
  • junit-jupiter-api-5.7.0.jar
  • junit-jupiter-engine-5.7.0.jar
  • junit-jupiter-migrationsupport-5.7.0.jar
  • junit-jupiter-params-5.7.0.jar

This is what was included when I added JUnit5.4 using IntelliJ:

  • apiguardian-api-1.0.0.jar
  • junit-jupiter-5.4.2.jar
  • junit-jupiter-api-5.4.2.jar
  • junit-jupiter-engine-5.4.2.jar
  • junit-jupiter-params-5.4.2.jar
  • junit-platform-commons-1.4.2.jar
  • junit-platform-engine-1.4.2.jar
  • opentest4j-1.1.1.jar

Investigating a little further I found that JUnit5 is made up of three "sub-projects" (Jupiter, Vintage, and Platform) but all of these .jar files are not included when I add JUnit through IntelliJ.

  1. Why are there so many files on the JUnit website that aren't included when I add JUnit using IntelliJ?
  2. There are files that aren't on the JUnit website that are included when I add through IntelliJ (apiguardian-api-1.0.0.jar and opentest4j-1.1.1.jar). Whats up with that?
  3. How does IntelliJ determine which .jar files are needed when adding to the classpath? Is it always the same files or will only necessary files be included?

Like I said earlier I'm new to the Java world so hopefully I'm wording everything correctly.

1
What is not working?Jim Garrison

1 Answers

0
votes

IntelliJ IDEA will add the dependencies depending on the test you are trying to generate. Not all the parts of Junit are needed to be added in case you have i.e only Junit 5 tests. vintage-engine will be added in case you need to run Junit 4 tests. Please read about why the opentest4j is needed here: https://github.com/ota4j-team/opentest4j and about the apiguardian here: https://junit.org/junit5/docs/5.1.0-RC1/release-notes/