Matthew Cox Team : Web Development Tags : Technology Web Development

The return of Pex

Matthew Cox Team : Web Development Tags : Technology Web Development

I must admit that when I first heard the concept of unit testing I didn’t quite get it. Code that proves my code does what I think it does? “Well of course it does what I think it does, I just wrote it and I can easily read it to verify that fact.” It seemed to me that unit testing was the practice of writing thousands of lines of code to catch the one in a thousand times you both miswrote and misread a function. It always seemed silly to me that you would verify your function with known data, my function is obviously only going to break when it gets a value that I’m not expecting.

Then in 2008’ish Microsoft Research announced Pex, a library that would automate unit testing. At that time it was only available to MSDN subscribers, but it seemed to me like it finally made sense of this unit testing nonsense. Rather than having to write massive amounts of code just to prove what I already knew, Pex would analyse the structure of my code and work out the necessary inputs to achieve 100% unit test coverage without me having to do anything.

Unfortunately Pex never seemed to go anywhere, the plugin got developed up to VS2010, but after that, nothing. Eventually Microsoft released Code Digger for VS2012 and VS2013, but it would only work on portable assemblies and didn’t have test generation so it was a poor substitute for Pex.

While over the years my understanding and appreciation of unit tests have improved, my desire for effortless test coverage hasn’t waned. Which is why I was really excited to learn that it finally looks like Pex is going to graduate from a research project to a full-fledged product. It’s gone through the Microsoft boring name generator and come out as “Smart Unit Tests” and will be included as part of the ultimate edition of Visual Studio 2015.

https://msdn.microsoft.com/library/dn823749%28v=vs.140%29.aspx