Tag: unit testing

How do I wait for an asynchronously dispatched block to finish?

I am testing some code that does asynchronous processing using Grand Central Dispatch. The testing code looks like this: [object runSomeLongOperationAndDo:^{ STAssert… }]; The tests have to wait for the operation to finish. My current solution looks like this: __block BOOL finished = NO; [object runSomeLongOperationAndDo:^{ STAssert… finished = YES; }]; while (!finished); Which looks […]

Error compiling for unit test using google toolbox for mac

Hi my application runs fine but when I try to run the unit tests I am getting this error… 2010-10-19 00:27:49.919 AssignmentUnitTest[27988:903] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘*** -[NSURL initFileURLWithPath:]: nil string parameter’ Irony is I have searched the whole project & I dont have any similar line of code that […]

Running Xcode unit tests during release build

I have a number of logic unit-tests (where my project files have a target membership of the App and AppTests). I want to add a call to xcodebuild test-without-building to my build system so that my unit-tests run for each build. However, the tests cannot run on the release build (because release doesn’t build for […]

OCUnit will not allow me to use my own data types

I am using XCode 3.2.2 to unit test some custom data types. The tests run properly without those data types, but when I use said data types, I get this error: “_OBJC_CLASS_$_classname”, referenced from: (where “classname” is the, well, class name…) I have seen hints online that it could be linker related. The strange thing […]

Adding Logic Tests to the project in Xcode 4.5

I’m using xcode 4.5 and trying to add logic tests to the project. (This is actually a test, newly created project without unit tests). I’m following this guide: http://developer.apple.com/library/mac/#documentation/developertools/Conceptual/UnitTesting/02-Setting_Up_Unit_Tests_in_a_Project/setting_up.html So, what i’ve done so far: Created a new project (View Based Application template) Click on File -> New- CocoaTouchUnitTestBundle That’s it. The tests (as documentation […]

Export unit test result into a file with Xcode

Is there a way to automate the saving of the unit test results in Xcode? I’d like to save them into a folder each time I run them thx

OCUnit Tests giving errors in classes not being tested

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 […]

Is it possible to unit test a WindowController thats initialised with a nib?

I have a simple Mac OS application that comes with the default MainMenu.xib. In there I have a second window for preferences and a PreferencesWindowController. I’d like to get the following test working: @implementation TestPreferencesWindow – (void)testProtectsUserPasswordByUsingAPasswordField { PreferencesWindowController *controller = [[PreferencesWindowController alloc] initWithWindowNibName:@”MainMenu”]; XCTAssertInstanceOf([[controller passwordField] class], NSSecureTextField); } @end The problem is that [controller […]

What is the proper way to configure googletest with Xcode 4?

I am following the instructions located at http://code.google.com/p/googletest/wiki/XcodeGuide to set up googletest to work with Xcode. However, these instructions seem to be written for Xcode 3. Many things that this article mentions have changed in Xcode 4. What is the proper way to get google test to work with Xcode 4?

UIKit and unit testing

I’m tying to implement some test cases for my iPhone app. I have successfully set up the UnitTest-Target as described here: iPhone development guide I’m also able to build a simple test case: – (void) testPass { STAssertTrue(TRUE, @””); } But when I’m trying to instantiate a class that has some methodes that return UIColors […]