8.7. Testing

The automated acceptance tests are in the com.samscdrental.tests package:

    CheckinCheckoutTests.java
    TestOnlyOperations.java

The CheckInCheckoutTests class contains tests derived from the use cases and misuse cases. The tests run in the JUnit framework.[*] They are executed using collection instances (e.g., CDDiscDataAccess, CDReleaseDataAccess, etc.) containing a small amount of data. The data is initialized using the file import operation, which also serves in migrating data to the new system.

[*] Tests for the individual classes are not shown in the appendix. They duplicate much of the logic in the overall tests.

How many automated tests should you create? Let us differentiate between testing (determining if a system is functionally correct) and debugging (finding the source of failures). If the external interfaces to a system have a set of tests that check all functionality and the tests are successful, the system is functionally correct. If the tests are unsuccessful, the system does not work and the developer has to determine why.

It is possible to debug a system by tracing through the program driven by the external tests. For a complex system, the program tracing can involve numerous method calls and many classes. If there are no internal tests on a system's classes and modules, step-by-step debugging can be required to determine the cause of the failure.

The more tests performed on a system's internal classes and modules, the more confidence the developer ...

Get Prefactoring now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.