Unit-Testing Native C++ with Visual Studio

Unit-Testing Native C++ with Visual Studio

  • Comments 16

John Socha-Leialoha

Hi there! I’m John Socha-Leialoha and I’m a big fan of TDD. When I asked around about writing C++ tests, I was told there isn’t any support for C++ unit tests in Visual C++. Not true. Check this blog post where I tell you what’s required in order to write unit test for native C++ code using Visual Studio.

[Go to John’s full article…]

  • @Joe. I don't agree. I was introduced to TDD about 5 years ago when I was writing Windows Mobile code. In that case, I would run the unit tests all the time on the desktop, and every now and then on the mobile device. Since Windows Mobile is a subset of Windows, there was no gaurantee that the behavior would be the same between the desktop and the device. However, even though there wasn't complete fidelity, our productivity gain was huge.

    What I'm doing now, and what resulted in my article, is testing desktop software on the desktop. Because my tests are true unit tests, not component or integration tests, they 100% valid. I have yet to run into a case where the behavior was any different between the testing environment and the production code. The actual code that I'm testing is always running as native code. At this point I have almost 400 unit tests, and they've saved us a number of times from making breaking changes.

Page 2 of 2 (16 items) 12