Chapter 6. Unit testing continuously integrated code

 

This chapter covers

  • Unit testing in a CI environment
  • Continuously examining test coverage
  • Test mocking

We’ll risk the opinion that without automated testing, CI would be obsolete, because CI’s main strength is that it shows how the changes you introduce into the code affect the software. The CI process should be designed to show you immediately when a change degrades the code quality. What better way to check for that kind of occurrence than to perform automated testing along with every source code change?

Automated software testing is a broad term. In this chapter, we’ll focus on one particular type of automated testing: unit testing. Unit testing lies somewhere toward the bottom of the common automated-test chain. We’ll get to the rest of the chain—integration, system, and acceptance testing—in chapter 7. But in this chapter, we’ll define what unit tests are and what purpose they serve in the CI process. We’ll take two popular testing frameworks, NUnit and Microsoft Unit Testing Framework (MSTest), and incorporate them into the CI process. Then you’ll learn how to mock things out to speed up your tests.

6.1. Unit testing from a bird’s-eye view

6.2. First encounters with unit testing

6.3. Microsoft unit testing framework

6.4. Summary

sitemap