ocunit

Imported files not recognized in OCUnit

六月ゝ 毕业季﹏ 提交于 2020-01-13 10:12:12
问题 I am doing unit testing on my iPhone app using OCUnit on XCode 3.2.3, and iOS 4.0. I have successfully set up my testing environment to pass and fail basic tests appropriately, but when I import my own files (in this case, "UserAccount.h", it fails to compile and tells me: "_OBJC_CLASS_$_UserAccount", referenced from: It then says "Symbol(s) not found". This strikes me as some sort of linker error, but I have no idea what's going on. I have built and cleaned all targets numerous times, but to

Imported files not recognized in OCUnit

折月煮酒 提交于 2020-01-13 10:11:05
问题 I am doing unit testing on my iPhone app using OCUnit on XCode 3.2.3, and iOS 4.0. I have successfully set up my testing environment to pass and fail basic tests appropriately, but when I import my own files (in this case, "UserAccount.h", it fails to compile and tells me: "_OBJC_CLASS_$_UserAccount", referenced from: It then says "Symbol(s) not found". This strikes me as some sort of linker error, but I have no idea what's going on. I have built and cleaned all targets numerous times, but to

isKindOfClass and NSStringFromClass disagree about UIApplicationDelegate

笑着哭i 提交于 2020-01-09 19:26:08
问题 I was playing with a simple OCUnit test for an iPhone app, and just wanted to assert that the app delegate was an instance of the class that I expected it to be. I didn't expect this test to be very useful, but it turned out to reveal a misunderstanding that I have regarding Objective C. I first get a reference to the delegate. Then I log the class name of what comes back. In my case, the output correctly says "app delegate's class name is CalculatorAppDelegate". However, the assertion on the

isKindOfClass and NSStringFromClass disagree about UIApplicationDelegate

冷暖自知 提交于 2020-01-09 19:23:46
问题 I was playing with a simple OCUnit test for an iPhone app, and just wanted to assert that the app delegate was an instance of the class that I expected it to be. I didn't expect this test to be very useful, but it turned out to reveal a misunderstanding that I have regarding Objective C. I first get a reference to the delegate. Then I log the class name of what comes back. In my case, the output correctly says "app delegate's class name is CalculatorAppDelegate". However, the assertion on the

iPhone testing: testing IBOutlets

匆匆过客 提交于 2020-01-04 05:53:05
问题 I actually feel a little embarrassed asking this because it feels about as basic as you can go, but it's been stumping me for hours... Let's say I have an instance of a UIViewController (called MyViewController) which simply has one IBOutlet to a UITextField, and when the page loads I either set it to be Enabled or not based on a BOOL property. - (void)viewDidLoad { [super viewDidLoad]; self.surname.enabled = self.allowTextField; } Everything is wired up correctly and when I run the app it

GHUnit error file _OBJC_CLASS_$_SenTestCase", referenced

烂漫一生 提交于 2019-12-31 02:17:26
问题 I'm using GHUnit in my project but when i try to run the app it gives errors Ld /Users/goldfire/Library/Developer/Xcode/DerivedData/WhatsMySpeed-amkgqintxyhelabqvrpouivmdglf/Build/Products/Debug-iphonesimulator/GHUnitTests.app/GHUnitTests normal i386 cd /Users/goldfire/Desktop/Example/WhatsMySpeed setenv MACOSX_DEPLOYMENT_TARGET 10.6 setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:

What is the best approach for writing unit tests for iPhone / iPad?

[亡魂溺海] 提交于 2019-12-30 05:26:08
问题 I am developing an iPad application. I'm not sure if I should write unit tests for this application, and if so, how I should go about writing them. What would you suggest as the best approach to writing unit tests for iPhone / iPad? 回答1: Ok, there are two questions being raised here: Is unit testing worth it? Answer: Definitely. I cannot count the times it has saved me hours of pain and suffering. What's the best way to unit test in the iPhone/iPad environment? Answer: for myself I skipped

Where does OCUnit store NSUserDefaults?

陌路散爱 提交于 2019-12-24 07:09:47
问题 I read the question Easy way to see saved NSUserDefaults? I found the .plist file for the app, but where's the one for the testing bundle? 回答1: If you use Xcode 4's integration with OCUnit, it injects the test bundle into a running application. NSUserDefaults are therefore saved in the application itself. This is problematic for unit tests: When you run the app manually, your defaults may have been overwritten by your tests. Instead of using [NSUserDefaults standardUserDefaults] directly, use

OCUnit Tests giving errors in classes not being tested

元气小坏坏 提交于 2019-12-24 03:41:33
问题 I have written an OCUnit test, which ran fine in Xcode 3.2, and now I'm having problems with it in Xcode 4. It tests a single static function X in class A , which doesn't call any classes or functions (outside of library functions). The only other code that should need to be called is the static constructor, which initializes two static variables, but again, those are hardcode values (arrays) that don't call any other classes, or functions of class A . And yet, I had to include the .m, .mm,

TDD: Unit Testing Asynchronous Calls

夙愿已清 提交于 2019-12-22 14:05:57
问题 guys: I'm working on an application, and building it with unit testing. However, I'm now in a situation where I need to test asynchronous calls. For example, - (void)testUserInfoBecomesValidWhenUserIsBuiltSuccessfully { if ( ![userBuilder userInfoUpToDate] ) { [userBuilder buildUser]; } STAssertTrue([userBuilder userInfoUpToDate], @"User information is not valid before building the user"); } What is the general practice for testing such things? userInfoUpToDate is expected to be updated