Skip to Main Content
Prefactoring
book

Prefactoring

by Ken Pugh
September 2005
Intermediate to advanced content levelIntermediate to advanced
240 pages
6h 28m
English
O'Reilly Media, Inc.
Content preview from Prefactoring

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Understanding Unittest.Mock

Understanding Unittest.Mock

Mario Corchero
Java™ Performance

Java™ Performance

Charlie Hunt, Binu John

Publisher Resources

ISBN: 0596008740Supplemental ContentCatalog PageErrata