MockWebServerExtension

class MockWebServerExtension : BeforeEachCallback, AfterEachCallback, ParameterResolver

Runs MockWebServer for the duration of a single test method.

Specifically while junit instances passes into test constructor are typically shares amongst all tests, a fresh instance will be received here. Use with @BeforeAll and @AfterAll, is not supported.

There are 3 ids for instances

  • The test instance default (passed into constructor)

  • The test lifecycle default (passed into test method, plus @BeforeEach, @AfterEach)

  • named instances with @MockWebServerInstance.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun afterEach(context: ExtensionContext)
Link copied to clipboard
open override fun beforeEach(context: ExtensionContext)

Start the servers passed in as test method parameters.

Link copied to clipboard
open override fun resolveParameter(parameterContext: ParameterContext, extensionContext: ExtensionContext): Any
Link copied to clipboard
@IgnoreJRERequirement
open override fun supportsParameter(parameterContext: ParameterContext, extensionContext: ExtensionContext): Boolean