Section 34.5. Changing the Application in Small Steps


34.5. Changing the Application in Small Steps

Once the first test was failing because of the incorrect actual date being that day's date, Emily and Neo started to change the application to access the Clock from class RentEz. Emily offered the driving seat to Neo.

Together, they traced from the test fixture into the code to see specifically where the application was accessing the system clock as it affected that test. Neo then changed that code to access the date through RentEz.

After one change, the test passed, surprising them both. They then chose the next Fit test involving dates and ran it to see it fail. After some time tracing through the code, they found another point that needed to be changed to use the new Clock. "There seems to be some redundancy here," remarked Neo.

"Let's mark it in the code and come back to it later," suggested Emily. "By using the tests to drive the change, we can be sure that all the changes have been tested."

Questions & Answers

Q1:

What if you notice some code that needs to be changed, but there's no test to force the change?

A1:

At some point, it would be wise to think about the test that would be needed to use that code. That may take some careful thinking. However, it may not be possible to create such a test, if the code is completely redundant. It may have been left there after a change and no one was sure about removing it.



    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