I have written certain code which doesn't exactly have a main method. But I want to know if the code has any issues. Basically I can do it using the JUnit test case in Eclipse (I am using linux). But I am in a situation where I have to test it in Windows which currently doesn't have Eclipse. So I'm left with the option of doing it in cmd (if that is possible). What is the JUnit test (Eclipse) equivalent in cmd?
Asked
Active
Viewed 731 times
2
-
Note: you **definitely** don't want to do it in MS-DOS, unless you have some ancient floppy disks with that OS lying around. The command shell that you mean is **not** MS-DOS or DOS, even if it's command line looks very similar. – Joachim Sauer Sep 08 '11 at 10:40
-
2possible duplicate of [How to run Junit testcases from command line?](http://stackoverflow.com/questions/2235276/how-to-run-junit-testcases-from-command-line) – Joachim Sauer Sep 08 '11 at 10:41
1 Answers
2
Look at this page: http://junit.sourceforge.net/doc/faq/faq.htm#running_4
To run your JUnit tests, you'll need the following elemements in your CLASSPATH:
- JUnit class files
- Your class files, including your JUnit test classes
- Libraries your class files depend on
If attempting to run your tests results in a NoClassDefFoundError, then something is missing from your CLASSPATH.
Windows Example:
set CLASSPATH=%JUNIT_HOME%\junit.jar;c:\myproject\classes;c:\myproject\lib\something.jar
Invoke the runner:
java org.junit.runner.JUnitCore <test class name>