.NET software testing tutorials: unit testing, open source, NUnit, SpecFlow, Visual Studio, etc.
This article from Keith Burnell presents best practices and techniques to increase the testability of ASP.NET MVC applications. This includes how to structure the solution, architecting the code to handle the injection of dependencies and implementing dependency injection with StructureMap.
This article explains how you can set up a unit test method that will retrieve values used in the test method from a data source using the Microsoft unit test framework for managed code. Creating these data-driven unit tests makes it easy to test a multiple inputs with a single method.
In this blog post, Dror Helper presents a short “getting started” procedure to do Behavior Drive Development (BDD) with SubSpec. SubSpec allows developers to write declarative tests operating in C# at all layers of abstraction consisting of highly composable, small primitive concepts. SubSpec is based on the xUnit testing framework and can easily be integrated into existing testing environments. The blog post shows how to write its first behavior test and how to run all the assertions in one test.
Best practices for unit testing are that you should only write for each test a single assertion. In this article intends, Jonathan Allen tries to demonstrate that unit tests with multiple assertions are both necessary and beneficial.
This article explains how Microsoft Fakes perform a similar role than mocking in unit testing, helping you to isolate the code you are testing in Visual Studio by replacing other parts of the application with stubs or shims. A stub replaces another class with a small substitute that implements the same interface. A shim modifies the compiled code of your application at run time so that instead of making a specified method call, it runs the shim code that your test provides.
Replace any .NET method with your own delegate! “Fakes” is a new framework in Visual Studio 11 for test stubs and detours in .NET. Fakes may be used to detour any .NET method, even in tough situations like static methods, non-virtual methods, private methods, constructors, etc… If you’ve been a user of Moles, Fakes is a lot like Moles but different so come and learn about the changes coming ahead too.
In this blog post, Rui Sun and Andre Hamilton explore some Visual Studio 2012 capabilities that will make it easier to test and verify Windows 8 applications. Visual Studio 2012 has a simulator that reduces your need to have physical devices of every form factor at your disposal for testing. You can launch your application in the simulator directly from within the Visual Studio through the debugging action. Then you can interact with your application using the mouse or using simulated touch on your development computer with gestures like swipe, pinch to zoom and rotation. Visual Studio also provides a unit test library project for Windows 8 applications written in C#, VB.net or C++.