.NET software testing tutorials: unit testing, open source, NUnit, SpecFlow, Visual Studio, etc.
Running your SQL Server database unit tests within the scope of a single transaction allows you to roll back any changes that the test enacted after the test ends. This article propose a step by step approach to achieve this goal. You start to create a transaction in your Transact-SQL test script that uses BEGIN TRANSACTION and ROLLBACK TRANSACTION. Then you will create a transaction for a single test method in a test class and then a transaction for all test methods in a given test class.
Unit testing is a difficult but essential activity to improve software quality and team velocity. This video presents the best practices to perform unit testing in a .NET context and with an agile approach.
This article provides a process to integrate Test-Driven Development in the maintenance of a .NET application. You will first write the tests that will prove your new code gets the same results as the legacy code. Then you isolate new code into separate methods or classes that you can test independently. You break down the requirements into simple valid tests. Finally you check to see that you have not introduced a new bug. While you are doing this, let Visual Studio generate the utility code for you and find a tool to run your tests continuously like AutoTest.NET.
Rowan Miller shows how to replace a DbContext based data access layer with an in-memory fake for unit testing in this blog post. He builds an interface that represents the context and then builds an in-memory fake of that context for use in our unit tests. He uses an MVC controller but the same approach can be used with any component that needs to interact with an EF based context, including repositories. The key benefits of this approach are stable and robust tests that execute quickly and exercise a single component, making failures easy to isolate.
This article provides a detailed description on how use Pex and Moles to generate unit tests for a project having external dependency(WCF Proxy) using Visual Studio 2010 SP1. The Pex tool, which automatically generates test suites with high code coverage, will be used to generate unit tests. Moles allows to replace any .NET method with a delegate. They will be generated to isolate the external dependency (WCF proxy) and behavior will be redefined using delegates.
This video describes the six mechanisms in Visual Studio 2010 that enable more effective collaboration between developers and testers. These mechanisms include tools to create actionable bugs, debug historical events, and automate functional testing. Effective collaboration between developers and testers is paramount and can make the difference between shipping quality applications on time, or slipping because bugs are found late.
This article presents a simple and efficient engine which produces mutations of source code written in C# with helps testing it. The novelty of this engine is that it produces mutations that do not contradict with the specifications of the program. The latter are described by a set of pre- and post-conditions and invariants. The engine comprises two parts, a static analysis and syntactic verification component and a mutation generation component. Preliminary experiments showed that the proposed engine is more efficient than a simple mutations generator in terms of producing only valid mutations according to the specifications posed, thus saving time and effort during testing activities.