Re: How to step through unit test bundle execution in Xcode 2.1? - RESOLVED
Re: How to step through unit test bundle execution in Xcode 2.1? - RESOLVED
- Subject: Re: How to step through unit test bundle execution in Xcode 2.1? - RESOLVED
- From: Rush Manbert <email@hidden>
- Date: Fri, 08 Jul 2005 11:41:03 -0700
Chris Hanson wrote:
On Jul 8, 2005, at 9:15 AM, Rush Manbert wrote:
Thanks for the reply Chris. However...
What I am developing is a cross-platform static library written in C
++. Since it's not an app, there is no executable. I have a target
that is my unit tester class and if I build it the test gets run
automatically, so all of that mechanism just works. (Or works
fortuitously, despite the fact that I've done something strange.)
It doesn't sound like you've done anything strange, it seems like
you're on the right track.
The automatic execution poses two problems:
1) I don't get an opportunity to setup the environment variables
(although I could modify the script, which is described in the
documentation)
2) Even if I could set the env vars, if I select the unit test
target and open the debugger window, both "Debug" and "Build and
Debug" are disabled.
I guess I can try creating a target that is a dummy app, then just
use it as a vehicle to get to the debugger, but that seems sort of
crude. Any other suggestions?
The automatic execution is handled as part of the build process,
which is why it doesn't give you the opportunity to set up
environment variables (except by adding them to the shell script
build phase) or debug. To debug after a build, your project needs an
executable.
What you'll need to do is create a new custom executable in your
Xcode project, point it at the CPlusTest test rig — the tool that
loads your test bundle and runs it if it's not being injected into an
application — and specify the path to your test bundle as an argument
to the test rig. If you were debugging a framework or a dynamic
library, you'd also have to specify some additional environment
variables for the executable to ensure the framework or shared
library you built is the one loaded.
Here's how to do this:
(1) With your Xcode project open, choose "New Custom Executable" from
the Project menu. Specify an Executable Name of "CPlusTestRig" and
an Executable Path of "/Developer/Tools/CPlusTestRig" (both without
the quotation marks). This will make the test rig available for
debugging. Doing this should bring up the Info window for your new
custom executable; if it doesn't, just highlight CPlusTestRig under
the Executables group and get info on it.
(2) In the Arguments tab of the Info window for CPlusTestRig, add the
path to your test bundle to the "Arguments to be passed on launch"
table. Use a path of the form "$(BUILT_PRODUCTS_DIR)/
YourTestBundleName.cptest" so Xcode will resolve the full path for
you. (More information on the arguments you can pass to CPlusTestRig
is in its man page.) If your test bundle name contains spaces,
you'll need to quote the path.
(3) If you're building a shared library or framework, in the
Arguments tab of the Info window for CPlusTestRig add two entries to
the "Variables to be set in the environment" table with the names
DYLD_FRAMEWORK_PATH and DYLD_LIBRARY_PATH. Set the values for both
entries to $(BUILT_PRODUCTS_DIR). This ensures that the dynamic
loader will load the shared library or framework you just built
instead of any other version you may have on the system.
(4) Choose CPlusTestRig from the "Set Active Executable" submenu of
the Project menu, if it's not already chosen. This is more important
if you have a project with multiple targets, some of which may
generate executables.
(5) Build your test bundle target. Your unit tests should run.
(6) Set a breakpoint in one of your tests, then choose Debug
Executable from the Debug menu. The debugger should come up, it
should run CPlusTestRig, and it should stop at the breakpoint you
just set.
-- Chris
Dude, you rule! That worked beautifully. Thank you very much for the help!
- Rush
_______________________________________________
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