SenTest OCUnit in Xcode 4
Asked Answered
L

3

7

I haven't been able to find any up to date info on using the OCUnit tests with Xcode 4, even though it is a redesigned feature.

Apples own documentation in the Organizer is from 2005 (OS X 10.3).

I thought I just go ahead and try set it up myself.

1: Made a new test target. (TestUnit)

2: Made sure all Base SDK settings in project and targets is set to iOS 4.3.

3: Added a test Class

4: Made sure the framework search path pointed to the framework folder

(4.1?) Manually added the SenTesting framework to my testTarget

When I set my scheme to the "TestUnit iOS 4.3 Simulator" and try and run it an error pop up says "The selected run destination is not valid for this action.".

I have no idea if the above is the correct way to add OCUnit testing to Xcode 4, so if someone has a resource or could point out the steps I would be grateful.

Thank you in advance.

Luvenialuwana answered 27/5, 2011 at 17:44 Comment(0)
B
6

In Xcode 4 'longpress' on the run button until a drop down comes out and select test.

Bulbiferous answered 27/5, 2011 at 20:15 Comment(2)
Thanks RLB, I had apparently done everything right, cause when I started the app as you describe it worked.Luvenialuwana
Even faster: ⌘U (think 'U'nit test)Derayne
P
4

The following steps worked for me to add unit testing to an iPhone project running in the simulator:

  1. Add a Cocoa Touch Unit Testing target to the project. Adding the target added a unit testing class to the project.
  2. Modify the application's scheme to run the unit tests. This involved adding the unit testing target to the Test step of the scheme. I used the application's scheme to unit test instead of the unit test scheme Xcode adds when you add the unit testing target.
  3. Choose Product > Test.

You do not need to add the SenTesting framework to your project. Also, make sure the Test Host build setting is blank if you're unit testing an iPhone app running in the simulator. The simulator does not support application-hosted unit tests.

Panicle answered 27/5, 2011 at 20:37 Comment(2)
Thanks Mark, this serves as a good step by step guide. I wasn't able to find the above anywhere in either Apple docs, in here or using Google.Luvenialuwana
+1: This was a great step-by-step guide, very succinct and got the tests working very quickly for me.Benia
S
0

In addition, to avoid the "The selected run destination is not valid for this action" message when you are in the UnitTest target, open its Biuld scheme and select Run

Seraphic answered 20/10, 2011 at 7:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.