1

I want to start to do some unit testing however I am really confused about how to setup CPPUnit. I have looked at various tutorials and guides online to find out what to do but there are so many variants of what to do. I've tried a few ways but none seem to work. If anyone could pont me in the right direction of what to do then I woudl be extremeley grateful. I am currently using visual studio 2005 and most of my apps are mainly MFC I also create a fair amount of .net apps so ideally I want it to work for both. I am a massive newbie so when explaining please try and keep technical jargon down to a minimum as I probably won't understand it.

2
  • Don't use CPPUnit for .Net apps. Use NUnit. Commented Nov 11, 2011 at 12:46
  • @Merlyn Morgan-Graham Okay thanks for that but it says NUnit is written entirely in C# and I code in C++, will this be an issue. I also am mainly bothered about my MFC apps.
    – bigbaz34
    Commented Nov 11, 2011 at 12:50

2 Answers 2

1

Did you follow this tutorial?

If it is still not working for you, can you please be a bit more specific on what is working for you and what is not? Maybe post the link to the tutorial you are following and where it bugs?

4
  • This is embaressing, I can't even unzip the tar.bz file. How do I go about doing this?
    – bigbaz34
    Commented Nov 11, 2011 at 13:00
  • Which soft are you using? Try with 7zip (sourceforge.net/projects/sevenzip).
    – Tim Bee
    Commented Nov 11, 2011 at 13:10
  • The folder extracted however all the files are non-readable in VS, all the files have the character ,v at the end i.e. ".cvsignore,v".
    – bigbaz34
    Commented Nov 11, 2011 at 13:48
  • Sorted it, I downloaded another version. Thank you.
    – bigbaz34
    Commented Nov 11, 2011 at 14:43
0

There is no installation. The distribution is the source code which must be compiled with the compiler you are using for your C++ work. Setting up CPPUnit (on windows using Visual Studio):

  1. Download latest release of CPPUnit from here
  2. Extract the zip contents (using 7zip or winrar)
  3. Open the Visual Studio 6 workspace file in the examples directory of the extracted folder.
  4. Open file MsDevCallerListCtrl.cpp in the folder srcmsvc6testrunner. Find the following line:

    import "libid:80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2" version("7.0") lcid("0") raw_interfaces_only named_guids

  5. Now do a batch build for all configurations.

  6. Check the lib directory in the cppunit directory. If the files cppunit.lib, cppunit_dll.lib and cppunit_dll.dll are in there.
  7. Go to Tools->Options->Projects and Solutions->VC++Directories
  8. From the dropdown for "Show directories for" choose "Include Files" and add (by clicking in the blank space on the bottom) -> include
  9. Now change the Library files by adding lib
  10. Check that CPPUnit is now running by loading the CPPUnitTestMain project which can be found in the examples folder.
  11. Build and Run without debugging. If the command line appears showing “OK(222)” appears then CPPUnit is now on your machine.

enter image description here

2
  • Thanks for adding almost the exact content of the answer I gave above and unflagging it as accepted answer... O_o
    – Tim Bee
    Commented Nov 18, 2011 at 7:11
  • @Tim Bourguignon Still getting used to how stackoverflow works, my bad. Put your answer back, I just thought I'd clarify the answer in a simple step by step form.
    – bigbaz34
    Commented Nov 18, 2011 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.