Jimmy T.
Jimmy T.

Reputation: 4190

Getting JAR list in JUnit test

Is it possible to get a list of the JAR files in a JUnit test?

I want to read the MANIFEST.MF but when I try to get the JARs via ClassLoaders (which works in normal execution) I only get one file surefirebooter<somenumbers>.jar

This isn't test specific code but code I want to test in the JUnit test.

Upvotes: 0

Views: 141

Answers (1)

Roland Weisleder
Roland Weisleder

Reputation: 10501

The system property java.class.path contains all classpath elements, JARs and directories. See https://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html

It also works while executing code with the maven-surefire-plugin.

Upvotes: 1

Related Questions