If you have several test classes, you can combine them into a test suite . Running a test suite executes all test classes in that suite in the specified order. A test suite can also contain other test suites. Using Suite as a runner allows you to manually build a suite containing tests from many classes. To use it, annotate a class with @RunWith (Suite.class) and @SuiteClasses(TestClass1.class).
- [Instructor] So far, many of the examples that I've shown…have been very simple,…including just one class, one unit test.…But if you have several test classes…you can combine them and run them all at once,…by combining them into a test suite.…Running a test suite execute all test classes in that suite…in the specified order.…A test suite can also contain other test suites.…I have an example here in NetBeans,…where I've created a program to test…more than one class.…
As you can see on the left,…in the test packages under the test suite package,…I have two Java files,…Suite Test 1 and Suite Test 2,…and then I have my TestSuiteTest.java file.…Lets look at that first.…On line 18, you'll see we have the @runwith annotation,…which tells the compiler…that we're going to use the Suite.class.…Below that, we have the @Suite.SuiteClasses…which is were we can include…one or more classes that we want to test…in the order in which they should be tested.…
In this case I'm just testing those two programs,…Test 1 and Test 2.…When you run this class, it will run all the tests…
- What is JUnit?
- Comparing values with assertions
- Using JUnit with different Java IDEs
- Creating basic unit tests
- Testing for exception handling
- Creating parameterized tests