Tuesday, December 14, 2010

Automated Tests as an Aid to Debugging


So, what makes automated tests valuable when debugging? They help out at all stages:

• First and foremost, well-tested code tends to have fewer bugs in the first place. The easiest bug to fix is the bug that never existed.

• The shorter the delay between a mistake being made and subsequently being discovered, the easier and cheaper it is to fix. Early testing means that most bugs are discovered very shortly (often immediately) after they’re introduced.

• Automated testing is a key enabler of continuous integration, in which code is integrated with the whole product as soon as it’s complete.  

• Automated tests allow you to frequently release new versions of the software with high confidence that the new release is functional. This means that you get end-user feedback on new features and bug fixes much more quickly than would otherwise be the case (again, reducing the time between code being written and bugs being discovered within the code). It can also reduce the need to back-port bug fixes to previous versions of the software or to release patches.

• For code to be tested, it needs to be structured in such a way as to provide access to intermediate results and internal state that might otherwise be unavailable. This kind of access turns out to be a great help during later debugging.

• Writing a test is an excellent way to reproduce a bug during the diagnostic process. Many of the techniques created to support automated testing are extremely useful for reliably reproducing bugs.

• After you’ve completed your diagnosis, automated tests provide powerful protection against the fix introducing regressions.

• If, during diagnosis, you make a habit of always writing a test that reproduces the bug, you naturally end up with a regression test that ensures that the bug won’t be reintroduced at some point in the future.

• Automated tests are a key enabler of refactoring, which is the most powerful weapon at your disposal to ensure that code remains well-structured and flexible throughout its lifetime.

Automated tests are a particularly powerful debugging tool when allied with a technique that has risen in popularity alongside them—test doubles.

Source of Information :  Paul Butcher - Debug it Find repair and prevent bugs

Automated Tests as an Aid to DebuggingSocialTwist Tell-a-Friend
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

0 comments: on "Automated Tests as an Aid to Debugging"

Post a Comment