Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OCMock: Mock objects that implement several protocols?

id protocolMock = OCMProtocolMock(@protocol(SomeProtocol));

Will create a mock object that can be used as if it were an instance of an object that implements SomeProtocol.

Does OCMock provide a way to create a mock object that implements several protocols?

like image 413
schmittsfn Avatar asked Mar 08 '26 15:03

schmittsfn


2 Answers

In your test file, you can create a new protocol that implements the multiple ones you need:

@protocol MyTestProtocol <MyProtocolA, MyProtocolB>
@end

and then mock it:

id protocolMock = OCMProtocolMock(@protocol(MyTestProtocol));

This is currently not supported in OCMock. If you think this is a feature that really should be added, please log an issue on Github (https://github.com/erikdoe/ocmock/issues).

like image 26
Erik Doernenburg Avatar answered Mar 10 '26 08:03

Erik Doernenburg