Sign in Go Pro

MockWebServer

Getting Set Up for Testing

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson
Autoplay

Up next

Previous

About

To test with MockWebServer, you need to set up your app to talk to the real server normally, but switch to MockWebServer during testing.

In this lesson you will learn:

How to test Retrofit with MockWebServer
Quick review of how to use OkHttpIdlingResource to wait for Retrofit to complete its network calls
How to use a custom test runner to instantiate a different Application during test
How to have the test application return the MockWebServer base url for Retrofit to use
How to enqueue a response to MockWebServer in your Espresso test

Instructor

Links

Comments

Hi, cool lesson and very useful.

Mention that if you are running an example from scratch, you need to add:
<uses-permission android:name="android.permission.INTERNET"/>
To avoid EACCES (Permission denied)

>
You need to go PRO to post comments.

Lessons in MockWebServer