Testing

A 3-post collection

Designing With Testability in Mind

By Sean Grimes |  Mar 12, 2015  | csharp, testing

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. The most important thing about this principle is that it promotes the separation of concerns. Consider the example below:

Continue Reading...

Writing Your First Unit Test

By Sean Grimes |  Mar 12, 2015  | csharp, testing

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). The SUT can be just be about anything but is typically a method in a particular class. Since a unit test should only test a single thing then it follows that each of your tests should only have a single SUT.

Continue Reading...

Introduction to Unit Testing

By Sean Grimes |  Mar 4, 2015  | csharp, 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. This is where unit testing and automated testing in general comes in.

Continue Reading...