Testing a playlist view model
A music app's playlist ViewModel takes a track list from a Repository and produces loading, success, and error states. How would you test those state transitions without a real network?
A music app's playlist ViewModel takes a track list from a Repository and produces loading, success, and error states. How would you test those state transitions without a real network?
Through the initializer, inject a fake Repository that adopts the protocol so it returns success, failure, or an empty list at will, then await load() and compare the state enum against the case you expect.
TestingShort answerIntro
A teammate says they'd rather build one more feature than spend the time writing tests…
#unit-test
TestingShort answerIntro
What's the difference between unit tests, integration tests, and UI tests?
#unit-test
TestingShort answerBasics
What is a test double?
#fake
TestingShort answerAdvanced
You have dozens of UI tests that are slow and break often. How would you restructure the…
#unit-test