Test readonly property with OCMockito

355 Views Asked by At

I've got a class that has a readonly property.

typedef NS_ENUM(NSInteger, MyObjectStates) {
   MyObjectStatesUnknown,
   MyObjectStatesOn,
   MyObjectStatesOff
};
@interface MyObject : NSObject
@property (nonatomic, readonly) MyObjectStates state;
@end

- (void)testExample
{
    MyObject *mockObject = mock([MyObject class]);
    [given(mockObject.state) willReturnInteger: MyObjectStatesOn];

    assertThatInteger(mockObject.state, equalToInteger(MyObjectStatesOn));
}

But what I get when I run this code is

-[NSInvocation mkt_retainArgumentsWithWeakTarget]: unrecognized selector ...

What do I wrong?

1

There are 1 best solutions below

0
On

I've to confess that I forgot to set -ObjC on Other linker flags. Realized that when I looked into the OCMockito.podspec file and saw the TPWeakProxy dependency.