concept test suite in category java

appears as: test suite, test suite, test suites, A test suite
JUnit in Action, Second Edition

This is an excerpt from Manning's book JUnit in Action, Second Edition.

Suite (or test suite)—A group of tests. A test suite is a convenient way to group together tests that are related. For example, if you don’t define a test suite for a test class, JUnit automatically provides a test suite that includes all tests found in the test class (more on that later). A suite usually groups test classes from the same package.

Runner (or test runner)—A runner of test suites. JUnit provides various runners to execute your tests. We cover these runners later in this chapter and show you how to write your own test runners.

In order to test the form and check that the message is what we expect it to be, we use the same JUnit scaffolding from the previous chapter and first set up a test suite to manage the Selenium server:

[...]
@RunWith(ManagedSeleniumServerSuite.class)
@SuiteClasses( { UnmanagedFormTester.class })
public class ManagedFormTest {
// See annotations.
}

This code shows the test suite ManagedFormTest that runs the test case UnmanagedFormTester containing the @Test methods. The JUnit test runner ManagedSeleniumServerSuite manages the Selenium server and drives the unit test.

As in JUnit, you can group JsUnit tests into a suite of related tests. Listing 13.6 wraps our previous test page into a test suite.

Listing 13.6. jsUnitTestSuite.html

To define a test suite, create a function called suite , which returns a JsUnitTestSuite object. You then build up a suite object by adding test pages or other suite objects. In our example, we add one page , the page we previously defined by calling the addTestPage function. The rest of the code in this HTML page is the same as our previous example with the exception that we don’t need to refer to our JavaScript factorial library.

13.8.6. Creating a test suite

The benefit of using a test suite with GWT goes beyond grouping related tests together. A performance gain is possible by using a GWT test suite. GWT sorts test cases in a suite by module name as returned by getModuleName. This causes all tests with the same module name to run one after the other.

To create a test suite, you can start with the Eclipse JUnit Test Suite Wizard. For example, to create a test suite that includes all test cases in a package, go to the Packages view, right-click a package, and choose New and then Other. In the New dialog box, open the JUnit node and choose JUnit Test Suite. Listing 13.16 shows the generated code with two changes we explain next.

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