Open vsanthanam opened 2 years ago
@vsanthanam I can generate mocks with no problem. Would the same error occur if you use the latest version of Mockolo (1.7.0)?
Seems to be happening even on 1.7 note that generating the mocks isn't the problem. Its that the mocks aren't compilable.
❌ /Users/vsanthanam/Desktop/convusic-monorepo/Project/ConvusicMobileTests/Mocks.swift:498:16: call to main actor-isolated initializer 'init()' in a synchronous nonisolated context
return MainControllerMock()
The mocks cannot invoke the initializers of their actor dependent mocks because they are not annotated correctly
Here's an attached generated but non-compiling example: Mocks.swift.txt
If you annotate a protocol with a global actor, such as @MainActor, its generate mock doesn't compile:
Given
the mock will fail with this compilation error:
The solution, I believe, would be to also add the actor annotation to the Mock
An identically generated mock, with the
@MainActor
annotation would work just fine.I believe there would be similar errors for per-member annotations as well.