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
2 answers

OCUnit tests not running / not being found

I'm trying to get to grips with OCTest, but can't seem to get it to actually run my tests (at least, I believe it's not running my tests). I've set up a project as described in the developer documentation, and added a class called UnitTests which…
Griff
  • 100
  • 8
1
vote
1 answer

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…
mag725
  • 695
  • 2
  • 9
  • 22
1
vote
2 answers

Prevent OCUnit tests from running when compilation fails

I'm using Xcode 3.2.2 and the built in OCUnit test stuff. One problem I'm running into is that every time I do a build my unit tests are run, even if the build failed. Let's say I make a syntax error in one of my tests. The test fails to compile…
mhenry1384
  • 7,538
  • 5
  • 55
  • 74
1
vote
0 answers

EXC_BAD_ACCESS while running OCUnit tests in Xcode

I got stuck with issue. I have OCUnit tests. I can run them successfully in iOS 7 simulator but I get EXC_BAD_ACCESS on iOS 6 simulator. Here is screenshot form Xcode: I'm using OCMockito and OCHamcrest. Do you have any idea what was the cause? I'm…
Eugen Martynov
  • 19,888
  • 10
  • 61
  • 114
1
vote
2 answers

OCUnit (SenTestingKit) error file is not of required architecture

I'm trying to build a project that uses OCUnit to run tests but get the following errors when linking: ld: warning: in /Developer/SDKs/MacOSX10.5.sdk/Library/Frameworks//SenTestingKit.framework/SenTestingKit, file is not of required…
1
vote
1 answer

Avoiding fragile unit tests with NSDateFormatter

What is the best practice for testing NSDateFormatter methods? For example, lets say I have a method: - (NSString *)formatStringFromDate:(NSDate *)date { NSDateFormatter *f = [[NSDateFormatter alloc] init]; [f…
squarefrog
  • 4,750
  • 4
  • 35
  • 64
1
vote
1 answer

Using OCUnit in Xcode for iPhone projects?

After configuring my iPhone app for unit testing, I belatedly noticed this warning in the documentation: iPhone OS Unit Testing Support: Unit tests are not supported for iPhone applications. As some of the other Xcode documentation regarding…
Greg Maletic
  • 6,225
  • 8
  • 54
  • 73
1
vote
2 answers

"Nesting" of tests with OCUnit?

Coming from Rails/Rspec, I'm used to being able to manage tests something like this: setup { //stuff for all tests goes here } tests for "foo" method setup { stuff specific to foo method here } test_foo_1 { ... } test_foo_2 { ... } end tests…
dpassage
  • 5,423
  • 3
  • 25
  • 53
1
vote
0 answers

Custom OCHamcrest matcher with a primitive function argument

I'm trying to write my own HCMatcher that I can use to simply some assertions when working with a collection of objects. Currently my test method is doing this: __block int totalNumberOfCells = 0; [configurations…
lukestringer90
  • 492
  • 7
  • 16
1
vote
2 answers

XIB outlets unit testing

I have following code to test if view is properly configured(among others, I have the monthScrollview placed as a subview of view: @implementation ECBrowserViewControllerTests -(void)setUp { //-deviceSpecific simply adds suffix like '_iPad' …
Michał Zygar
  • 4,052
  • 1
  • 23
  • 36
1
vote
1 answer

OCMock partial mock gives unexpected call

I have a test that verifies (with OCMock) that a method gets called when a certain notification is sent: - (void)testThatVCRegistersToLocationUpdateNotification { IssueDetailsViewController* vc = [[IssueDetailsViewController alloc] init]; id…
Ilea Cristian
  • 5,741
  • 1
  • 23
  • 37
1
vote
2 answers

How to replace async calls with mocks and predefined answers?

I have simple class for perform network stuff. It's a singleton and it encapsulates NSOperationQueue inside it. When class' user calls some method to getting data from network, this class creates proper instance of operation class inherited from…
Rostyslav Druzhchenko
  • 3,673
  • 3
  • 33
  • 38
1
vote
1 answer

Do the OCUnit, set the test after build to yes, the project can't build successfully

it's very strange, when i set the "test after build" to "yes" in "build settings", the project can't build successfully. but set to "no" , I press the "CMD+U" in keyboard, the test can executes successfully. i want to run the UT cases in jenkins, so…
Siro
  • 21
  • 3
1
vote
1 answer

Using Xcode's unit-testing framework, can application code determine whether it is being run as unit test?

Using the built-in testing framework provided by Xcode, is there any way for application code to determine whether it is being run by the test runner, as opposed to running as the app? In other words, I'm wondering whether it is possible to do…
Kristopher Johnson
  • 81,409
  • 55
  • 245
  • 302
1
vote
1 answer

OCUnit - Break on test case failure?

When debugging test case failures it would be very useful if the execution would automatically break upon test case failure, so that I could directly investigate the failure. So essentially a break point that triggers when an assertion fails. Does…
Erik B
  • 40,889
  • 25
  • 119
  • 135