We just published Pex 0.7. This update is mainly a maintenance release. We have been working on fixing bugs, those reported by our users, as well as many others we found while using Pex internally. There are a few breaking changes (mainly renamings), and a few improvements under the cover.
Patterns for Parameterized Unit Testing
Writing good parameterized unit tests is hard. We have started to collect a set of patterns how to write good parameterized unit tests, and avoid bad ones. Peli gives an introduction to our new paper with patterns in his blog.
Pex now knows a bit more about enums, so that you can write assumptions such as the following.
The assumption above filters out those enum values which are not defined.
Better Exploration Strategies
In addition to such improvements in local reasoning, we also worked on better global reasoning, i.e., searching more effectively for interesting feasible execution paths.
Together with Tao Xie, who visited us from North Carolina State University, we developed a search strategy based on the idea of fitness. The result is a paper [PDF], and we also published the source code on CodePlex. If you dare, you could try to write your search strategy, plug it into Pex, and see if your strategy solve problems that Pex couldn’t solve before!
For example, before we integrated the the fitness-based search strategy, Pex had a really hard time to find the "bug" hidden in the following test.
(I realize that this test doesn’t do anything useful. It’s just the essence of a testing problem.) You need to come up with a very particular input array to hit the "bug". The problem here for Pex is that the variable y, whose value decides whether we hit the bug, is related to the test inputs in a very indirect fashion. To better attack those kinds of problems, Pex now uses the notion of fitness to guide the search, here towards those test inputs which cause y to be closer and closer to 10.