Tuesday, 8 January 2013

Creating test suites with Junit4

Creating test suites with Junit4

Test Suite can be created in JUnit 4 as

import org.junit.runners.Suite;

@RunWith(Suite.class)
@Suite.SuiteClasses({TestClass1.class, TestClass2.class})
public class TestSuite {
//nothing
}

The @RunWith(Suite.class) gives opportunity to combine both JUnit 4 and JUnit 3 tests and test cases together:


@RunWith(Suite.class)
@Suite.SuiteClasses({
 ExampleOfJunit3TestSuite.class,
 ExampleOfJUnit3TestCase.class,
 ExampleOfJUnit4TestSuite.class,
 ExampleOfJUnit4TestCase.class})
public class BothJUnit4and3TestSuite {
}

No comments:

Post a Comment