Protocol Mock in library has internal initializer
I have a library that I generate all of my mocks into that is imported in my unit tests. When mocking a protocol, the generated mock object doesn't have an initializer declared. This means is uses the default initializer, which would be fine, except the default init() method is internal. I can get around this by importing my mock library @testable, but I'd suggest that protocol mocks for public protocols have a public init() {} method generated.
Hey, @AnthonyMillerSF, I understand where you're coming from. However, method accessibility is a tricky subject because we might fix this use case and break N others. I'm not against implementing this if it's tested thoroughly enough to rule out issues that might arise from it. If you're up for it, by all means, file a PR along with some tests and we'll take a look and merge it as long as it's not a breaking change for others.
I've just taken a look at Cuckoo and hit same issue. Our codebase is highly modular (private Cocoapods spec repo) and wanted to have each pod have a 'Mock' sub-spec that contains mocked versions of the protocols in the module. Maybe way to deal with compatibility is to have a command line option to turn generating of protocol initialisers on? Might take a look at implementing this if this is thought a sensible approach.
Hey, @mwoollard. Unless @AnthonyMillerSF's proposal doesn't work for all use-cases, I'd rather avoid polluting the generator arguments.
I reckon that generating an init with no parameters (and the same accessibility as the generated class) shouldn't break anything; provided there is no init with any number of parameters declared in the protocol itself.
We'll probably see where we fall with a concrete implementation and a bit more extensive tests on protocol inits. I hope we won't need to add another argument to the generator, further increasing the complexity.
If @AnthonyMillerSF's proposal works for all use-cases would see that as preferable.