JUnit 4 Tutorial 5 – Suite Test
Published: May 21, 2009 , Updated: April 1, 2010 , Author: mkyong
The “Suite Test” 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.
The below example means both unit test JunitTest1 and JunitTest2 will run together after JunitTest5 is executed.
import org.junit.runner.RunWith; import org.junit.runners.Suite; /** * JUnit Suite Test * @author mkyong * */ @RunWith(Suite.class) @Suite.SuiteClasses({ JunitTest1.class, JunitTest2.class }) public class JunitTest5 { }
Result
@BeforeClass - oneTimeSetUp @Before - setUp @Test - testEmptyCollection @After - tearDown @Before - setUp @Test - testOneItemCollection @After - tearDown @AfterClass - oneTimeTearDown
P.S Result is from JunitTest1 and JunitTest2 unit test
Any Java questions or problems? please post at this JavaNullPointer.com forum, see you there ~
Nice article, depicting the topics effectively.
keep up the work.
rastogi
Consultants available for Software testing, Test Management requirements. reach us at Testing-Associates
[...] Tutorial 5 – Suite Test Bundle a few unit test cases and run it together. [...]