12:48 pm - Saturday July 22, 2017

JUNIT Test Suit

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

Test suite

Test suite means bundle a few unit test cases and run it together.

In Junit both @RunWith and @Suite annotation are used to run the suite test.

Example:

1.)import org.junit.*;
   import static org.junit.Assert.*;
   import java.util.*;

public class Ju { }

@AfterClass

public static void tearDownclass() {

System.out.println("Am  AfterClass ");

     @Before

public void setUp() {

     @After

         collection.clear();
     	System.out.println("Am After ");

         assertEquals(1, collection.size());
         System.out.println(" Am Test ");
     }

}

2.) import org.junit.*;

public class Jun {

@Test(expected = ArithmeticException.class)

public void divisionWithException() {

}

}

Note:First run 1&2 program

3.)import org.junit.runner.RunWith;
   import org.junit.runners.Suite;

@RunWith(Suite.class)

@Suite.SuiteClasses({

        Ju.class,
        Jun.class

})

public class Junittest {

}

Output

Am BeforeClass

Am Before

Am Test

Am After

Am AfterClass

BACK

Filed in: Z-A All Java Codes

Comments are closed.