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
1
vote
0 answers

Adding OCMock to a framework

A bit of background first, I am currently writing some ocunit tests for a universal framework, and now need to add OCMock to test some networking aspects of the framework. I have followed the OCMock instructions here and downloaded the sample…
ChrisH
  • 285
  • 3
  • 13
1
vote
2 answers

why can I not just pass an int or bool directly into the OCMock's "andReturnValue" argument?

I was trying to do: [[[mockQuestion stub] andReturnValue:YES] shouldNegate]; [[[mockQuestion stub] andReturnValue:123] randomNumberWithLimit]; But that gave me this warning/error "incompatible integer pointer conversion sending 'BOOL' (aka 'signed…
patrick
  • 9,290
  • 13
  • 61
  • 112
1
vote
1 answer

iOS Application Test static library initialization

I'm trying to write tests for an iOS app with a legacy C++ library dependency. The legacy library has initialization routines and static variables that must be run/set once per app cycle. I've created a test target that is working correctly. My test…
HatAndBeard
  • 1,416
  • 3
  • 18
  • 31
1
vote
1 answer

OCUnit tests alway pass if they contain a method named 'name'

Esteemed OCUnit testers, OCUnit tests always pass if they contain a method named 'name', e.g: #import @interface Tests : SenTestCase @end @implementation Tests - (NSString *)name { return @"Howard"; } -…
Howard Lovatt
  • 968
  • 1
  • 8
  • 15
1
vote
1 answer

Unit Testing with Core Data objects in XCode 4.5 using OCUnit in iOS-Development

Is there a simple way out there to create NSManagedObjects for testing reasons without to use the managed object context created for the release Application? I'm now into Core Data coding for a couple of weeks but still having some issues in the…
CGee
  • 1,650
  • 5
  • 20
  • 31
1
vote
1 answer

OCUnit or OCmock testing methodology for locally instantiated and scoped variables.

I am new to OCUnit and OCMock and would like to learn more about this testing methodology. I am aware of OCUnit and OCMock's capabilities to create stubs generate mock object etc... I have a particular use case that I have not been able to crack…
narcolepsy
  • 21
  • 2
1
vote
1 answer

When if ever will a property of type NSString be [NSNull null]

I'm parsing some json to return a basic string token or error message. - (void)callBackWithVerifyHttpResponse:(NSData *)response { SomeResult *result = [self.parser parseVerifyHttpResponseAndReturnResult:response]; if (result.token) {…
Toran Billups
  • 27,111
  • 40
  • 155
  • 268
1
vote
0 answers

Auto generate OCUnit test files from existing classes.

I would like to ask if there is a process or a tool out there that can help me with parsing header and/or implementation files in objective-c (Xcode) to isolate properties and method names to help automatically generate OCUnit Test header and…
narcolepsy
  • 21
  • 2
1
vote
2 answers

How to share code among several OCUnit test cases?

Is there any way to share code among several OCUnit test cases? Maybe I'm missing something obvious, but I haven't been able to do it... I have tried to put the common code in another class, but it seems you can only use STAssertxxx macros inside…
jgongo
  • 41
  • 4
1
vote
1 answer

How to make Xcode to stop at exception on test code?

When I testing my code with OCUnit, it makes exception log and makes it fail, but never stop when the exception raises. Even the breakpoint doesn't work. I want to track the stack and see the state at the time of exception, but debugger doesn't pop…
eonil
  • 83,476
  • 81
  • 317
  • 516
0
votes
1 answer

OCUnit - iOS 5 - How do I test files in my app?

I am trying to build simple tests to see if files I need (images, videos, audio files) are in my app. Whenever I try to do something such as: if (![[NSFileManager defaultManager] fileExistsAtPath:@"Menu Loop.mp3"]) { STFail(@"File does not…
Will
  • 1,697
  • 17
  • 34
0
votes
4 answers

How to stub out the return value on a class based method using ocmock

I'm writing a test to verify location services are started when a button click occurs. This requires a very simple if statement to make sure the phone has location services available. A working test right now looks like this -…
Toran Billups
  • 27,111
  • 40
  • 155
  • 268
0
votes
1 answer

OCUnit application testing: Trying to test UIPageControl numberOfPages == NSArray count

I'm relatively new to OCUnit and OCMock so please bear with me. I have a view controller which contains a UIPageControl where the number of pages is calculated from the count of an NSArray (which is populated from Core Data). This is done in the…
0
votes
1 answer

ios: OCUnit STAssertEquals -> Type missmatch

I wrote a unit test for my code. The code looks like the following: bool result = [t1 isSimilarToTransaktion:t2]; if( result ) NSLog(@"YEAH!!!!"); STAssertEquals( YES, result, @"Not equal" ); Actually I checked that in this particular case…
toom
  • 12,864
  • 27
  • 89
  • 128
0
votes
2 answers

Why is this first OCUnit unit test passing?

It should fail, but it's passing. So I assume my syntax is wrong somewhere (although it builds). #import @interface FirstCocoaLibrary : NSObject -(int)AddFirstNum:(int) i1 withSecondNum:(int) i2; @end #import…
Mark W
  • 3,879
  • 2
  • 37
  • 53