Running JUnit tests from Terminal

user3469584

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

Gimby

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

JHipster & Gradle: Running Junit tests from STS

From Dev

Running AsyncHttpClient with JUNIT Tests

From Dev

Running AsyncHttpClient with JUNIT Tests

From Dev

Error when running JUnit Tests from DOS Command line

From Java

Maven not running JUnit 5 tests

From Dev

Silverstripe Tests from Terminal

From Dev

Gradle project running jUnit 5 tests in IntelliJ

From Dev

jenkins maven build not running JUnit tests

From Dev

Gradle project running jUnit 5 tests in IntelliJ

From Dev

Mavenising WebSphere/BPM tests and running via JUnit

From Dev

Refactoring JUnit rules from tests

From Dev

how to use junit from the terminal

From Dev

Running Android JUnit tests with Ant: ClassNotFoundException: org.junit.Test

From Dev

PHPUnit: Running tests from instances

From Dev

Running a python package from terminal

From Dev

Running tigris package from terminal

From Dev

Issue with running test from terminal

From Dev

Running programs in the background from terminal

From Dev

Running programs in the background from terminal

From Dev

Running java program from terminal

From Dev

running a python script from the terminal

From Dev

Script running from terminal but not in crontab

From Dev

Running a meteor server from terminal

From Dev

Running GUI app from terminal

From Dev

How to run JMH from inside JUnit tests?

From Dev

Getting list of tests from JUnit command line

From Dev

Maven running tests annotated with junit @Ignore when building Java project

From Dev

Define variable before all JUnit Tests start running?

From Dev

"Address already in use: bind" exception when running Gradle JUnit tests