TDD

I’ve been investigating different unit testing frameworks for JavaScript lately and I stumbled onto FireUnit. FireUnit is a unit testing framework created by John Resig (of well-deserved jQuery fame) and Jan Odvarko. In this blog entry, I provide a brief overview of the FireUnit testing framework. In particular, I explain how you can use FireUnit to unit test JavaScript code. Installing FireUnit FireUnit is implemented as a FireFox extension. This is both bad and good. First, the bad news. You cannot use FireUnit with Internet Explorer, Safari, Chrome, or any other browser than Mozilla Firefox. Here’s the good news. FireUnit extends Firefox with...

Posted Monday, May 18, 2009 9:45 AM

The motivation for this blog entry is to explain the nature and purpose of the tests used in Test-Driven Development. To avoid confusion, I’ll use the expression TDD test to refer to the type of test used in the context of Test-Driven Development. The goal of this blog entry is to clarify the relationship among TDD tests, unit tests, and acceptance tests. TDD Tests are not Unit Tests Let’s start with the distinction between TDD tests and unit tests. On the surface, TDD tests are very similar to unit tests. This is not surprising, since you use a unit testing framework such...

Posted Saturday, April 11, 2009 2:30 PM

Recently, I had a disagreement with a colleague over the correct way to do Test-Driven Development. This is an important disagreement because it affects the design of the ASP.NET MVC framework. According to my co-worker (let’s call him Tad), there is no difference between Test-First Development and Test-After Development “except when you write your unit tests.” Tad is a practitioner and proponent of Test-After Development. When you practice Test-After Development, you write application code first and then you write a unit test that tests the application code. From the perspective of someone who practices Test-Driven Development, this gets things backwards. I...

Posted Wednesday, April 08, 2009 12:52 PM

Thank you everyone who came to my one day ASP.NET MVC workshop at ASP.NET Connections. We managed to build an entire Movie Database application with unit tests and a reasonably good design -- Congratulations! I've attached the Movie Database application and the demo code from the workshop below. Workshop Code

Posted Thursday, March 26, 2009 5:15 PM

I will be in Orlando, Florida next week speaking at the ASP.NET Connections conference in Orlando, Florida. I'm giving 5 separate talks.  I'm presenting two talks on Microsoft day: ASP.NET MVC: A New Framework for Building Web Applications ASP.NET MVC is Microsoft’s newest framework for building web applications. In this session, you learn how to take advantage of ASP.NET MVC to build loosely coupled and highly testable applications. Over the course of this session, we build a simple database-driven Web application from start to finish. You learn how to use several features of the ASP.NET MVC framework including Model Binders, Partials, and...

Posted Friday, March 20, 2009 9:49 AM

We posted a complete Contact Manager sample ASP.NET MVC Application at the www.ASP.net/mvc website. The source code is available in both C# and VB.NET. The application is intentionally simple. The goal was to provide members of the ASP.NET community with an application that they could use to quickly learn how to build new applications with ASP.NET MVC. The Contact Manager application is an address book application. The application enables you to list, create, edit, and delete contacts. I built the application over multiple iterations. With each iteration, I gradually improved the application. The goal of this multiple iteration approach was to enable...

Posted Friday, February 27, 2009 7:51 AM

In this series of blog posts, I build an entire ASP.NET MVC Forums application from start to finish. In this post, I explain how to test and implement authentication and authorization for the Forums application. Before you read this blog post, you should read the previous posts in this series: ASP.NET MVC Application Building: Forums #1 – Create the Perfect Application – In this first entry, I explain the overall goals of the ASP.NET MVC Forums application. I emphasize the importance of Software Design Principles and justify my choice to use test-driven development. ASP.NET MVC Application Building: Forums #2 – Create the First...

Posted Friday, September 12, 2008 4:22 PM

In this series of blog entries, I build an entire ASP.NET MVC forums application from start to finish. In this blog entry, I add the functionality to the Forums application that enables users to post new messages and replies. Before reading this blog entry, you should read the previous two blog entries in this series: ASP.NET MVC Application Building: Forums #1 – Create the Perfect Application – In this first entry, I explain the overall goals of the ASP.NET MVC Forums application. I emphasize the importance of Software Design Principles and justify my choice to use test-driven development. ASP.NET MVC Application Building: Forums...

Posted Saturday, September 06, 2008 12:44 AM

In this series of blog entries, I build an entire ASP.NET MVC Forums application from scratch. In this blog entry, I create my first unit test for the Forums application and implement the code necessary to pass the test. Before reading this blog entry, you might want to read the first entry in this series: ASP.NET MVC Application Building: Forums #1 – Create the Perfect Application – Describes the goals of the ASP.NET MVC Forums application. Create the ASP.NET MVC Application Let me start by creating a new ASP.NET MVC application. Launch Visual Studio 2008 and select the menu option File, New Project. Select...

Posted Friday, September 05, 2008 5:41 PM

In this tip, I show how you can create custom route constraints that prevent you from accessing a URL unless you are local and authenticated. I show you how you can create a LocalConstraint and an AuthenticatedConstraint. I also demonstrate how you can test your custom constraints. When you create an MVC route, you can add constraints to a route. For example, the following route maps browser requests to a controller named Blog and an action named Archive: routes.MapRoute( "BlogArchive", "Archive/{entryDate}", new { controller = "Blog", action = "Archive" } ); This route, named BlogArchive, maps three parameters. The controller...

Posted Thursday, August 07, 2008 5:41 AM