Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SenTest OCUnit in Xcode 4

Tags:

xcode4

ocunit

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.

like image 484
RickiG Avatar asked May 27 '11 17:05

RickiG


2 Answers

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

like image 117
RLB Avatar answered Oct 23 '22 03:10

RLB


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.

like image 4
Swift Dev Journal Avatar answered Oct 23 '22 02:10

Swift Dev Journal