Parameterized Unit Testing with Pex

This tutorial explores the principles of parameterized unit testing with Microsoft Pex 2010. Microsoft Pex is a Visual Studio add-in for testing .NET Framework applications that automatically generates test suites with high code coverage. Right from the Visual Studio code editor, Pex finds interesting input-output values of your methods, which you can save as a small test suite with high code coverage.

Pex enables parameterized unit testing, an extension of unit testing that reduces test maintenance costs. A parameterized unit test is simply a method that takes parameters, calls the code under test, and states assertions. Pex analyzes the code in the parameterized unit test together with the code-under-test, attempting to determine interesting test inputs that might exhibit program crashes and assertion violations. Pex learns the program behavior by monitoring execution traces, using a constraint solver to produce new test cases with different behavior.