Closed valeriomazzeo closed 7 years ago
So, what happens when you write it as follows?
id mock = OCMPartialMock([MyClass sharedInstance]);
OCMStub([mock myProperty]).andReturn(@1234);
If this also fails, then you'll have to provide the implementation of myProperty
, and whatever is called from it. Otherwise it's impossible to see how the recorder gets called twice.
My class implements initWithCoder
could it be related?
It could be. Without a failing example (in code), or at least some code and more information I can only guess, which I don't like doing. ;-)
Closing this due to inactivity.
sorry @erikdoe, your first suggestion fixed the issue, then I forgot to reply 👍
@erikdoe My code is OCMStub([class method:mockArgument]).andReturn(YES)
. It crashed when run. The exception message is [NSException raise:NSInternalInconsistencyException format:@"** Method init invoked twice on stub recorder. Are you trying to mock the init method? This is currently not supported."];
OCMStub([OCMPartialMock([MyClass sharedInstance]) myProperty]).andReturn(@(1234));
triggers
"** Method init invoked twice on stub recorder. Are you trying to mock the init method? This is currently not supported."