ocunit

Run logic tests in Xcode 4 without launching the simulator

孤街醉人 提交于 2019-11-27 11:10:41
问题 I want to run tests in Xcode 4 using OCUnit without launching the simulator. Please, don't try and convince me I am doing unit testing wrong or anything like that. I like to do TDD the traditional way: write the API for the class in the tests, then make the class pass the tests. I will write separate tests that are end-to-end that run in the simulator. If there's no way to do this, then please can someone tell me how to have the test harness not instantiate the whole app? My app is event

SenTestingKit in Xcode 4: Asynchronous testing?

亡梦爱人 提交于 2019-11-27 09:53:57
问题 I have been searching for a way to use SenTestingKit to do some integration testing between my client-side code and our server. I haven't had any luck. It seems that once the code is run in a method, the object gets destroyed. This means that any asynchronous responses never call the selectors. Questions: Is there a way to keep the object instantiated until such time as I see fit to destroy it - ie. after the tests have completed? If not, how could I create a class that blocks (ie. acts

isMemberOfClass returns no when ViewController is instantiated from UIStoryboard

孤街醉人 提交于 2019-11-27 09:09:48
I have an OCUnit Test class: PatientTestViewControllerTests. Below is the interface: @interface PatientTestViewControllerTests : SenTestCase @property (nonatomic, strong) PatientTestViewController *testController; @end and setUp: - (void) setUp { UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Testing" bundle:nil]; self.testController = [storyboard instantiateInitialViewController]; } The 'Testing' storyboard is the only storyboard in my app, and is set as the app's main storyboard. The PatientTestViewController is set as the storyboard's only view controller. I have one test in

Xcode 4: Run tests from the command line (xcodebuild)?

落花浮王杯 提交于 2019-11-27 06:03:09
I've created a brand new iOS project in Xcode 4, and included unit tests. The default app has 2 targets, the main application and the unit test bundle. Using "Product > Test" (Command-U) builds the application, builds the unit test bundle, launches the iOS simulator and runs the tests. Now I'd like to be able to do the same thing from the command line. The command line tool (xcodebuild) doesn't have a "test" action, but it seems like I should be able to build the unit test bundle target directly, since it depends on the application itself. However, running: xcodebuild -target TestAppTests -sdk

Linking error for unit testing with XCode 4?

萝らか妹 提交于 2019-11-27 05:36:29
问题 I want to write some logic unit tests for classes in my XCode application. In Xcode 4, I clicked on the project name in the Project Navigator, and from the bottom clicked Add Target. I chose "Cocoa Touch Unit Testing Bundle" under Other, give the new target a "product name" of "tests", and finish. Because the class I want to test is compiled as part of my existing application target, for my new "tests" target I immediately go to the Build Phases tab and add my existing application target as

Unit Test can't find Core Data model file

痞子三分冷 提交于 2019-11-27 03:19:44
问题 I've created a project with a Core Data model in it. The application looks for the model file (.momd) and runs just fine. Unfortunately, the unit test keeps returning null: NSURL *dataModelURL = [[NSBundle mainBundle] URLForResource:@"myDataModel" withExtension:@"momd"]; I can see the myDataModel.xdatamodeld folder and file in BOTH the main target and the unit testing target's Compile Sources directory - but that doesn't seem to be enough. What else am I missing in the unit test target?

OCUnit test for protocols/callbacks/delegate in Objective-C

丶灬走出姿态 提交于 2019-11-27 00:04:11
问题 Using OCUnit, is there a way to test delegate protocols? I'm trying this, which doesn't work. -(void) testSomeObjDelegate { SomeObj obj = [[SomeObj alloc] initWithDelegate:self]; [obj executeMethod]; } -(void) someObjDelegateMethod { //test something here } I'm going to try calling the obj method on a different thread and have the test sleep until the delegate is called. It just seems like there should be an easier way to test this. 回答1: Testing a delegate is trivial. Just set an ivar in the

Link error while building a unit test target

ε祈祈猫儿з 提交于 2019-11-26 19:05:43
问题 I have a XCode4 / iOS project with a regular target and unit test target. Everything works fine, except when I try to #import one of my classes in my test class and try to use it. If I try to build the unit test target, I get the following link error: Undefined symbols for architecture i386: "_OBJC_CLASS_$_FRRCategory", referenced from: objc-class-ref in CategoryTests.o ld: symbol(s) not found for architecture i386 collect2: ld returned 1 exit status In CategoryTests.m I'm importing the

How do you load a prototype cell from a storyboard?

删除回忆录丶 提交于 2019-11-26 16:54:09
问题 Is there a way to load a prototype cell, along with any IBOutlet connections as defined within a storyboard? Update I want to unit test the cell (a UICollectionViewCell for that mater), hence would like to load it outside of a UIViewController context. Effectively, in the same way that you can load a custom view from a nib, specifying its file's owner and have its IBOutlet(s) set. 回答1: Edit: As far as I know, it's not possible to use prototype UITableViewCells from a Storyboard anywhere other

isMemberOfClass returns no when ViewController is instantiated from UIStoryboard

只愿长相守 提交于 2019-11-26 14:32:58
问题 I have an OCUnit Test class: PatientTestViewControllerTests. Below is the interface: @interface PatientTestViewControllerTests : SenTestCase @property (nonatomic, strong) PatientTestViewController *testController; @end and setUp: - (void) setUp { UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Testing" bundle:nil]; self.testController = [storyboard instantiateInitialViewController]; } The 'Testing' storyboard is the only storyboard in my app, and is set as the app's main