ocunit

Run logic tests in Xcode 4 without launching the simulator

被刻印的时光 ゝ 提交于 2019-11-28 18:15:56
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 driven, and it sends a bunch of events through when it starts up that mess with my tests. Please can

How to run and debug unit tests for an iPhone application

血红的双手。 提交于 2019-11-28 17:18:37
NOTE: Unit testing is a lot easier to setup nowadays. This tutorial is not really relevant for Xcode version 5 and above. It took me quite some time but I finally managed to make it work for my project. To create the "logic" tests I followed Apple guidelines on creating logic tests . This works fine once you understand that the logic tests are run during build. To be able to debug those tests it is required to create a custom executable that will call those tests. The article by Sean Miceli on the Grokking Cocoa blog provides all the information to do this. Following it however did not yield

SenTestingKit in Xcode 4: Asynchronous testing?

吃可爱长大的小学妹 提交于 2019-11-28 16:45:36
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 synchronously) until the tests are completed? FYI, I'm running a test server where I know the expected

Unit Test can't find Core Data model file

人盡茶涼 提交于 2019-11-28 09:48:04
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? Thanks, -Luther Unfortunately, a unit test target does not use the application's main bundle but it creates

Linking error for unit testing with XCode 4?

北城以北 提交于 2019-11-28 05:53:09
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 the only target dependency. I then go to the created tests.m file, import the class I want to test

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

谁都会走 提交于 2019-11-28 03:29:34
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. Testing a delegate is trivial. Just set an ivar in the test in your callback method, and check it after what should be triggering the delegate callback. For

How do you load a prototype cell from a storyboard?

点点圈 提交于 2019-11-27 23:34:14
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. Edit: As far as I know, it's not possible to use prototype UITableViewCells from a Storyboard anywhere other than the ViewController you created it in. I haven't tried this with unit tests yet but you can easily put

How to run and debug unit tests for an iPhone application

落花浮王杯 提交于 2019-11-27 20:09:54
问题 NOTE: Unit testing is a lot easier to setup nowadays. This tutorial is not really relevant for Xcode version 5 and above. It took me quite some time but I finally managed to make it work for my project. To create the "logic" tests I followed Apple guidelines on creating logic tests. This works fine once you understand that the logic tests are run during build. To be able to debug those tests it is required to create a custom executable that will call those tests. The article by Sean Miceli on

Link error while building a unit test target

淺唱寂寞╮ 提交于 2019-11-27 17:35:52
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 header file in this way: #import "../todoro/FRRCategory.h" What am I doing wrong? Joe Make sure that the

SenTestKit: cleaning up after ALL tests have run?

五迷三道 提交于 2019-11-27 14:11:54
问题 I am using SenTest in XCode for my unit tests. I must run a command-line task for my unit tests to test. I can do that in the +initialize method of my test class (subclass of SenTestCase, of course). I would like to terminate the command-line task when the tests are done. Since there's not an opposite of +initialize, I'm stumped. Is there some way to subclass a SenTest class to do this that I'm overlooking? 回答1: Don't run your command-line tool in +initialize. That's sent by the Objective-C