Re: Target setup for unit testing (using cppunit)
Re: Target setup for unit testing (using cppunit)
- Subject: Re: Target setup for unit testing (using cppunit)
- From: Stefan van den Oord <email@hidden>
- Date: Fri, 25 Nov 2005 10:48:23 +0100
Thanks for your explanation, James! This indeed seems the way to go.
After reading your message, I have some additional questions which I
hope you can answer:
1) The unit test bundle, what kind of target is it? Is it the Xcode
"Carbon Unit Test Bundle", or is it a normal "Loadable Bundle" or
"Framework"?
2) How do I link the test bundle into my application? Is it sufficient
to add it by checking its check mark in the project window?
3) I tried using a "Carbon Unit Test Bundle". If I do that, I get tons
of link errors on the test bundle, because it needs symbols that are
in the other target (the application). To me it seems normal that the
symbols aren't there yet, because they will be when the bundle is
linked into the application. Am I missing something?
Thanks!
Stefan
On 11/21/05, James Bucanek <email@hidden> wrote:
> Stefan van den Oord wrote on Monday, November 21, 2005:
>
> >Dear list members,
> >
> >We have a multi-platform C++ project. On the Mac, we use Xcode for
> >development. Because it's multi-platform, there is no carbon or cocoa
> >involved. For unit testing, we use cppunit (cppunit.sourceforge.net),
> >which works ok for us.
> >
> >My question is about how to properly set up my targets, so that unit
> >tests get automatically run after each build, but sources are compiled
> >only once (compiling takes way too much time to do it more than once).
> >
> >I have tried several things, but I run in all kinds of trouble ranging
> >from multiple compilations to unresolved symbols.
> >
> >Can you please advise on the right way to set this up?
>
> I have no experience with cppunit, but I can provide some general advice based on the way that C++ unit tests in Xcode 2.1 are constructed. I'll assume that cppunit works in a similar fashion.
>
> What you are talking about is a "dependent" unit test. The unit test bundle contains only the code for the test. The actual code to be tested is in your application binary. At build time, your source code is compiled once (for your application), and the test code is compiled separately. The tests are run by loading your application into memory using a special environment or some support code that prevents it from running normally, the test bundle is also loaded, the symbol referenced in the test bundle are linked to the actual code in your application, and the tests are run.
>
> How your application code and test bundle get loaded into memory will depend on how cppunit works. You'll have to read up on it to find out what it expects and then construct the custom script phase of your unit test target to do whatever it is that needs to be done.
>
> As for the undefined symbols, this bites a lot of people -- it bit me -- using C++. You have to set the "Symbols Hidden by Default" (GCC_SYMBOLS_PRIVATE_EXTERN) build setting to NO. The linker normally hides (removes) all symbols in an application which are resolved at link time. The result is that all of the functions you define in your application are hidden from the dynamic linker. You also have to include your application's binary as a "library" when building your unit tests. Otherwise, your application doesn't declare any of the functions it defines and your unit test code has nothing to link to (either at link or run time).
>
> Of course, you'll want to have this setting turned on for the shipping version of your app.
>
> --
> James Bucanek
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden