Pex – dynamic analysis and test generation tool for .NET from Microsoft

Pex (Program EXploration) is an assistant to the programmer.Pex takes test-driven development to the next level. Pex analyzes .NET programs. From a parameterized unit test, it automatically generates unit tests cases with high code coverage. In addition,when a generated test fails, it suggests to the developer how to fix the bugs.

 

Features

  1. With Pex, you can write parameterized unit test methods and leave to Pex the task of deciding which input is relevant to cover the code (or find bugs). Actually, parameterized unit tests are nothing but specifications. Pex integrates ‘naturally’ with existing unit test framework (VSTS, NUnit, MbUnit, etc…) by providing a set of custom attributes to tag Pex classes and tests.
  2. Call Pex directly from Visual Studio to start exploring the parameterized unit tests.
  3. Pex runs the parameterized unit tests with different input values. Pex monitors the execution and figures out why the program executed the way it did. This is represented as a boolean function over the test parameters. Pex then uses a constraint solver to compute new parameter values that make the program execute in a different way.
  4. From the parameterized unit tests, Pex generates classic unit tests that can be re-executed without Pex. Pex also tags the generated tests with additional information using attributes (for tools) and xml documentation (for humans).
  5. While exploring parameterized unit tests, Pex explicitly looks for program errors such as index out of bound or failing user assertions. Pex reports dynamically detected errors in the code.
  6. Sometimes Pex can automatically fix bugs! When a test fails, Pex traces back the involved values. Pex suggests additional checks to prevent the failure from happening again. Those checks are argument or invariant validation.
  7. Pex summarizes all the possible fixes in a prioritized table with quick preview.
  8. Pex integrates generated tests automatically inside the test project. Pex also avoids duplicate tests and recycles obsolete tests.
  9. Pex comes with a command line tool to execute any assembly containing Pex tests. Great for automation!
  10. Pex generates detailed HTML reports about the exploration process. The reports contains details about each generated tests, path conditions, suggested fixes, etc…
  11. Pex generates code coverage reports for each test.
  12. Pex has a built-in support for mocking interfaces and virtual methods. Pex generates the return values of mocked methods just like it generates test input for parameterized unit tests.

Watch the screencast

Technorati Tags: ,,

 
 
 

Leave a Reply