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
It looks like the generated mock file will contain mocks for inherited protocols by design. Can we improve the generator to exclude them? Or is there a way to do this that I'm unaware of.
Example
Swift Package "Base":
public protocol BaseProtocol {
func getBar() -> Int
}
Swift Package "Middle":
public protocol MiddleProtocol: BaseProtocol {
func getFoo() -> Int
}
Now run the generator using the following command:
We would get both MockMiddleProtocol and MockBaseProtocol inside the file MiddleTestMocks.swift.
Expected Behavior
Using the above example, I'm looking for a way to not contain MockBaseProtocol inside BaseMiddleMocks. This can probably be configurable via a new command line argument like supportGlob. It indicates the file necessary to generate the correct mocks that contains parent methods but does not generate mock for parent protocols themselves.
Hey there, @juyan. Does excluding the MiddleProtocol on its own do what you need? I'm not against adding support for this case, but I'd refrain from adding more CLI flags if possible.
Hey, in Cuckoo 2.0 the regex exclusion is applied after inheritance is resolved, so it is possible to do the thing you're proposing here. 🙂 Thanks for the issue!
Overview
It looks like the generated mock file will contain mocks for inherited protocols by design. Can we improve the generator to exclude them? Or is there a way to do this that I'm unaware of.
Example
Swift Package "Base":
Swift Package "Middle":
Now run the generator using the following command:
We would get both
MockMiddleProtocol
andMockBaseProtocol
inside the fileMiddleTestMocks.swift
.Expected Behavior
Using the above example, I'm looking for a way to not contain
MockBaseProtocol
insideBaseMiddleMocks
. This can probably be configurable via a new command line argument likesupportGlob
. It indicates the file necessary to generate the correct mocks that contains parent methods but does not generate mock for parent protocols themselves.Looking forward to see other's thoughts. Thanks.
The text was updated successfully, but these errors were encountered: