Questions tagged [ocunit]

OCUnit is a unit testing framework for the Objective-C language and included with Apple's Xcode IDE since Xcode 2.1.

OCUnit is a unit testing framework for the Objective-C language and included with Apple's Xcode IDE since Xcode 2.1.

It was created by Sen:te and modeled after the original Smalltalk unit testing framework. In design and use it is similar to classical JUnit, but taking advantage of Objective-C's runtime features to automatically locate tests to run.

263 questions
7
votes
3 answers

OCUnit tests fail from the command line but work in Xcode when using Keychain Services

I'm using SFHFKeychainUtils to use Keychain Services in my app. I've written some OCUnit tests that verify the funcionality of this code. Everything works fine when I run the unit tests from Xcode on the iOS simulator or my device. However now I'm…
7
votes
3 answers

SenTest OCUnit in Xcode 4

I haven't been able to find any up to date info on using the OCUnit tests with Xcode 4, even though it is a redesigned feature. Apples own documentation in the Organizer is from 2005 (OS X 10.3). I thought I just go ahead and try set it up…
RickiG
  • 11,380
  • 13
  • 81
  • 120
7
votes
7 answers

Is it possible to test IBAction?

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?
sash
  • 8,423
  • 5
  • 63
  • 74
7
votes
3 answers

XCode 4 Unit test: Is it possible to ignore certain test cases?

Is there a way of ignoring a specific test case without commenting it out? Some tests are written before the implementation exists, so before commiting any code I'd like to first flag these tests to be ignored so it doesn't appal any of my…
Schoob
  • 1,688
  • 1
  • 14
  • 18
7
votes
3 answers

Unit Testing in With A Static Library

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…
lipidfish
  • 356
  • 4
  • 11
7
votes
2 answers

EXC_BAD_ACCESS using ARC only during testing

I have an issue where I'm getting bad access exceptions but only when running a testing build (calling the same methods in a debug build doesn't cause the problem to come up). The project has ARC enabled and I'm running this on the iPad 5.1…
Mattia
  • 2,251
  • 1
  • 22
  • 27
6
votes
6 answers

OCUnit tests failing, but Xcode Log Navigator says No Issues

Im having a very sneaky issue in Xcode and its "Log Navigator". I've recreated the issue like so; I have a very simple OCUnit test: -(void)testSimpleFailure{ STFail(@"Please fail!"); } I clean my build, I build my test scheme, and run my…
Nick L
  • 145
  • 1
  • 8
6
votes
1 answer

Testing Exceptions using SenTestingKit/OCUnit

The only solution I seem to be able to find for testing for exceptions is using SenTestingKit's STAssertThrows and STAssertThrowsSpecific, however in both cases when the exception is thrown the application under test hangs until I manually ask it to…
Undistraction
  • 42,754
  • 56
  • 195
  • 331
6
votes
4 answers

Xcode keyboard shortcut: jump to test file?

Is there an Xcode keyboard shortcut to jump from MyObject.m to MyObjectTests.m, and vice versa? If so, what is it?
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
6
votes
1 answer

How to run OCUnit logic tests automatically before each build (run) of iOS app in Xcode 4?

It seems that I have everything set up correctly. When I run command ⌘ + U (or select Product > Test from menu) my test runs fine. Best practices should be that test are run as often as possible, ideally during each build (understand during each…
Vilém Kurz
  • 3,401
  • 2
  • 34
  • 43
6
votes
2 answers

Unit Tests for designs that use notifications

I'm having difficulty testing some logic that uses notifications. I've read about enforcing that particular NSNotifications are sent, but that doesn't really address the problem I'm seeing. [SomeObject PerformAsyncOperation] creates an NSURLRequest…
Daniel A. Thompson
  • 1,904
  • 1
  • 17
  • 26
6
votes
4 answers

Using OCUnit to test if an UIAlertView is presented

I'm working on an app that will display a UIAlertView upon hitting it's exit button, only if progress in the game has been made. I was wondering how you would use OCUnit to intercept the UIAlertView and interact with it, or even detect if it has…
wjl
  • 7,143
  • 1
  • 30
  • 49
6
votes
3 answers

Doing a compare of NSArray in ocUnit

I'm new to ocUnit and I'm attempting to compare 2 arrays with the STAssertTrue method and == for equality. The test below simply asks the system under test (sut) for the array in return - (void) testParse { SomeClassForTesting* sut =…
Toran Billups
  • 27,111
  • 40
  • 155
  • 268
6
votes
1 answer

iPhone: Application Testing and Core Location

I'm trying to implement Application Tests as described here. So far, so good, but i fail to test, for instance, the location of the device using Core Location. I have added the appropriate Framework to the Target, and have initiated the update of…
ariel
  • 143
  • 1
  • 7
6
votes
3 answers

OCUnit, NSLog, and XCode 3.1

I'd been using OCUnit (the default installation that comes with XCode) in XCode 3.0. I've been happy being able to run my tests and see the results in the Build Results window, as well as any NSLog() messages I output. However, with XCode 3.1 the…
sehugg
  • 3,615
  • 5
  • 43
  • 60