15.4. Testing

The entire testing procedure is beyond the scope of this book. Following is a short summary of how the tests proceed. The client and I developed our testing strategy as the design was being developed ("Plan for Testing"). Because we applied the guidelines of Extreme Separation, there are only a few methods to test in each class.

  1. For each ParticularMessage:

    1. Ensure that convert_to_text( ) and convert_from_text( ) both work.

    2. Create a message with test values, call handle( ), and check that the returned Message is of the correct type and has the appropriate values.

  2. For each set of Messages involved in an operation method, such as do_particular_operation( ):

    1. Call do_particular_operation( ).

    2. Check the return values from do_particular_operation( ) to see if they match the testing oracle (the definitive source of what should be the results of a test).

  3. For a sequence of operation methods:

    1. Call the set of methods.

    2. Check the values along the way to see if they match the testing oracle.

You can run the second and third tests in a variety of environments by varying the implementations of TextMessageDispatcher, ClientEnvironment, and ServerEnvironment.

The classes that implement interfaces allow for mixing and matching of implementations during testing ("Build Flexibility for Testing"). Both ClientMessageDispatcher and ServerMessageDispatcher implement the MessageReceiver. To test that the handle( ) method for each Message works correctly, do_particular_operation( ) can call the implementation ...

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.