Microsoft Research has released a new version of Pex, an automated white-box testing library for .NET. Pex v0.11 adds support for Delegates as Parameters, a new Exception Tree View, Stubbed Events, and Recursive Stubs. This release fixes an issue with incorrect registration of the Stubs Visual Studio Add-in, and it updates Pex to reference the latest Code Contracts release.
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 performs a systematic analysis, hunting for boundary conditions, exceptions and assertion failures, which you can debug right away. Pex enables Parameterized Unit Testing, an extension of Unit Testing that reduces test maintenance costs.
Pex v0.11.40421.0 can be downloaded from MS Research. This release requires the OpenMP C++ runtime. This runtime is installed by default on a machine with Visual Studio or can be downloaded separately.
Delegate As Parameters: Pex now understands Parameterized Unit Tests that take delegates as parameters. Pex will automatically generate a delegate instance and its behavior: if the delegate returns a value, Pex will generate a new symbolic value for it, track its use, and then generate different values depending on the program behavior.
When executing Pex on Test, Pex will generate a Func
Pex Explorer: Exception Tree View:
We have started to work on improving the experience when applying Pex to a large number of explorations. To this end, a new window called Pex Explorer will show various views over the events produced by Pex. The Exception Tree View provides the tree of exception types that Pex found. This is really helpful to quickly drill through the (really) bad exceptions first.
Pex Explorer: Contract Failures Tree View: If Code Contracts are being used, Pex also provides a specialized view to sort the contract failures kind.
Events in Stubs: Stubs now support events:the stub simply expose the backing delegate fields (which hold the event delegate)as a public fields. As a result, one can clear, set, and invoke the event as any other member.
Recursive Stubs: Another common feature of mock/stub frameworks is to support nested invocation of members. Stubs now lets you recursively invoke property getters. Instead of assigning the property getter delegate, you can use new helper methods ending in ‘AsStub’ that take care of allocating the nested stub, assigning it to the property getter and returning it.