Allow tests to initialize non-stubbed dependencies
Add flag allow-tests-to-init-real-dependencies that will force all dependency resolver methods to be declared as internal rather than private or fileprivate so that any @Testable import of the generated code is able to initialize both the dependency container and access all of the DependencyResolvers. Note that this does NOT change any of the test mock generation, this is altering the access level of the real dependencies to be able to facilitate customization of test dependencies. It is then possible to mix and match real and mocked dependencies based on your test setup. Previously this was not possible because the MainDependencyContainer initializer was private, along with all of the dependency resolvers. Without setting this flag, there is no impact to code generation so this change is fully backward compatible.
For example, now inside of unit tests for some CoolSampleApp , you would be able to do this:
@Testable import CoolSampleApp
class ExampleTests: XCTestCase {
func testExample() {
let realDependencyContainer = MainDependencyContainer()
let realDependency = realDependencyContainer.specificDependencyResolver().specificDependency
// Test code that actually uses the real dependency
}
}