ocunit

How do I trap OCUnit test pass/failure messages/events

99封情书 提交于 2019-12-03 12:27:26
问题 I'm trying to use xcodebuild and OCUnit with my Continuous Integration server (TeamCity). JetBrains offers test observer implementations for boost::test and CppUnit that format test output in a way that TeamCity can interpret. I need to do something similar for OCUnit if I want to use it. There appears to be a SenTestObserver class in OCUnit but I'm ignorant of how exactly it should be used, and the OCUnit homepage doesn't seem to provide any documentation on the matter. 回答1: You can write

OCUnit tests to existing iOS project. “ld: file not found”

蓝咒 提交于 2019-12-03 11:19:15
问题 I've been following this blog post: Adding unit tests to existing project. I'm getting this error however: ld: file not found: Build/Products/Debug-iphoneos/MyApp.app/MyApp Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang failed with exit code 1 I have my test target properties, Bundle Loader = $(BUILT_PRODUCTS_DIR)/MyApp.app/MyApp Test Host = $(BUNDLE_LOADER) (which both equate to: build/Debug-iphoneos/MyApp.app/MyApp) My wild guess is that those variables aren't

Unit Testing in With A Static Library

匆匆过客 提交于 2019-12-03 07:23:49
I have an XCode workspace with a user interface project (UI) and a core logic project (Core). I want OCUnit unit tests in the UI project, so I have added a new target for testing, as is commonly done. I am able to run tests just fine until I put in import statements for classes in the main UI target which in turn reference the Core project. The error I get is "Lexical or Preprocessor Issue 'xxx.h' file not found". I do not get this message when I build the main UI target directly. It's as if the main UI target knows about Core when it is built, but when it is referenced from the test target it

EXC_BAD_ACCESS when accessing parameters in andDo of OCMock

不打扰是莪最后的温柔 提交于 2019-12-03 05:26:56
I am trying to write an block of code using OCMock's stub andDo method. In this case UIImageView extension class is being tested. I want to check that the extension calls [self setImage:] with parameter that is non-nil (later other image comparison will be used). When using OCMock's andDo method, the test crashes with EXC_BAD_ACCESS after the block completes. id mockView = [OCMockObject mockForClass:[UIImageView class]]; [[[mockView stub] andDo:^(NSInvocation *invocation) { UIImage *img; [invocation getArgument:&img atIndex:2]; <---- line causing the exception somebodySetImage |= (img != nil);

Xcode 4 unit testing linker error

蓝咒 提交于 2019-12-03 01:44:17
NOTE: "Use GHUnit" is not an acceptable answer to this question. I know most think GHUnit is better than the Xcode4 OCUnit, but that's not what I'm asking about. I'll evaluate that separately. I have an Xcode project that I created in Xcode4 from scratch, with the "Include unit tests" checkbox checked during creation. I have also included some libraries I developed in a previous project. They were added to the project via the "Add Files to x..." dialog and only added to the application target (not the testing target). They work fine when running the application, so I think they're set up

Unit Testing of private methods in Xcode

为君一笑 提交于 2019-12-03 00:18:18
问题 I'm trying out test driven development in a toy project. I can get the tests working for the public interface to my classes (although I'm still on the fence because I'm writing more testing code than there is in the methods being tested). I tend to use a lot of private methods becuase I like to keep the public interfaces clean; however, I'd still like to use tests on these methods. Since Cocoa is a dynamic language, I can still call these private methods, but i get warnings in my tests that

Unit Testing of private methods in Xcode

青春壹個敷衍的年華 提交于 2019-12-02 14:00:40
I'm trying out test driven development in a toy project. I can get the tests working for the public interface to my classes (although I'm still on the fence because I'm writing more testing code than there is in the methods being tested). I tend to use a lot of private methods becuase I like to keep the public interfaces clean; however, I'd still like to use tests on these methods. Since Cocoa is a dynamic language, I can still call these private methods, but i get warnings in my tests that my class may not respond to these methods (although it clearly does). Since I like to compile with no

Apple Mach-O Linker Error using Core Data classes in OCUnit

戏子无情 提交于 2019-12-01 18:19:52
OK, here's my code in my test class: - (NSManagedObjectContext*)managedObjectContextWithConcurrencyType:(NSManagedObjectContextConcurrencyType)concurrencyType { NSManagedObjectModel *mom = [NSManagedObjectModel mergedModelFromBundles:nil]; STAssertNotNil(mom, @"Can not create MOM from main bundle"); NSPersistentStoreCoordinator *psc = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:mom]; STAssertNotNil(psc, @"Can not create persistent store coordinator"); NSPersistentStore *store = [psc addPersistentStoreWithType:NSInMemoryStoreType configuration:nil URL:nil options:nil error

Timed out waiting 120 seconds for simulator to boot

旧巷老猫 提交于 2019-12-01 14:20:03
问题 It looks like Teamcity agent (TC version is 9.0 EAP) can't run iOS Simulator via testing shell script. I am using Build Step: Command Line , which running Custom Script and passing params to it. Teamcity agent was launched on Mac OS X Yosemite 10.10 by using shell script ../bin/mac.launchd.sh . Error from Build Log: [12:33:24][Step 2/2] 2014-11-20 11:33:25.421 xcodebuild[28083:289783] iPhoneSimulator: Timed out waiting 120 seconds for simulator to boot, current state is 1. [12:33:24][Step 2/2

Is it possible to test IBAction?

我的未来我决定 提交于 2019-12-01 05:43:46
It is kinda easy to unit test IBOutlets, but how about IBActions? I was trying to find a way how to do it, but without any luck. Is there any way to unit test connection between IBAction in a View Controller and a button in the nib file? For full unit testing, each outlet/action needs three tests: Is the outlet hooked up to a view? Is the outlet connected to the action we want? Invoke the action directly, as if it had been triggered by the outlet. I do this all the time to TDD my view controllers. You can see an example in this screencast . It sounds like you're asking specifically about the