Designing With Testability in Mind
Although there are some special considerations, designing for testability largely involves following well established software design principles. In this blog post I’ll cover these design principles and how they help with testability and also cover any special considerations that you’ll need to keep in mind.
Useful Software Design Principles Single Responsiblity Principle For those not familiar with the Single Responsiblity Principle (SRP), it was originally proposed by Uncle Bob Martin and states that a class should have a single responsibility or reason to change.
Writing Your First Unit Test
For the rest of the articles in this series, we’ll be using the excellent xUnit.net unit testing framework to write tests. This is the unit testing framework with the greatest amount of mindshare at the moment, with Microsoft having recently adopted it for the various ASP.NET projects that they have open sourced.
Before we begin, we’ll need to cover some simple concepts around how to write your tests. When writing a unit test, the thing being tested is called the System Under Test (or SUT for short).
Introduction to Unit Testing
Let’s be honest, manually testing software sucks. When developing a new feature, you’ll often have to manually test your changes multiple times to ensure everything is working. If you are a web developer, this usually means jumping through hoops in order to test your code through the UI. What you really want is a way to automate these tests and run them whenever you make a change. Even better would be a way to run these tests everytime someone else makes a change to the software as well.