I'm having trouble figuring out how to get the testing framework set up and usable in Visual Studio 2008 for C++ presumably with the built-in unit testing suite.
Any links or tutorials would be appreciated.
I'm having trouble figuring out how to get the testing framework set up and usable in Visual Studio 2008 for C++ presumably with the built-in unit testing suite.
Any links or tutorials would be appreciated.
I'm not 100% sure about VS2008, but I know that the Unit Testing framework that microsoft shipped in VS2005 as part of their Team Suite was only for .NET, not C++
I've used CppUnit also and it was alright. Much the same as NUnit/JUnit/so on.
If you've used boost, they also have a unit testing library
The guys behind boost have some serious coding chops, so I'd say their framework should be pretty good, but it might not be the most user friendly :-)
Here is the approach I use to test the IIS URL Rewrite module at Microsoft (it is command-line based, but should work for VS too):
Here is an example:
With this approach, people don't have to learn too much C++/CLI stuff, all the real test will be done in C++ native and the TestShim class will be used to 'publish' the test to MSTest.exe (or make it visible).
For adding new tests you just declare a new [TestMethod] void NewTest(){::NewTest();} method and a new void NewTest() native function. No macros, no tricks, straighforward.
Now, the heade file is optionally, but it can be used to expose the Assert class' methods with C++ native signatures (e.g. wchar_t* instead of Stirng^), so it can you can keep it close to C++ and far from C++/CLI:
Here is an example:
HTH
I've used CppUnit with VS2005 and Eclipse. The wiki is very thorough (especially if you are familiar with JUnit).
I use UnitTest++.
In the years since I made this post the source has moved from SourceForge to github. Also the example tutorial is now more agnostic - doesn't go into any configuration or project set up at all.
I doubt it will still work for Visual Studio 6 as the project files are now created via CMake. If you still need the older version support you can get the last available version under the SourceForge branch.
I was suffering to implement unit testing for an unmanaged C++ application in a Windows environment with Visual Studio. So I managed to overcome and wrote a post as a step-by-step guidance to unmanaged C++ application unit testing. I hope it may help you.
Unit test for unmanaged C++ in Visual Studio
There is a way to test unmanaged C++ using the built in testing framework within Visual Studio 2008. If you create a C++ Test Project, using C++/CLI, you can then make calls to an unmanaged DLL. You will have to switch the Common Language Runtime support to /clr from /clr:safe if you want to test code that was written in unmanaged C++.
I have step by step details on my blog here: http://msujaws.wordpress.com/2009/05/06/unit-testing-mfc-with-mstest/