import org.junit.runner.JUnitCore;import org.junit.runner.Result;import org.junit.runner.notification.Failure; /** * Created by Divakar on 2/16/2017. */public class BeforeAfterClassAnnotation { public static void main(String[] args) { Result result = JUnitCore.runClasses( BeforeAfterClassAnnotationTest.class ); for(Failure failure : result.getFailures()) { System.out.println( failure.toString() ); } System.out.println( result.wasSuccessful() ); } }
import org.junit.AfterClass;import org.junit.BeforeClass;import org.junit.Test; import static org.junit.Assert.assertEquals; /** * Created by Divakar on 2/16/2017. */public class BeforeAfterClassAnnotationTest { @BeforeClass public static void val1() { System.out.println( "Called '@BeforeClass' annotation method" ); } @Test public void valueEquality() { String country = "India"; assertEquals("India", country); } @AfterClass public static void val2() { System.out.println( "Called '@AfterClass' annotation method" ); } }
22
No comments:
Post a Comment