background preloader

Test driven development

Facebook Twitter

How To Configure ASP.NET Unit Tests in Visual Studio 2010 - SkoNet. Moq - The simplest mocking library for .NET and Silverlight. Mocks Aren't Stubs. 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. What's often not realized, however, is that mock objects are but one form of special case test object, one that enables a different style of testing. In this article I'll explain how mock objects work, how they encourage testing based on behavior verification, and how the community around them uses them to develop a different style of testing. I first came across the term "mock object" a few years ago in the Extreme Programming (XP) community.

Since then I've run into mock objects more and more. Partly this is because many of the leading developers of mock objects have been colleagues of mine at ThoughtWorks at various times. Partly it's because I see them more and more in the XP-influenced testing literature. But as often as not I see mock objects described poorly. Regular Tests. State Testing vs Interaction Testing.

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. Or maybe it’s just that the article title is a bit misleading as its content is about mocks in the strict sense used by mockists, and not in the general sense I think of them (as generic aids in unit testing). I’m a state testing guy myself, but I always found it very annoying having to create all those little “mocks” to help me test classes that had dependencies. . Using ApprovalTests in .Net 20 Asp.Mvc Views. Visual Studio 2010: Test Driven Development. Description Visual Studio 2010 brings with it several enhancements to help cut development friction and enable the developer to focus on the task at hand: writing high-quality code.

In the following exercises we'll highlight several of the new features that the TDD developer can use to enhance his/her development cadence. Visual Studio helps your cadence by cutting the number of keystrokes to accomplish frequently performed tasks, speeds navigation through your solution, and enables you to use test frameworks other than MSTest. Overview Test Driven Development (TDD), also frequently referred to as Test Driven Design, is a development methodology where developers create software by first writing a unit test, then writing the actual system code to make the unit test pass. TDD follows a cadence of “Red, Green, Refactor.” Note: This lab is not meant to teach you how to work with TDD; instead, it is intended to highlight Visual Studio 2010’s support for working in TDD. Objectives Setup Exercises. Fit: Framework for Integrated Test.

Mocking The File System to Improve Testability « Milan Nankov’s Blog. 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. So I started writing tests… And here is the catch – in general it is not a good idea to have tests that are performing I/O operations like accessing files and databases.

Usually faster than performing I/O operations You do not have have to deal with security issues You have more control – easily test intricate scenarios Test setup is far more easier to do The first thing that most people think about when asked about mocking is interfaces. Let’s write some tests… Notice that the constructor accepts a parameter of type IFileSystem.