Chapter 8. Testing Code with Visual Studio

In This Chapter

  • Understanding different kinds of software testing

  • Creating and running unit tests

  • Introducing stubs and mocks

  • Using the Object Test Bench

  • Exploring unit-testing frameworks

So you're plugging along coding like crazy. You'll have this set of requirements knocked out in no time. But how do you know when you're done? If you're unit testing your code while you go, the answer is when your code passes all your tests. If you're not unit testing while you go, you'll probably code until you feel like you're done and then pass the code off for somebody else to test.

Testing is an important part of the software development life cycle. Many kinds of tests are performed to ensure an application fulfills its requirements. Developers are usually responsible for writing unit tests to test the code they write. In Visual Studio 2010 Professional Edition, testing is more of a coding practice than a feature. Microsoft provides upgraded editions of Visual Studio that provide extensive support for all kinds of testing.

This chapter discusses the importance of testing, shows you how to write simple unit tests, and introduces you to some of the Visual Studio tools you can use to support your testing efforts.

Defining Unit Testing

Testing means different things, depending on the context in which it's used. Developers are usually responsible for testing the code they write — unit testing. After code passes unit tests, it's usually checked into a source code ...

Get Visual Studio® 2010 All-in-One For Dummies® 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.