TDD and Test-Driven Refactoring

This is a neat observation. One equivalent to test-Driven Development (TDD) when working with an existing codebase might be “test-driven refactoring”. The idea seems to be that at any particular point in the lifecycle of a software system not all of the benefits of TDD are actually being used. So why not just do enough TDD to get the required benefits at the time.

In this case the need is to refactor some existing code in preparation for a change. Rather than either (a) stop to write tests for the whole system, or (b) throw up our hands and abandon TDD for this work, the suggestion is to write a passing test around the exact code being refactored, then use that test to ensure that the change preserved that behaviour. Then, in the TDD style, rinse and repeat for the following refactorings.

As this progresses the result should be a growing body of regression tests. concentrating around the areas which have actually changed, which seems good to me. It’s not as good as TDD from the start, but it’s better than no tests at all.

Agile Tips: Testing private methods, TDD and Test-Driven Refactoring

Jay Fields’ Thoughts: Developer Testing and the Importance of Context

Sometimes it can be tricky to decide how to best write tests to express the correct information to potential readers and maintainers. In the general case this is true of all code, but the following article discusses some of these issues in the context of developer testing.

Jay Fields’ Thoughts: Developer Testing and the Importance of Context

The Value of Test Names

A really thought-provoking article about the use and/or necessity of names for tests. Read it and be prepared to reconsider your assumptions.

Jay Fields’ Thoughts: Testing: The Value of Test Names

Confidence as a test code metric

A brief description of the value of tests in building confidence in a codebase.

nutrun » Blog Archive » Confidence as a test code metric

Using Stubs to Capture Test Essence

Jay Fields recommends using stubs far more often than mocks, a view which aligns pretty well with my own thoughts. I still find most tests using traditional Mock frameworks to be inexpressive, unwieldy and fragile.

Jay Fields’ Thoughts: Using Stubs to Capture Test Essence