-
DescriptionHello! I have discussion w/ developers in our team :) We have using dependencies with liveValue and testValue. Would we save our mocks in the main target of the directory of our dependency and use it in testValue? Or would we save all mocks in test target and change dependency implementation in our tests? Checklist
Expected behaviorNo response Actual behaviorNo response Steps to reproduceNo response The Composable Architecture version informationNo response Destination operating systemNo response Xcode version informationNo response Swift Compiler version informationNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hi @katovBash, I am going to convert this to a discussion since it's not an issue or bug with the library. |
Beta Was this translation helpful? Give feedback.
-
Hi @katovBash, in our view the most optimal implementation of the static let testValue = SpeechClient(
authorizationStatus: unimplemented("SpeechClient.authorizationStatus", placeholder: .denied),
requestAuthorization: unimplemented("SpeechClient.requestAuthorization", placeholder: .denied),
startTask: unimplemented("SpeechClient.startTask")
) …as well as every other demo and case study we have in our various repos. This way you are immediately alerted to the moment a dependency starts being used in a feature because you will get a test failure in all the places you haven't dealt with that new behavior. This also means you don't need to put any mocks in the module that holds the |
Beta Was this translation helpful? Give feedback.
Hi @katovBash, in our view the most optimal implementation of the
testValue
of a dependency is the one that simply performs anXCTFail
in every single endpoint, or uses theunimplemented
helper to stub any kind of closure with one that performsXCTFail
under the hood. This is what we do in our standups demo app:https://github.com/pointfreeco/standups/blob/e130ec11cbd7de569256373fb177ae7cbdb470a0/Standups-StackBased/Standups/Dependencies/SpeechClient.swift#L72-L76