Closed SumoSimo closed 6 months ago
I'm not sure if it's the correct way to solve this, but I've added the any
keyword in the generated mocks to all protocols and the tests pass with flying colors, so we'll try it and see if the real world has a problem with it. 😁
Hi there. I'm running into an issue with the inability to mock protocols that conform to
ObservableObject
. Consider the following protocol:protocol TestProtocol: ObservableObject {}
The generated mock and stub for this protocol is as follows:
Below is a screenshot of the errors for
__defaultImplStub
andfunc enableDefaultImplementation(_ stub: TestProtocol) { ... }
:I was able to resolve the compilation errors by assigning the
MocksType
typealias toTestProtocolStub
, setting the type for__defaultImplStub
toTestProtocolStub
, and setting the parameter type ofenableDefaultImplementation(_ stub: TestProtocol)
toTestProtocolStub
. I don't know if this is the exact solution because I don't understand the underpinnings and nuances of the Cuckoo framework, but it can serve as a lead.If this turns out to be the solution, then I suppose the Cuckoo framework should be updated to account for protocols that conform to protocols that have Self or associated type requirements by using the approach aforementioned. If this issue can be solved, it would also take care of #364. The difference between this issue and #364 is that I cannot exclude protocols that conform to
ObservableObject
.Any help is greatly appreciated since testing in the context of SwiftUI is picking up. Thank you!