unit test + snow leopard + xcode 3.2.2 - iphone

I have been trying to set breakpoint in my unit test code using SenTestCase framework in xcode 3.2.2. I can see the build results properly but unable to set a breakpoint.
Anyone having an idea please help.

Take a look at Matt Gallagher's sample iPhone app with unit tests, particularly the section titled "Debugging setup for the LogicTests target". The setup is a bit involved, but will save you a ton of time over the long run.
Additionally, this article has some examples of common errors you may run into in the process, and how to fix them.

Related

How do I get code coverage for tests and build for iPhone in Xcode 4?

I have a couple of projects with unit tests where I want to measure coverage. So I follow the instructions detailed in the How-to for CoverStory and elsewhere on the web.
I add -fprofile-arcs and -ftest-coverage to my test target and the target under test and link to /Developer/usr/lib/libprofile_rt.dylib as specified.
And it works! When I run the tests scheme under the iPhone simulator, I get my code coverage, my tests and app build and run.
But then, when I go back to the Run scheme on actual iPhone hardware, I get a link error for libprofile_rt.dylib. Specifically, I get
ld: library not found for -lprofile_rt
What I suspect here is that libprofile_rt is actually a library for Mac hardware and the iPhone obviously can't link to a binary built for Mac, in general.
My question is How do run on iPhone hardware and get my code coverage?
I suspect I can do this with a copy of my Debug target that is only ever used for testing, but that has the additional trouble of maintaining yet another target. Is there any other way to get this working? Am I doing something silly?
might a little bit late but actually you can. it is explained in this presentation, slides 32 to 34.
took me a fair amount of time to find this hidden gem. hope this might help future visitor of this page.
Possible answer to this problem is here: https://stackoverflow.com/a/5140459
The trick is to get the *.gcda files out of the App's Documents directory via Xcode organizer, since they will, of course, be generated on device.
The answer is: you can't run on your device AND get coverage at the same time. The only way to get coverage is on the simulator: make a copy of your debug target, setup coverage and what not on that target and run that target, with your tests, in the simulator.
I go through all the details in an answer to this question on stackoverflow: Code coverage on iOS Using Xcode 4.2 on Lion

Quickly testing iOS and objective-c code

I was wondering if is there any way to quickly check iOS/objective-c snippets or new code inside my xcode project without having to compile the whole app for that, open up the simulator just to get the NSLog message traced on the console.
I remember when life was easier using ruby's irb or node command for node.js :)
It just gives me the impression that on iOS development you have to learn how to deal with this high complexity and dependencies all the time, but I am just starting on this new world. so any help would be appreciated.
thanks a lot
This timely blog post should help; I'm using it often already.
Update: there is also Code Runner available in Mac App Store - this supports many languages, including Objective-C.
An Xcode project can contain multiple targets. One of the targets can be a test driver in which you can put some class/object/snippet exercise code and drive it from the command-line, results to the debug console. Another option is to create unit test targets.
If the code you're writing has known expected input-output pairs and you're just writing code to make them work, you may want to look into using XCode's unit testing capabilities. A link to a tutorial on using unit tests is at http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/UnitTesting/0-Introduction/introduction.html . If you want to test more interactive things, it is possible to use Instruments (a program in XCode) to automate those tests as well using the Automation instrument. A guide on using Instruments is available at http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/AboutTracing/AboutTracing.html .
Not really—Objective-C is a compiled language, while I believe Ruby is interpreted (which allows for interactive testing like what you describe). You can reduce some of the overhead of building and running your project by just leaving the simulator open; stopping the app from Xcode will close the app but leave the simulator running, meaning that a rebuilt version of the app will launch more quickly when you run it.

Will old source code run with SDK 4.2?

I've been working on creating my own iPhone app with source code my company gave me. This code was created with iPhone SDK 3.0. I've worked on it for over a year (I'm a designer so my coding is mostly copy and paste) and to test the app on my iPhone it says I must update my SDK to 4.2. I'm wondering will this break my app? I probably don't have the skills in xcode to upgrade my code if I am required to rewrite parts.
Thanks,
Chris
If none of the code has been deprecated, changed or even removed, chances are good it still runs fine. Most projects run, and if you have used external code (and hopefully noted where you got it from) there might be an update available for that piece of code.
Just set the deployment target to iOS 3.0 in your project settings
here some little explanation: link

automated unit test case for iphone

for last three days i am trying to create unit test case using OcUnit. but not succeed yet . every time i google i get new tutorial with different configuration. and apple tutorial is the only which worked in xcode 3.2.5 . plz if any one know step to create logic test as well as application test please let me know .
Apple's approach forces you to make an artificial and unnecessary distinction between "logic tests" and "application tests". It also makes debugging a real pain.
For iOS unit testing, try GTM or GHUnit instead.
Update: Xcode 4 changes everything. I now use the built-in OCUnit for iOS unit tests. See Xcode Unit Testing: The Good, the Bad, the Ugly
i use GHUnit, is a test framework for Objective-C, you can follow the instruction on the GHUnit page or see the video TDD for iPhone Development , GHUnit it's easy to use and very helpful.
hope this help.

UnitTesting on iPhone doesn't build

I am trying to perform some unit testing on the iphone but for some reason I cannot get it to build the executable
I have downloaded TestMyApp from the Standford lecture slides and that compiles and runs perfectly. I have created a test project and even gone as far as to use the test code from the Stanford sample but for some reason depsite every setting looking identical I get the following precompiler errors:
/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:13:26:
error: AppKit/AppKit.h: No such file
or directory
/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:14:30:
error: CoreData/CoreData.h: No such
file or directory
N.B> Only other point to note is that Im running it on a "tweaked" xcode install on a PPC not an Intel mac
If you right click on your unit test target and select the "get info" menu you will see your target options.
At the bottom of the pane, you'll see a section called "User Defined": remove the entry containing the path to cocoa.h.
I don't remember the name of this entry as I removed it, but this fixes the same problem I had before.
I also changed Base SDK to be Device - iPhone OS 2.2
and other linker flags to -framework Foundation -framework SentestingKit
AppKit is not available for iPhone development. Looks like you downloaded a desktop mac app project. iPhone dev uses UIKit in place of AppKit.
CoreData is not available for iPhone dev as well.
Try setting up a Desktop cocoa application, and these frameworks and objects should be available.
For unit testing an iPhone app, the Google Toolbox for mac is useful.
GTM iPhone docs
You can find instructions and a sample project on Sen:te web site: http://www.sente.ch/s/?p=535&lang=en
I had to remove the value for GCC_PREFIX_HEADER in the "User Defined Section". It was using
$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h
Once I removed that, I got past this problem.
Do you have the iPhone SDK 2.2 installed? Without using the GTM for iPhone, OCunit doesn't work with iPhone SDK < 2.2.
I have been working with the Stanford example code as well. When I try to set up my own project, I wasn't able to get my tests to run. So, I took the Stanford example projects and renamed everything. Now the OCunit testing is working fine.
Do not use the Sen:te thing for testing any classes that make use of the UIKit framework. It will fail with code 139. Use Google's GTM.