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.
Microsoft Azure and Amazon Web Services (AWS) are two of the most popular cloud platforms.…
Cloud management is difficult to do manually, especially if you work with multiple cloud…
Azure’s scalable infrastructure is often cited as one of the primary reasons why it's the…
https://www.youtube.com/watch?v=wDzCN0d8SeA Watch our "Unlocking the Power of AI in your Software Development Life Cycle (SDLC)"…
FinOps is a strategic approach to managing cloud costs. It combines financial management best practices…
Using Kubernetes with Azure combines the power of Kubernetes container orchestration and the cloud capabilities…
View Comments
I often get asked about unit testing native code and quite frankly I’ve never really had a good answer
From Where I can download WinUnit?
Sarath,
See the MSDN Magazine article at http://msdn.microsoft.com/msdnmag/issues/08/02/NativeUnitTesting/default.aspx.
- John Robbins
John Sir,
Thanks. I never looked into the source code.
WinUnit reminds me of unittest++, which is by the way plattform-independent. Why inventing the wheel twice?
This looks very similar to CPPUnit. It would be great to find a comparision of the various C++ options for unit test frameworks.
Karl-Heinz and Mike Miller
The problem with unittest++ and CPPUnit is they are missing a fundimental piece: a simple to use infrastructure for running tests. With WinUnit, you can run all tests, one test, or any combination of tests. The other frameworks are run all your tests all the time or you get the pain of writing your own runner.
WinUnit is the only tool that truly brings NUnit like functionality to native Windows developers. That's why I like it so much.
- John Robbins
You are right, the TestRunner is missing in other frameworks as those do not depend on a plattform nor on a certain developer-environment. BTW unittest++ tests can be started in the postbuild-step of VisualStudio, errors are reported in the output pane...
But talking "about one of the coolest pieces of code I've seen in ages..."... hm, sorry I can't agree.
@Mike Mille: have a look at: http://www.gamesfromwithin.com/articles/0412/000061.html
John, it looks like as if the link to the code download from the February Magazine is broken. You can download the file but it will not extract and fail with an error.
Can you provide a different link?
Thank you,
Manfred
Manfred,
Grrrr. MSDN Magazine went off and broke 15+ years of links. I updated the links in my blog post. Also, in their infinite wisdom, MSDN Magazine no longer lets you download an individual article's code. You have to get the full issue's code. The Feb '08 issue code is at: http://download.microsoft.com/download/f/2/7/f279e71e-efb0-4155-873d-5554a0608523/MSDNMag2008_02.exe