Chapter 14Unit Testing
—by Brad Wilson
What's In This Chapter?
- Understanding unit testing and test-driven development
- Building a unit test project
- Advice for unit testing your ASP.NET MVC and ASP.NET Web API applications
Unit testing and developing testable software have become recognized as essential elements in the software quality process. Most professional developers practice some form of unit testing in their daily jobs. Test-driven development (TDD) is a style of writing unit tests where the developer writes a test before writing any production code. TDD allows the developer to evolve the design in an organic way, while still gaining the quality and regression testing benefits of unit tests. ASP.NET MVC was written with unit testing in mind. This chapter focuses on how unit testing (and TDD in particular) applies to ASP.NET MVC.
For users who have never practiced unit testing or TDD, the first half of this chapter offers a brief introduction to both subjects to encourage readers to seek out more in-depth information on the practices. Unit testing is a very large subject. This introduction should serve as a guide to whether unit testing and TDD are something you want to research further.
The second half of this chapter includes real-world advice for unit testing your ASP.NET MVC and Web API applications. Those who are already practicing unit testing and want to get the most out of their craft might want to skip directly to the second half of the chapter.
UNDERSTANDING ...
Get Professional ASP.NET MVC 5 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.