Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@BrewTestBot
Copy link
Member

Created by brew bump


Created with brew bump-formula-pr.

release notes
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
  }
}

It is still possible to use the tests flag to generate stubbed dependencies and use those alongside each other. For example, you can now mix and match real and mocked dependencies for a class under test to be able to do integration or feature level tests. Continuing the textExample() from above, you may see something like this:

  func testExample() {
    let realDependencyContainer = MainDependencyContainer()
    let realDependencyFoo = realDependencyContainer.dependencyFooResolver().dependencyFoo

    let mockedDependencyContainer = StubbedDependencies()
    let mockedDependencyBar = StubbedDependencies.dependencyBarDouble

    let objectUnderTest = SomeClass(foo: realDependencyFoo, bar: mockedDependencyBar)
    // Actual test logic and validation
  }

Also update dependencies and tools versions in the package so that it can compile with modern tool chains (Xcode 16.x, Swift 5).

@github-actions github-actions bot added bump-formula-pr PR was created using `brew bump-formula-pr` macos-only Formula depends on macOS labels Apr 18, 2025
@github-actions github-actions bot added automerge-skip `brew pr-automerge` will skip this pull request autobump labels Apr 18, 2025
@chenrui333
Copy link
Member

chenrui333 commented Apr 18, 2025

autobump: add weaver

Signed-off-by: Rui Chen <[email protected]>

weaver: remove build patch

Signed-off-by: Rui Chen <[email protected]>
@chenrui333 chenrui333 removed the automerge-skip `brew pr-automerge` will skip this pull request label Apr 18, 2025
@github-actions
Copy link
Contributor

🤖 An automated task has requested bottles to be published to this PR.

Please do not push to this PR branch before the bottle commits have been pushed, as this results in a state that is difficult to recover from. If you need to resolve a merge conflict, please use a merge commit. Do not force-push to this PR branch.

@github-actions github-actions bot added the CI-published-bottle-commits The commits for the built bottles have been pushed to the PR branch. label Apr 19, 2025
@BrewTestBot BrewTestBot enabled auto-merge April 19, 2025 00:21
@BrewTestBot BrewTestBot added this pull request to the merge queue Apr 19, 2025
Merged via the queue into master with commit 392f621 Apr 19, 2025
17 checks passed
@BrewTestBot BrewTestBot deleted the bump-weaver-1.1.7 branch April 19, 2025 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autobump bump-formula-pr PR was created using `brew bump-formula-pr` CI-published-bottle-commits The commits for the built bottles have been pushed to the PR branch. macos-only Formula depends on macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants