Thursday, 16 February 2017

BeforeAfterAnnotation


import org.junit.runner.JUnitCore;import org.junit.runner.Result;import org.junit.runner.notification.Failure;

public class BeforeAfterAnnotation {

    public static void main(String[] args)
    {

        Result result = JUnitCore.runClasses( BeforeAfterAnnotationTest.class );
        for(Failure failure : result.getFailures())
        {
            System.out.println( failure.toString() );        }

        System.out.println( result.wasSuccessful() );    }
}


import org.junit.*;
import static org.junit.Assert.assertEquals;
/** * Created by Divakar on 2/16/2017. */public class BeforeAfterAnnotationTest {

    @Before    public void val1()
    {
        System.out.println( "Called @Before annotation method" );    }

    @Test    public  void valueEquality()
    {
        String country = "India";        assertEquals("India", country);    }
    @After    public void val2()
    {
        System.out.println( "Called @After annotation method" );    }


}




22

No comments:

Post a Comment