Override dependencies in complex testing #52
Unanswered
marcuswu0814
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I’m trying to refactor my dependencies system and fix my failing test cases, facing two problems, the executable demo project is here.
Question A - Mock a nested dependency in testing
According to Discussion #21, I made a nested dependencies with this pattern.
In my test case, I try to do partial mock, but it does not work as excepted.
If I need using live
b
implementation, and only mock mya
service, what is the best practice to do this? Currently I use nestedwithDependencies(_:operation:)
to do so. But it let test case much unreadable. Any suggestion for this situation?Question B - Override dependencies after global mock
According to BaseTestCaseTests.swift and Documentation - Override Dependencies, I create a
BaseTestCase
and mock some dependency globally in all test cases.When I trying to override it in some specific test case, it doesn’t work. Is this a supported feature?
Beta Was this translation helpful? Give feedback.
All reactions