Chapter 4. Managing test suites

 

This chapter covers

  • Manually collecting tests into custom test suites
  • Automatically collecting tests into different kinds of test suites
  • Ordering and filtering tests in test suites
  • Using Parameterized Test Cases to build a data-driven test suite

In JUnit, the smallest unit of “test execution” is the test suite. JUnit doesn’t actually execute individual tests, but only executes test suites, so in order to execute your tests, you need to collect them into a test suite. The recipes in this chapter describe different ways to create and manage test suites.

The simplest test suite to create consists of all the tests in a test case class. This is so simple that JUnit does it for you. See recipe 4.1, “Let JUnit build your test suite.” If you need to create your test suites by hand, go to recipe 4.2, “Collect a specific set of tests.” If you have data-driven tests and don’t want to write by hand a bunch of test methods that simply use your test data, see recipe 4.8, “Build a data-driven test suite.” After that you’ll probably want to move your test data outside the code. For that, see recipe 4.9, “Define a test suite in XML.”

4.1. Let JUnit build your test suite

 
 

4.2. Collect a specific set of tests

 

4.3. Collect all the tests in a package

 

4.4. Collect all the tests for your entire system

 
 
 

4.5. Scan the file system for tests

 
 

4.6. Separate the different kinds of test suites

 
 

4.7. Control the order of some of your tests

 
 
 
 

4.8. Build a data-driven test suite

 

4.9. Define a test suite in XML

 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest