RickiG
RickiG

Reputation: 11390

SenTest OCUnit in Xcode 4

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.

Upvotes: 7

Views: 5338

Answers (3)

Freeman
Freeman

Reputation: 6216

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

Upvotes: 0

Swift Dev Journal
Swift Dev Journal

Reputation: 20088

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.

Upvotes: 4

RLB
RLB

Reputation: 171

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

Upvotes: 6

Related Questions