Questions tagged [ocmock]

OCMock is an Objective-C implementation of mock objects.

The OCMock framework provides the ability of using mock objects in Objective-C applications. Some of the functionality in the framework is:

  • Create fail-fast and nice mocks.
  • Ability to stub and return predetermined values.
  • Mock instance and class methods.
  • Mock protocols and notification observers.
  • Partial mocks to stand in for a real object.
  • Forward messages to other objects.

Relevant links

Web site

Source

484 questions
0
votes
2 answers

How to check OCMock release version?

How to check OCMock release version? I want to know whether the code I am working on has the latest (release 2.1) OCMock. How to check that in xcode project?
Warrior
  • 39,156
  • 44
  • 139
  • 214
0
votes
2 answers

OCMock test for void methods

I am doing OCMocktest for methods that will return some value. How to implement for void methods. Eg a method that calculates Simple interest. But it doesot return any value. How can check the calculation functionality? -(void)calculateSI { float…
Warrior
  • 39,156
  • 44
  • 139
  • 214
0
votes
1 answer

OCMock confuses references in a threaded environment

I have a piece of code, which is processing a queue synchronously and asynchronously. I'm using OCMock to test the thing and individually I can test both cases (synchronous and asynchronous) but when I test for both at the same time I get trouble.…
JHollanti
  • 2,343
  • 8
  • 27
  • 39
0
votes
1 answer

How to mock a class which calls an invokation block?

I'm digging myself into TDD and startet using SenTestingKit along with OCMock. I'm using FMDB as a wrapper for my SQLite Database. I can't get my head around how to mock the DatabaseQueue class, so it correctly invokes the invocation block with an…
Christoph Winkler
  • 6,278
  • 1
  • 18
  • 18
0
votes
2 answers

Assert that message is sent to self OCUnit

I am fairly new to OCUnit and I am trying to add a Test Case to a method that looks like this: - (void) processMessageBody:(XMPPMessage *)message fromNick:(NSString *)nick; { BOOL isEcho; SBEventMessage *eventMessage =…
Pierluigi Cifani
  • 224
  • 2
  • 14
0
votes
2 answers

Create simple OCMock unit test in objective c

I configured OCMock to my static class library and I created simple method like this. #import "IOSExample.h" @implementation IOSExample -(NSString *)MyTest { return @"Nuwanga"; } -(int *)MyAge { int a=5; int b=5; int product=a*b; …
Himesh
  • 458
  • 1
  • 3
  • 15
0
votes
1 answer

Mocking an object under observation

I am seeing an exception when mocking an object that is already under KVO observation. Here is a simplified example that shows the problem: [sourceObject addObserver:destinationObject forKeyPath:@"stringProperty" options:NSKeyValueObservingOptionNew…
drewag
  • 93,393
  • 28
  • 139
  • 128
0
votes
1 answer

why is this OCMock verify failing?

Not sure if I'm using OCMocks correctly, or if it's because I'm using the cocoapods version and not the .lib file. Here's the test(s) #import "MWViewControllerTests.h" #import "MWViewController.h" #import "OCMockObject.h" #import…
Mark W
  • 3,879
  • 2
  • 37
  • 53
0
votes
2 answers

GHUnit, OCMock: how to test if one of two specified block is called?

I have a method that takes a response block and an error block, I write unit test by giving it valid data and invalid data so it will call response block and error block respectively, but with GHUnit and OCMock, how do I test if the correct block is…
hzxu
  • 5,753
  • 11
  • 60
  • 95
0
votes
1 answer

OCMock in a block context

So I am attempting to throw together a simple test to verify that I am receiving frequency values from my audioController correctly. In my view I am making a call like this to setup up a block callback: - (void) registerVolumeCallback { …
Greg Price
  • 2,556
  • 1
  • 24
  • 33
0
votes
1 answer

PartialMock for Init method

I've tried swizzling out the init method for a partial mock and was wondering if this was possible. I've had no luck with: SomeClass *foo = [SomeClass alloc]; mock = [OCMockObject partialMockForObject:foo]; [[[mock stub] andCall:@selector(mockInit)…
Brian Liang
  • 7,734
  • 10
  • 57
  • 72
0
votes
1 answer

Is it possible to OCMock a class call in a static method?

Am just getting started with OCMock so bear with me - I have been looking through the documentation and loads of examples but am yet to find a definitive answer - is it possible to mock out an init call within a static method, for example: +…
ChrisH
  • 285
  • 3
  • 13
0
votes
1 answer

Stub Methods with Block Arguments

I'm trying to stub a method which has got an block argument. [[[myMock stub] andCall:@selector(performBlock:) onObject:self] performBlock:[OCMArg any]]; The block is of a simple type. typedef void (^MyBlock)(void); Upon execution I get the…
fabb
  • 11,660
  • 13
  • 67
  • 111
0
votes
1 answer

Unit Testing an NSURLConnection Delegate: Faking a Connection

I'm writing a weather application and I've created a sort of weather model that does all the calculations, fetching of data, etc. Before I created the ViewControllers, I wanted to write some unit tests for my model to ensure that everything was…
0
votes
1 answer

OCMock does not recognize called selector

I'm struggling with a testcase that uses OCMock. So far I used OCMock in a few projects and it always work as i thought. I have the following method that tests that [self setNeedsDisplay] is called when I set a property called image. -…
Sandro Meier
  • 3,071
  • 2
  • 32
  • 47
1 2 3
32
33