How to run my JUnit tests that I built in Eclipse from command line [message #1728189] |
Thu, 31 March 2016 14:32  |
Eclipse User |
|
|
|
Hi,
I'm a newbie to JUnit. I have created some tests inside of eclipse and using "Run as" inside of eclipse to execute my tests.
I want to know how can I run these same tests from a command line?
Example, what are all the steps necessary?
I have set my environment variables (e.g. JAVA_HOME and JUNIT_HOME) and also added them to the classpath as well.
What else do I need to do, do I need to add the location of my bin project folder containing the .class files to the classpath or anywhere?
I tried to run the following commands:
1)
java -classpath C:\JUnit\junit-4.12.jar;C:\Users\tarik.abdallah\workspace\RentalManTests\bin\com\wynnesystems\rentalman\tests; org.junit.runner.JUnitCore OperationScreenTests
Got this error:
Exception in thread "main" java.lang.NoClassDefFoundError: OperationScreenTests (wrong name: com/wynnesystems/rentalman/tests/OperationScreenTests)
2)
c:\JUnit>java -classpath C:\JUnit\junit-4.12.jar org.junit.runner.JUnitCore OperationScreenTests
Got this error:
There was 1 failure:
1) initializationError(org.junit.runner.JUnitCommandLineParseResult)
java.lang.IllegalArgumentException: Could not find class [OperationScreenTests]
at org.junit.runner.JUnitCommandLineParseResult.parseParameters(JUnitCommandLineParseResult.java:102)
at org.junit.runner.JUnitCommandLineParseResult.parseArgs(JUnitCommandLineParseResult.java:50)
at org.junit.runner.JUnitCommandLineParseResult.parse(JUnitCommandLineParseResult.java:44)
at org.junit.runner.JUnitCore.runMain(JUnitCore.java:72)
at org.junit.runner.JUnitCore.main(JUnitCore.java:36)
Caused by: java.lang.ClassNotFoundException: OperationScreenTests
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.junit.internal.Classes.getClass(Classes.java:16)
at org.junit.runner.JUnitCommandLineParseResult.parseParameters(JUnitCommandLineParseResult.java:100)
... 4 more
I tried many things but have not had any luck... This should really be easy to do -(
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.11475 seconds