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 
  1. you should add . (the current directory) classpath
  2. 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:

  1. download junit-4.11.jar:hamcrest-core-1.3.jar junit site.
  2. 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);     } } 
  1. javac -cp junit-4.11.jar testcase.java
  2. 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

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -