If your app integrates with a server API, mocking server responses is important for tests. In unit tests it's easy to mock the object doing the API calls, but on a UI test it's harder. We're going to show how to mock Retrofit API calls in UI tests with a quick solution using MockWebServer and Hilt.
Unit testing is one of my favorite software engineering techniques. In our industry, the word “testing” is strongly associated with the word “bug”, so the common belief is that unit tests help find/eradicate/prevent bugs. And while this is not untrue, there’s much more that unit testing can offer!