Section 34.6. Summary


34.6. Summary

We have seen a useful pattern to follow when a system depends on another, independent system, such as the system clock. Emily and Neo introduced a normal and a mock form of the clock so that it was easy to switch between them. The test fixture creates the mock clock and passes it to the system under test, making it easy for the fixture to alter the date and time.

Questions & Answers

Q1:

Can this mocking approach be used with other sorts of independent systems?

A1:

Yes. There is a tradeoff in doing this, however. The increase in speed of running the tests leads to a reduction in the quality of the testing. A good approach is to run the faster tests more frequently but still run the end-to-end tests involving the whole system regularly.

This approach to mocking is handy to use in programmer tests with JUnit as well. It allows subsystems to be tested by removing their dependence on other parts of the system. See [HT03], [RS04] for further details.



    Fit for Developing Software. Framework for Integrated Tests
    Fit for Developing Software: Framework for Integrated Tests
    ISBN: 0321269349
    EAN: 2147483647
    Year: 2005
    Pages: 331

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net