java - Working only with gedit/vim. How to run JUnit class via command line -
i working on linux mint 14. installed junit , verified on path. in home folder have class named testclass.class , in have defined test methods. when try run program following error:
lazarevsky@linuxbox ~ $ java -cp /usr/share/java/junit.jar junit.textui.testrunner testclass.class class not found "testclass.class"
how proceed? doing wrong? note not using full-blown ide text editor.
you should use
java -cp .:/usr/share/java/junit.jar junit.textui.testrunner testclass
- you should add . (the current directory) classpath
- you should use class name testclass not testclass.class
edit
first, should read doc of junit. there lot of manuals. https://github.com/junit-team/junit/wiki
if use junit4, can start this:
- download junit-4.11.jar:hamcrest-core-1.3.jar junit site.
- create testcase.java file this:
import org.junit.test; import org.junit.runner.runwith; import org.junit.runners.junit4; @runwith(junit4.class) public class testcase { @test public void testa(){ org.junit.assert.asserttrue(true); } }
- javac -cp junit-4.11.jar testcase.java
- java -cp .:junit-4.11.jar:hamcrest-core-1.3.jar org.junit.runner.junitcore testcase
then can find test results this:
junit version 4.11 . time: 0.006 ok (1 test)
Comments
Post a Comment