Test driven development
(Microsoft .NET,Microsoft ASP.NET,Microsoft Visual Studio) by Jason Skowronek on 02/03/2011 This article demonstrates how to setup a basic unit test project to take care of code coverage of a standard ASP.NET website. This article assumes you have created an ASP.NET Web Application project (not ASP.NET Website). Setup a Unit Test Project Open your solution in Visual Studio 2010 Click Test | New Test Select Basic Unit Test (or any of the others) Name your test class Add to or create a new test project (preferably ProjectName.Tests)
Update : Development of this project has moved to GitHub .
The term 'Mock Objects' has become a popular one to describe special case objects that mimic real objects for testing. Most language environments now have frameworks that make it easy to create mock objects.
Highly recommended reading: Fowler’s article Mocks aren’t Stubs . It’s a very clear characterization of the types of so-called Test Doubles (mocks, fakes, stubs, etc.) you can use to aid your unit testing needs, but also of the kinds of TDD you can do: classic (or state) TDD and mockist (or interaction) TDD. I got the feeling that the article seemed a bit biased towards mockist TDD, only to see in the “So should I be a classicist or a mockist?” section that Fowler himself is a classic TDDer ). Maybe it’s because mockist TDD is a newer approach to TDD and therefore required a more extensive explanation.
Recently I started writing a simple application that would help me organize my music files by automatically renaming them using their tags and moving them to their designated folders. As expected the program will rely on the file system classes that the .Net Framework provides. Naturally, I wanted to cover the I/O logic with tests so that I am confident that when the software is used it will not do damage to my files and will behave according to my requirements.