Testing an API-backed screen
This screen leans heavily on an API response. How would you change the code so you can test the screen, view model included, without a server request?
This screen leans heavily on an API response. How would you change the code so you can test the screen, view model included, without a server request?
Abstract the network behind a protocol (a repository or service) that the view model takes in its initializer, and split the view so it only draws the view model's state. Then you can inject a stub implementation in tests.
TestingShort answerBasics
If you were testing load() on the view model below, which cases would you verify? …
#view-model #mvvm
TestingShort answerAdvanced
One item the architecture round scores is "can you add unit tests without a big…
#dependency-injection #testability
TestingShort answerBasics
The question asks about your experience writing code with unit tests in mind and the…
#dependency-injection #testability
ArchitectureShort answerBasics
Someone proposes moving an app that works fine on MVC over to MVVM. What's the…
#mvvm #testability