Whew! I can finally talk about one of the coolest pieces of code I’ve seen in ages: WinUnit. About a year ago, my friend, Maria Blees showed me an idea she had for unit testing native C++ code and asked if I thought it was any good. It was far more than good it was outstanding! WinUnit brings NUnit-like testing to native C++ code. What makes WinUnit very nice is that writing tests is easy, but what makes it truly great is it includes the infrastructure to run those tests. That’s what’s been missing from other native testing approaches.
I ported over a good size library I had, which used separate EXE files for testing to use WinUnit. It turned out that I cut the code down by 40% and got 40% more automated code coverage! That’s one heck of a return on your investment.
Maria’s article in MSDN Magazine discusses all the ins and outs of using WinUnit so you can see how to apply it immediately to your code. She even included a set of Visual Studio macros to configure your projects to use WinUnit. Most impressively, she included all her unit tests, written in WinUnit of course.
The most common question I get for native development is “how can I unit test C++?” Now, you have the answer. It’s been killing me to have to hold WinUnit secret until it finally was published in MSDN Magazine. It’s not too often I’m stunned speechless a piece of code any more, but WinUnit was one of those. I can’t recommend WinUnit enough!
Update April 30, 2008: MSDN Magazine broke their years of links recently so I fixed the links.