Posted by: wbailer | August 27, 2007

Mac OS X Framework for CppUnit

The C++ unit testing framework CppUnit can be built on many Unix-like platforms, thus also on Mac OS X. However, to make usage in C++ based Xcode projects more convenient, I’ve created a Xcode project that builds a Carbon framework.

The project is based on CppUnit 1.12.0, made with Xcode 2.4 and build universal binaries for Mac OS X 10.4 (Tiger). The limitation is that the graphical test runners are currently not supported, however this should be possible at least for the Qt test runner.

The framework project is available here, the framework binary package (including the header files) is available here.

Advertisements

Responses

  1. Thank you! Thank you! Thank you!

    I’ve been meaning to do this for a while. I just sat down at lunchtime today to start the process, but decided to do another google search on “Xcode cppunit” first. Thanks again.

    Any chance of taking the next step and submitting it to the cppunit maintainers?

    Regards,
    -Steve

  2. Hey there.

    Just another word of thanks…good work…very useful for us Mac heads doing cross-platform development.

    I took your framework and amended it slightly since it didn’t build straight from the source without running configure first. I didn’t want to do this and commit the config files to my SCM because they will be different for different users building.

    To solve the issue I added a new build phase before everything else that runs this script to generate local configuration files needed to do the rest of the build. Let me know if you want me to send you the updated project. There is a small patch to the configure script as well.

    Thanks again!

    Jamie

  3. Hey!

    Thank you so much! I also started porting, but then decided to do a quick google search.

    I felt that built-in xcode unit testing was quite limited.

  4. In the xcode project, I changed :
    INSTALL_PATH = “$(HOME)/Library/Frameworks”;
    with
    INSTALL_PATH = “@rpath”;

    as explained here :
    http://www.codeshorts.ca/tag/osx/

    This allows to place the framework in other places
    than the standard path …

  5. There is one rather serious bug in the binary distribution: because the Installation Directory in the Xcode project was set for $(HOME)/Library/Frameworks, it will only work if installed in /Users/ftt/Library/Frameworks — ftt being, I presume, the login under which it was built. Simply building it from source provides little relief, since the new binary will demand to be installed under the current user’s home directory.

    In order to fix the bug:

    1- Download and open the Xcode project (don’t forget to separately download and include CppUnit’s source);

    2- Right-click the “cppunit” build option and select “Get Info”;

    3- Locate the “Installation Directory” option and set it to something more sensible (say, /Developer/Library/Frameworks, since it is meant to be used during development only?);

    4- Clean and rebuild.

    To check whether the bug was fixed, open a terminal window, navigate to build/Release/cppunit.framework under the project tree and type this command:

    otool -L cppunit

    A list of directories is printed, the first of which should be something like:

    /Developer/Library/Frameworks/cppunit.framework/Versions/A/cppunit (compatibility version 1.0.0, current version 1.0.0)

    At any rate, there must be no trace of the current user’s home diectory in the output to the above command.

    Between this bug and Jamie’s amendmet to the build process, perhaps an updated version is in order?

  6. Thanks a lot for your comments. I’ve finally had time to create a new version that uses the solution suggested by r2d3: see this post.

  7. Hi

    I am using cppunit.framework in a carbon target. However, I get compiler error in my test classes like: syntax error before ‘CppUnit’.

    The symbol CPPUNIT_NS_BEGIN and all the likes are undefined?

    I have added cppunit.framework binary version from above. But I use the header files from sourceforge site, due to config-auto.h is missing.

    Well, I am a bit confused.

    Suggestions are very welcome. THX

    Suggestions are very much welcome


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: