1.1. What is Programmer Testing?
1.1.1. The goal of Object Testing
1.1.2. The rhythm of an Object Test
1.2. Getting started with JUnit
1.2.1. Downloading and installing JUnit
1.2.3. Understanding the TestCase class
2.2. Test a method that returns nothing
2.8. Test throwing the right exception
2.9. Let collections compare themselves
2.10. Test a big object for equality
2.11. Test an object that instantiates other objects
Chapter 3. Organizing and building JUnit tests
3.1. Place test classes in the same package as production code
3.2. Create a separate source tree for test code
3.3. Separate test packages from production code packages
3.4. Factor out a test fixture
3.5. Factor out a test fixture hierarchy
3.6. Introduce a Base Test Case
3.7. Move special case tests to a separate test fixture
3.8. Build tests from the command line
3.10. Build tests using Eclipse
Chapter 4. Managing test suites
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
Chapter 5. Working with test data
5.1. Use Java system properties
5.2. Use environment variables
5.6. Use a file-based test data repository
5.7. Use XML to describe test data
5.8. Use Ant’s <sql> task to work with a database
5.10. Set up your fixture once for the entire suite
5.11. Perform environment setup once for multiple test runs
Chapter 6. Running JUnit tests
6.1. See the name of each test as it executes
6.2. See the name of each test as it executes with a text-based test runner
6.4. Execute each test in its own JVM
6.5. Reload classes before each test
Chapter 7. Reporting JUnit results
7.1. Using a Base Test Case with a logger
7.3. Getting plain text results with Ant
7.4. Reporting results in HTML with Ant’s <junitreport> task
7.5. Customizing <junit> XML reports with XSLT
7.6. Extending Ant’s JUnit results format
7.7. Implementing TestListener and extending TestRunner
7.8. Reporting a count of assertions
Chapter 8. Troubleshooting JUnit
A problem with the CLASSPATH environment variable
8.1. JUnit cannot find your tests
8.2. JUnit does not execute your custom test suite
8.3. JUnit does not set up your test fixture
8.4. Test setup fails after overriding runTest()
8.5. Your test stops after the first assertion fails
8.6. The graphical test runner does not load your classes properly
8.7. JUnit fails when your test case uses JAXP
8.8. JUnit fails when narrowing an EJB reference
9.1. Verify the order of elements in a document
9.2. Ignore the order of elements in an XML document
9.3. Ignore certain differences in XML documents
9.4. Get a more detailed failure message from XMLUnit
9.5. Test the content of a static web page
9.6. Test an XSL stylesheet in isolation
9.7. Validate XML documents in your tests
10.1. Test making domain objects from a ResultSet
10.2. Verify your SQL commands
10.3. Test your database schema
10.4. Verify your tests clean up JDBC resources
10.5. Verify your production code cleans up JDBC resources
10.6. Manage external data in your test fixture
10.7. Manage test data in a shared database
10.8. Test permissions when deploying schema objects
10.9. Test legacy JDBC code without the database
10.10. Test legacy JDBC code with the database
10.11. Use schema-qualified tables with DbUnit
Chapter 11. Testing Enterprise JavaBeans
11.1. Test a session bean method outside the container
11.2. Test a legacy session bean
11.3. Test a session bean method in a real container
11.5. Test CMP meta data outside the container
11.7. Test a message-driven bean inside the container
11.8. Test a message-driven bean outside the container
11.9. Test a legacy message-driven bean
11.10. Test a JMS message consumer without the messaging server
11.11. Test JMS message-processing logic
11.12. Test a JMS message producer
11.13. Test the content of your JNDI directory
Chapter 12. Testing web components
Test the components in a container
12.1. Test updating session data without a container
12.2. Test updating the HTTP session object
12.3. Test rendering a JavaServer Page
12.4. Test rendering a Velocity template
12.6. Test your JSP tag library deployment
12.7. Test servlet initialization
12.9. Test processing a request
12.10. Verify web page content without a web server
12.11. Verify web form attributes
12.12. Verify the data passed to a page template
12.13. Test a web resource filter
Chapter 13. Testing J2EE applications
13.2. Test navigation rules in a Struts application
13.3. Test your site for broken links
13.4. Test web resource security
13.5. Test EJB resource security
13.6. Test container-managed transactions
Chapter 14. Testing design patterns
14.1. Test an Observer (Event Listener)
14.2. Test an Observable (Event Source)
14.4. Test a Singleton’s client
14.6. Test a template method’s implementation
15.1. Verify events with EventCatcher
15.4. Compare JavaBeans using “appears equal”
16.1. Test your class for compareTo()
16.2. Collect tests automatically from an archive
16.3. Organize test data using PropertyManager
16.4. Manage shared test resources
16.5. Ensure your shared test fixture tears itself down
16.6. Report the name of each test as it executes
17.1. Clean up the file system between tests
17.2. Test your file-based application without the file system
17.3. Verify your test case class syntax
17.4. Extract a custom assertion
17.5. Test a legacy method with no return value
17.6. Test a private method if you must
Appendix A. Complete solutions
A.1. Define a test suite in XML
A.2. Parameterized Test Case overriding runTest()
A.3. Ignore the order of elements in an XML document
A.4. Test an XSL stylesheet in isolation
A.5. Validate XML documents in your tests
A.6. Aspect-based universal Spy
B.2. Strangeness and transitivity
B.4. The mock objects landscape