This file contains hidden or 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
import org.junit.runner.JUnitCore; | |
import org.junit.runner.Result; | |
import org.junit.runner.notification.Failure; | |
public class TestRunner { | |
public static void main(String[] args) { | |
Result result = JUnitCore.runClasses(FirstTest.class, SecondTest.class); | |
for (Failure failure : result.getFailures()) { | |
System.out.println(failure.toString()); | |
} | |
System.out.println(result.wasSuccessful()); | |
} | |
} | |
//First test class | |
import static org.junit.Assert.assertTrue; | |
import org.junit.Test; | |
public class FirstTest { | |
@Test | |
public void equal() { | |
assertTrue(true); | |
System.out.println("First test ===>PASSSED"); | |
} | |
} | |
//Second test class | |
import static org.junit.Assert.assertFalse; | |
import org.junit.Test; | |
public class SecondTest { | |
@Test | |
public void add() { | |
assertFalse("This is failed by me",true); | |
System.out.println("Second test ===> PASSSED"); | |
} | |
} | |
//you can run this by @RunWith(Suit.class) Annotaotions @Suit.SuitClass like below as well | |
import org.junit.runner.RunWith; | |
import org.junit.runners.Suite; | |
@RunWith(Suite.class) | |
@Suite.SuiteClasses({ | |
FirstTest.class, SecondTest.class | |
}) | |
public class JunitTestSuit { | |
} | |