Skip to content

Instantly share code, notes, and snippets.

@ajuckel
Created October 27, 2013 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajuckel/7182384 to your computer and use it in GitHub Desktop.
Save ajuckel/7182384 to your computer and use it in GitHub Desktop.
JUnit from the command line
$ ls src
Simple.java SimpleTest.java
$ cat src/Simple.java
public class Simple {
public static int add(int x, int y) {
return x + y;
}
}
$ cat src/SimpleTest.java
import org.junit.Test;
public class SimpleTest {
@Test
public void adderTest() {
assert(Simple.add(1,2) == 3);
}
}
$ ls lib
hamcrest-core-1.3.jar junit-4.11.jar
$ javac -sourcepath src -d bin -cp lib/junit-4.11.jar:lib/hamcrest-core-1.3.jar $(find src -name '*.java')
$ ls bin
Simple.class SimpleTest.class
$ java -cp bin:lib/junit-4.11.jar:lib/hamcrest-core-1.3.jar org.junit.runner.JUn itCore SimpleTest
JUnit version 4.11
.
Time: 0.004
OK (1 test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment