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

Customizing SenTest/OCUnit

From time to time, I have the impulse to modify some aspects of the Mac/iOS unit testing framework. I wouldn't want to sacrifice its nice integration with XCode, but at times I find myself hankering to change some details: Send messages to a…
Mark Bernstein
  • 2,090
  • 18
  • 23
1
vote
2 answers

Exception raised for the setup and teardown OCUnit test case

- (void)setUp { [super setUp]; @try { [Problem setupProblem]; } @catch (NSException *exception) { NSLog(@"exception Caught %@: %@", [exception name], [exception reason]); STFail(@"Should Pass, no exception is…
Kiran
  • 345
  • 1
  • 4
  • 16
1
vote
0 answers

how to write Test case for NSNotification for onWillEnterForgroundNotification

How to write ocUnit test case notification when application enter foreground -(void)onWillEnterForgroundNotification:(NSNotification)notification{ [self message:@"Hi" Value:@"G"]; } @All Any one advice me how to implement the test case for the…
kiran
  • 4,285
  • 7
  • 53
  • 98
1
vote
1 answer

Unit tests throw error when simulator is in SDK 5.1

My unit tests run fine when the target is set to 6.1, and the code itself is fine when I walk through the features in the simulator. I think the problem is that the unit tests are expecting the 6.1 SDK to be there, but it's actually using the 5.1…
Luke The Obscure
  • 1,524
  • 2
  • 20
  • 35
1
vote
2 answers

CLLocationManager and unit testing

I have been trying to add some (logic) unit tests to my code recently. I've set up the tests with Kiwi, I like the BDD style and the syntax. My problem now is that I'm trying to test some code that relies on CLLocationManager sending a correct…
DaGaMs
  • 1,521
  • 17
  • 26
1
vote
2 answers

Pending OCUnit tests

Is there any way to denote a pending test using OCUnit? Of course, I could do something like: STFail(@"pending test"); However, it becomes all too easy to see a failed test run and assume that it's my pending test. I'm looking for some way to…
GarlicFries
  • 8,095
  • 5
  • 36
  • 53
1
vote
1 answer

OCUnit crashes when creating UITextView

Unit testing is handling out humble-pie by the bucketload here at the moment. I am trying to run tests on my BannerAdViewController-class, but everything comes tumbling down when reaching the following line: UITextView *buyAppTextView =…
T. Benjamin Larsen
  • 6,373
  • 4
  • 22
  • 32
1
vote
1 answer

Why is my class crashing my OCUnit test case with error code 138?

A class I wrote is crashing my test case with error code 138. The class returns an NSString with the user agent string from UIWebView: @interface MyWebViewUserAgent : NSObject { NSString* userAgent; UIWebView*…
1
vote
2 answers

Functional testing cocos2d application

I'm writing Cocos2d application and looking for a way to write functional tests. What I really need, is to launch application on the simulator and check that my scene contains specific nodes. Something like this @implementation MenuTest - (void)…
lambdas
  • 3,990
  • 2
  • 29
  • 54
1
vote
1 answer

How to compare NSNumber with a decimal value?

I recently upgraded from iOS 5 to iOS 6 and found this unit test was failing - (void)testCalculatesDistanceBetweenTwoPoints { self.sut = [[DistanceCalculator alloc] init]; CLLocationCoordinate2D start = {.latitude = 34.32, .longitude =…
Toran Billups
  • 27,111
  • 40
  • 155
  • 268
1
vote
2 answers

isMemberOfClass doesn't work as expected with ocunit

Possible Duplicate: 'isMemberOfClass' returning 'NO' when custom init I've some trouble with the "isMemberOfClass"-Method. I have a class, that generates and returns objects ("MyObject") //…
matrau
  • 148
  • 1
  • 9
1
vote
0 answers

How to unit test the background image is set for a given UITableView

I'm using ocunit and I'm trying to verify I set the background image on a UITableView In the test below my assertion is failing - (void)testNumberOfRowsInSectionSetsBackgroundViewOnTableView { UIImageView *expectedBackground = [[UIImageView…
Toran Billups
  • 27,111
  • 40
  • 155
  • 268
1
vote
1 answer

XCode OCUnit crashes with Abort trap: 6 before any test code is run

I have the following stupidly simple test case (defined in a .mm file with correspong .h file). It uses boost to try to read in a ptree from a stringstream to simulate the text that would be in a file. -(void)setUp { printf("setup\n"); …
stokastic
  • 986
  • 2
  • 7
  • 19
1
vote
1 answer

tearDown at Unit Testing of Xcode

- (void) tearDown { // tear-down code here [super tearDown]; } What is the functionality of tearDown here? Does "tearDown" only used to release the memory? or something else?
Md Mahbubur Rahman
  • 2,065
  • 1
  • 24
  • 36
1
vote
2 answers

overwriting a method via stubbing with OCMock

I am trying to test that a timer object is stopped after a level is completed.. I have the following code: -(void)advanceLevel { int nextLevelId = self.currentLevel.id + 1; self.currentLevel = [[Level alloc]…
patrick
  • 9,290
  • 13
  • 61
  • 112