JUnit from the command line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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