Cuckoo
Cuckoo copied to clipboard
Protocol Composition Mock
I was writing a piece of code that requires a "Protocol Composition"
InteractionServiceHandler & NavigationContentCaller
But it seems that the Cuckoo only support single Protocol, is the feature supported for the composition ?
Information provide from: https://docs.swift.org/swift-book/LanguageGuide/Protocols.html#//apple_ref/doc/uid/TP40014097-CH25-ID282
Hey, it's possible that this case has been overlooked, can you work around it using generics?
Using your protocols, declaring <T: InteractionServiceHandler & NavigationContentCaller>
to see if that works and if not, using the where
clause, so func gg<T>() where T: InteractionServiceHandler, T: NavigationContentCaller
.
I just ended up building a class inheriting the two types
class Mocker: InteractionServiceHandler, NavigationContentCaller
which doesn't use Cuckoo in my test case.
Ideally we should support composition.
We should add support for this. Not very common but definitely a good thing to have.