MockWebServerRule
Runs MockWebServer for the duration of a single test method.
In Java JUnit 4 tests (ie. tests annotated @org.junit.Test), use this by defining a field with the @Rule annotation:
@Rule public final MockWebServerRule serverRule = new MockWebServerRule();Content copied to clipboard
For Kotlin the @JvmField annotation is also necessary:
@JvmField @Rule val serverRule = MockWebServerRule()Content copied to clipboard