9

TDD on the Web

by Jeff McWherter

WHAT'S IN THIS CHAPTER?

  • TDD with Web Forms
  • TDD with MVC
  • TDD with JavaScript

Previous chapters have discussed tools and theory to describe exactly what test-driven development is. It's now time to apply this knowledge to practical examples and bring test-driven development to the world that many software developers live in: the web.

You might be thinking that web frameworks (primarily ASP.NET Web Forms) do not separate concerns very well. The single reasonability principal is something we have been very strict about not breaking while performing TDD. From C# or Visual Basic code mixed into the ASPX files, to common JavaScript functions being copied from page to page, many web frameworks don't follow many of the rules outlined in previous chapters. This chapter discusses patterns that will make it easier to test web applications, including frameworks that don't separate concerns very well. This chapter will start with ASP.NET Web Forms and move onto a fairly new Microsoft framework called ASP.NET MVC, you will learn the techniques required to not only make your web applications more testable, create them using TDD.

Entire books have been written about testing for the web, such as Testing ASP.NET Web Applications by Jeff McWherter and Ben Hall (Wrox, 2009, ISBN: 978-0-470-49664-0). This chapter summarizes the important points about this topic. By the end of this chapter, you will understand how to develop your web applications using TDD.

Get Professional Test-Driven Development with C#: Developing Real World Applications with TDD now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.