1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

CppUnitWithEclipse

From cppunit

Jump to: navigation, search

How to build CppUnit with Eclipse

These instructions describe how to build CppUnit with Eclipse 3.1.1, CDT 3.0.1 under Windows XP using MinGW. The steps to build it with WinXP/Cygwin or under Linux should be very similar, although I haven't tested it.

  • Download the Cpp``Unit distribution file Cpp``Unit-1.10.2.tar.gz and unpack it in a directory of your choice. From now on we will refer to this directory as $Cpp``Unit .
  • Run MSys to open a command line shell, then cd to the directory where you extracted Cpp``Unit and do:

./configure

There's no need to go any further than this with make, make install, etc. All we will need is the header $Cpp``Unit/include/Cpp``Unit/config-auto.h which has been generated in the step above.
  • Go to Eclipse and create a Managed Make C++ Project to generate a library (either static or shared).
  • Import all .h and .cpp files in $Cpp``Unit/src/Cpp``Unit to the project.
  • Open the project properties configuration dialog (Alt + Enter) and add $Cpp``Unit/include to the include path.

Image:Eclipse_Screenshot1.png

  • If you're building a shared library you'll also need to define the variable CPPUNIT_DLL_BUILD.

Image:Eclipse_Screenshot2.png

  • Finally, build the project (Ctrl + B).
  • Now let's create a sample project to test our library.
Create a new Managed Make C++ Project to generate an executable and import the contents of this file into it: attachment:sample_text.zip.
In the project properties configuration dialog:
 # Add $Cpp``Unit/include to the include path.
 # Add the Cpp``Unit library to the project (see screenshot below).
 # If you've built Cpp``Unit as a shared library you'll also need to define the variable CPPUNIT_DLL.

Image:Eclipse_Screenshot3.png

Note that in my system the generated library is at "C:\home_Alex\projetos_eclipse\CppUnit2\Release\CppUnit.dll".
  • By running the executable you'll find out that all tests will pass. You may now play around and introduce errors in the Complex class methods to see Cpp``Unit's diagnostic error messages when a test fails.
  • (optional) The compiler issues several warning messages of ignored pragmas in the Cpp``Unit source. You may edit the source headers and comment those lines if you don't want to be bothered by these warnings in your projects.

Configure a GUI test runner

Now that you've sucessfully set up Cpp``Unit to run from the console, you may wish to build a GUI test runner. Follow these step by step instructions for building QtTestRunnerWithEclipse.

Personal tools