views:

574

answers:

2

XCode 3.1.2 using built-in OCTest unit testing.

I'm getting a crash when unit tests run. I want to run w/ a few extra environment variables (MallocCheckHeapStart, MallocCheckHeapEach, for example).

I'm a beginner with this and can't figure out how to run my app's OCTest unit tests from the command-line. Or alternatively, to convince XCode to set a few extra environment variables when it launches the unit tests.

+2  A: 

This is a very useful post about debugging OCUnit tests.

http://chanson.livejournal.com/120740.html

kperryua
I got the OCUnit tests running with the info in this article. Ended up with the four environment variables he described. Needed to target my unit test classes to the executable (had only targetted them to the Unit test target previously). Not sure if that's something that needs undoing for release builds...
John M
A: 

In your Project, find the Executables group in the Groups and Files list. Expand that to reveal your executables. Find the executable that you're testing (most likely it's your active executable) and double click on it. This will bring up an information window on that executable. This window has four tabs. We want the second one, titled "Arguments". Go there.

In the Arguments tab, there are two sections: "Arguments to be passed on launch" (command line arguments) and "Variables to be set in the environment". Use the + button underneath the appropriate section to add arguments and environment variables to your heart's content.

Dave DeLong
That doesn't help with a unit test bundle, which isn't an executable at all. The tests run when you *build* the target.
Peter Hosey
@Peter Hosey - good point. However, if you create an executable to run otest, and run *that*, this should work just fine.
Dave DeLong
I tried the arguments tab/variables to be set and found what @Peter Hosey mentions. I found reference to otest and tried to run it from the command-line ouside of XCode (where I could set any environment variables I wanted). Any guidance on that would get me going.
John M
@John M: Chris Hanson's livejournal has a page on setting up the custom otest executable: http://chanson.livejournal.com/119578.html
Dave DeLong