I want to run a java program which is basically a Integration test class from command line using a jar file I created from intellij post build. But i am unable to since it throws classNotFoundException. Are test classes even included in the jar file when a jar is created? Do I need to create a new standalone jar file which has my test program as the main class to run it from command line?

Tried: java -cp myJArNAme.jar /test/java/package.name.myITTestClass.java Gave: Error: Could not find or load main class ,Caused by: java.lang.ClassNotFoundException.

Do jar files even include test classes? If no, Do i need to create new jar file which has my test class as a main class and then run it from command line?

1

There are 1 answers

0
userdr725 On

I got it, normally a jar file does not include test-classes, to do so u need to create a new jar file Follow the link: https://maven.apache.org/plugins/maven-jar-plugin/examples/create-test-jar.html