Wednesday, March 9, 2011

Having fun with Pex

Pex is a white box testing framework for .NET that integrates directly into Visual Studio 2010. Currently it’s in development by Microsoft Research. The framework uses symbolic execution to test the certain paths of a given method. It tries to find proper boundary conditions and applies them to the method. After execution the results for each input value are displayed and you can easily identify incorrect behavior. Together with the isolation framework Moles you can use Pex to automatically create white box tests for your methods. For further information to Pex and Moles have a look at: http://research.microsoft.com/en-us/projects/pex/

Now to the fun part: There’s an online version of Pex, called Pex for fun at http://www.pexforfun.com/. It’s a very simplified version of the fully featured framework mentioned above. Pex for fun features a set of so called puzzles. You can either watch a given method implementation, try to understand what it does and figure out which input values would lead to a failure or you can try to implement a secret method, which is really fun and sometimes difficult too. You just get an empty method stub. Your task is to implement it according to a given implementation which is kept secret. The only hints you get are by asking Pex. The framework compares the paths of your method with the secret implementation. If the results are the same for all determined input values, than you win that certain puzzle. It’s a kind of test driven development. You just know the input values and the according results and need to find the correct implementation. If you sign in with your Live Id you can even create your own puzzles and you gain points for solving puzzles of other users. It’s a good exercise to test both your analytical and your programming skills.

No comments:

Post a Comment