Re: Arcane BUNDLE_LOADER question
Re: Arcane BUNDLE_LOADER question
- Subject: Re: Arcane BUNDLE_LOADER question
- From: James Bucanek <email@hidden>
- Date: Sun, 10 Dec 2006 10:41:44 -0700
leenoori wrote on Sunday, December 10, 2006:
>Given three components:
>
>1. Main application
>
>2. Unit tests linked against main application using the BUNDLE_LOADER
>build setting
>
>3. A test runner and framework
>
>Is there any way to get the test runner to load the main application
>into memory alongside the test bundle *without* running the
>application? Basically, I would like to know if I can run the unit
>tests without having to launch the application; it seems that
>launching the application is the only way to get it into memory.
You can create an independent test. An independent test contains the unit tests and a separately compiled copy of the code you want to test. The testing framework itself becomes the "application" that gets executed. The framework runs the tests and exits. Your actual application isn't involved.
For dependent units tests, the answer is "not really" for Objective-C applications and "maybe" for C and C++ applications. The answer also depends how you define "launch."
In dependent tests, the application is "hooked" in some way so that control is passed to the unit testing framework very early in the initialization stage of the application. However, the very nature of a dependent unit test dictates that it's still the finished application that is being loaded, so some initialization in unavoidable.
For Objective-C and Carbon applications, the application is hooked by inserting an event that fires as soon as the run loop starts. For Cocoa, this is done automatically; for Carbon it's easy to whip one up.
For C and C++ you have to manually insert some code into main() that tests for the presents of the unit test framework and starts the unit tests. (You can optionally adopt this approach or Carbon apps too) This gives you about as much control over the process as you're going to get. You can intercept the application startup at any point after execution has reached main().
If you define "launch" as "getting to main()," then the answer is "No, you can't run the unit tests until the application is launched."
James Bucanek
____________________________________________________________________
Author of Beginning Xcode ISBN: 047175479X
<http://www.beginningxcode.com/>
_______________________________________________
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