BT

Pex: Unit Testing Tool from Microsoft Research

by Anand Narayanaswamy on Oct 27, 2012 |

Pex is a Visual Studio add-in and testing tool developed by Microsoft Research. It investigates, explores the managed code and suggests the tests, which the project requires. It provides support for code contracts, which are used to annotate methods with conditions such as preconditions, postconditions and invariants that must be initially verified for the code to run properly.

Pex automatically adds proper precondition to your code after a detailed analysis to catch any invalid data. On the other hand, code contracts provide additional data and information to refine the analysis done by Pex. The test project created with Pex using Visual Studio target MSTest, which is the default testing framework as well as other frameworks such as NUnit.

In order to work parameterized testing, you need to pass appropriate values to the parameters, which Dino Esposito thinks is a big challenge. According to Dino, Pex comes to the rescue and assists developers to pick meaningful input values using iteration with the help of dynamic symbolic execution technique.

You can check out Pex on the web for free. It is a simplified version of Pex power tools for Visual Studio and includes code puzzles. You just need to provide code in C#, Visual Basic or F# and all the background work happens in the cloud.

Pex Framework works only with Visual Studio 2010. However, if you work with Visual Studio 2012 then you need to make use of Microsoft Fakes framework.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT