You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What I want:
Auto prefixes (module name) for all types to prevent naming conflicts. Without them the tool is quite fragile at least for our purposes, but it's very powerful if it works!
The text was updated successfully, but these errors were encountered:
@torstenlehmann Thanks for raising. This is, unfortunately, a big conceptual problem, as we don't have module information in general when generating mocks (that's why we still have to declare imports in yml instead of deriving them from types modules).
There are some bigger changes coming in 4.0, and maybe we will find a way to work it out. The big problem is, in general:
you have your protocols you gonna mock usually split among separate files
the Mocks.generated.swift is a single file
This setup is fragile by default, as it's vulnerable to naming conflicts. If it was possible, I would just namespace mocks based on their module anyway, but this is unfortunately impossible. I see some options though:
If we have knowledge about origin modules for every type, then we can typealias Type = Module.Type in the scope of every mock generated
We will give better support for 'one generated file per mock' or 'per module' approach
The second option seems easier to achieve at this point and does not conflict with the other approach anyway. The 1 might not be possible to be done automatically, but there should be at least possibility to specify these rules in config.
As another workaround, you can use inline mocking:
A -> B -> D
A -> C -> D
Framework B:
Framework C:
Framework D:
What I do:
I try to generate mocks for A by including all files from A, B, C, D.
What I get:
Naming conflicts in the generated mocks file, because
TrackingEvent
is not prefixed with the Swift module name.Workaround:
Prefixing the extension methods argument type with module name:
What I want:
Auto prefixes (module name) for all types to prevent naming conflicts. Without them the tool is quite fragile at least for our purposes, but it's very powerful if it works!
The text was updated successfully, but these errors were encountered: