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: James Bucanek <email@hidden>
- Date: Fri, 25 Nov 2005 09:42:36 -0700
Stefan van den Oord wrote on Friday, November 25, 2005:
>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"?
The "Carbon Unit Test Bundle" is just a template that creates a "Bundle" target, preconfigured to be used as a unit test bundle. Of special interest is the addition of the Run Script phase at the end of the target that runs the tests.
You could easily create any kind of "Bundle" target type and configure it for your needs, but I'd start with a target created from the Carbon Unit Test Bundle template and modify that.
>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?
The symbols in your application need to be accessible to the tests in your unit test bundle both at link-time and at run-time.
You "link" your test bundle to your application by treating it like framework. In the Other Linker Flags build setting for you test bundle, add your application's binary to the list of frameworks:
OTHER_LDFLAGS = -framework Carbon -framework YourApplication
So that the internal symbols in your application are visible both at link-time and load-time, you need to suppress ld's habit of hiding all of the symbols defined by your application:
GCC_SYMBOLS_PRIVATE_EXTERN = NO
Note that the above setting is set for you application, not the bundle. We don't care if the symbols in the test bundle are visible. It's the bundle that needs to see the symbols in your application.
Naturally, your unit test bundle should be dependent on your appliaction target to ensure that it's built and up-to-date before the unit test target tries to link to it or test it.
--
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