4
votes

I have a method of the followng signature;

- (NSInteger) getFirstVisitTimeStamp;

When I use OCMock to mock and return a value, the test fails with the below error.

[[[[YSNYI13NMockingTest mockedYI13N] expect] andReturnValue:@(12345)] getFirstVisitTimeStamp];

Error:

file:///%3Cunknown%3E: test failure:
failed: Return value does not match method signature; signature declares 'q' but value is 'i'.

Can anyone help ?

2
Are q and i the actual values it lists? - shortstuffsushi
Are you running this on the 64 bit simulator? - michaels

2 Answers

9
votes

On 64-bit devices, NSInteger is declared as long, but the value you are returning is being typed as int. Try forcing your value to a long by adding l after the number:

[[[[YSNYI13NMockingTest mockedYI13N] expect] andReturnValue:@(12345l)] getFirstVisitTimeStamp];
3
votes

As @michaels hinted at in the comments, and after searching a bit further into your error message, this appears to be related to an open bug in OCMock.

It seems using OCMOCK_VALUE(...) might work for you instead.