Skip to content

Instantly share code, notes, and snippets.

@vaskoz
Created June 24, 2015 00:42
Show Gist options
  • Save vaskoz/3c784a01701fa19b8cfd to your computer and use it in GitHub Desktop.
Save vaskoz/3c784a01701fa19b8cfd to your computer and use it in GitHub Desktop.
Run JUnit tests programmatically
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class ProgrammaticJUnit {
@Test public void test1() {
assertEquals(3, 1+2);
}
@Test public void test2() {
assertEquals(8, 3*3); // INTENTIONAL FAIL
}
@Test public void test3() {
System.out.println("Just wanted to print here");
}
public static void main(String[] args) {
org.junit.runner.JUnitCore.main("ProgrammaticJUnit");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment