Chapter 2. Design and Testability

When writing code and developing software, one of the most important aspects to keep in mind is, "How am I going to test this?" The testability of software (another way of saying how easily the software can be tested), is an important consideration that most software developers forget. If testability is considered from the first line of code, then the testing efficiency and the quality of the software are greatly increased.

To achieve a testable application, you need to be in the mindset of thinking about testing when it comes to writing the code. Whether the code is about new functionality or fixing a bug, you should always be writing tests to reflect the changes. When in this mindset, the process of writing a test and writing code becomes a natural combination of activities. This mindset sometimes requires that you take a step back from your code and consider the effect that the change will have on your code and its overall structure and testability.

One important aspect of testability is your code's design. If you design your code while keeping in mind ways to successfully test it, then the various aspects discussed in this book become easier to take advantage of and implement. This doesn't mean you can't apply the techniques when testing hasn't been considered first; it means that the techniques can be more difficult to use and that you might need to approach them in a different fashion.

In short, considering how the design will affect testing ...

Get Testing ASP.NET Web Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.