I have some JUnit tests that are running in IntelliJ just fine. However, I need to run these same tests from the terminal. My problem is, no matter what I do, I get an error that says:
JUnit version 4.10
Could not find class: com.myCompany.MyTests
I do not know why it is not working. In an attempt to run the unit tests from the command-line, I'm running the following:
java -cp /Applications/IntelliJ\ IDEA\ 13.app/lib/junit-4.10.jar org.junit.runner.JUnitCore com.myCompany.MyTests
However, the only thing I see is the error listed above. I keep running this command up and down my source directory. Yet, no matter what I can't get any tests to run from the command-line. Yet, they run just fine from within IntelliJ. How do I get my tests to run from the command-line in the same way that they run from within IntelliJ? Is there some way I can view the actual command(s) that IntelliJ runs when running JUnit?
Thank you
Somewhere there is a directory or jar that holds that 'com' directory that is the root of your application's package structure (com/myCompany). That directory or jar needs to be added to the classpath through the -cp flag you are already using.
So say as an example that the class is in:
/workspaces/myproject/bin/com/myCompany/MyTests.class
then you need to add the /workspaces/myproject/bin directory to the classpath.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments