A Lesson by Chiu-Ki Chan
Since you will be starting and shutting down the MockWebServer in each test method, you can extract that into a JUnit TestRule to save repetition. This lesson will show you how to do that.
In this lesson you will learn:
- How to put a MockWebServer into a TestRule
- How to pass the url from the MockWebServer to the app in a JUnit @Before method
- How the server starts and stops before each test execution
- How to access the server object from within the custom TestRule
Pro Users: Sign in to access this lessons source code