We even wrote a tutorial. While it’s quite long, exercise 3 helps you to get started with Visual Studio 2008 Professional, and exercise 4 shows you how to use the command-line.
What is Pex?
Pex generates test inputs that cover all, or at least many of the corner cases in your .NET code. These test inputs are plugged into parameterized unit test that you write. The result is a small unit test suite, where each unit test calls the parameterized unit test with particular test inputs. There is a great picture on our main Pex page that illustrates this process.
Pex supports other unit test frameworks since the unit tests that Pex generates can be executed by other unit test frameworks without Pex. Pex comes with support for MSTest, the unit test framework of Visual Studio, out of the box. For support for other unit test frameworks, please look at the Pex Extensions project.
Parameterized unit tests have been around for quite some time already, under several names — row tests, data-driven tests, theories, etc.
What is really unique about Pex is that it analyzes your .NET code, instruction by instruction, to understand what your code is doing. Then, in a fully automatic way, Pex computes relevant test inputs that trigger the corner cases of the code. When you write assertions, Pex will try to come up with test inputs that cause an assertion to fail.
Is Pex a new Microsoft product?
No, it’s a prototype from Microsoft Research, developed mainly by two people. I started Pex in 2005, and Peli de Halleux joined the Pex team in 2006. Pex leverages other cool Microsoft Research technology, in particular the constraint solver Z3. We know that Pex has many rough edges, its version number is 0.5 for a reason.
Pex illustrates our vision how testing can be more powerful (and fun), without the difficulties of proving programs correct.
At this point we are mainly looking for feedback, and we want to see what it can do for other people.
To ask questions, get help, or just give feedback, please take a look at our mailing lists.
While Peli has blogged about Pex before, this is my first post. Stay tuned for more in-depth information on Pex at this place. I’ll also talk about its history, and the other more or less related research projects I worked on in the past (AsmL, Spec Explorer, XRT).
Hope you have some fun with Pex,
Disclaimer: This posting is provided “AS IS” with no warranties, and confers no rights.