StartStop

@Target(allowedTargets = [AnnotationTarget.FIELD])
@ExtendWith(value = [StartStopExtension::class])
annotation class StartStop

Runs MockWebServer for the duration of a test method or test class.

In Java JUnit 5 tests (ie. tests annotated @org.junit.jupiter.api.Test), use this by defining a field with the @StartStop annotation:

@StartStop public final MockWebServer server = new MockWebServer();

Or for Kotlin:

@StartStop val server = MockWebServer()