Cuckoo icon indicating copy to clipboard operation
Cuckoo copied to clipboard

Add command line option to specific additional frameworks to import into generated files

Open mwoollard opened this issue 5 years ago • 3 comments

This is useful when mocking code from pods imported into the target project. In this case the generated mock won’t be able to access content in the pod. By using the new option you can add import of the pod (or any other) into the generated source file.

mwoollard avatar Sep 15 '20 20:09 mwoollard

Hey, thanks for the PR. I'm not really familiar with the constraints of a @testable import as opposed to classic import. May I know the use-case where adding this argument instead of passing the framework to --testable is beneficial? All --testable does is it imports the frameworks, just with the @testable annotation if I remember correctly.

MatyasKriz avatar Sep 18 '20 15:09 MatyasKriz

@testable elevates access to the imported module so that any internal scope definitions in the module are made public. Personally, I feel its safer, particularly if working within a team, you only expose what should be. Stops someone inadvertently using something from an imported module not directly under test that wouldn't normally be available.

mwoollard avatar Sep 20 '20 07:09 mwoollard

Yes, I'm aware that @testable import has this characteristic, though I have to wonder; what role does the standard import play in the generated code as opposed to @testable? I can't think of a way the generated code would function differently.

MatyasKriz avatar Sep 22 '20 07:09 MatyasKriz

Closing for now, if someone wants to provide an argument for this, I'm all ears.

MatyasKriz avatar Aug 16 '22 15:08 MatyasKriz