Class WireMockExtension
java.lang.Object
com.github.tomakehurst.wiremock.junit.DslWrapper
com.github.tomakehurst.wiremock.junit5.WireMockExtension
- All Implemented Interfaces:
Admin
,Stubbing
,org.junit.jupiter.api.extension.AfterAllCallback
,org.junit.jupiter.api.extension.AfterEachCallback
,org.junit.jupiter.api.extension.BeforeAllCallback
,org.junit.jupiter.api.extension.BeforeEachCallback
,org.junit.jupiter.api.extension.Extension
,org.junit.jupiter.api.extension.ParameterResolver
public class WireMockExtension
extends DslWrapper
implements org.junit.jupiter.api.extension.ParameterResolver, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.AfterAllCallback
JUnit Jupiter extension that manages a WireMock server instance's lifecycle and configuration.
See http://wiremock.org/docs/junit-jupiter/ for full documentation.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class com.github.tomakehurst.wiremock.junit.DslWrapper
admin, stubbing
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Constructor intended for subclasses. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
afterAll
(org.junit.jupiter.api.extension.ExtensionContext context) final void
afterEach
(org.junit.jupiter.api.extension.ExtensionContext context) baseUrl()
final void
beforeAll
(org.junit.jupiter.api.extension.ExtensionContext context) final void
beforeEach
(org.junit.jupiter.api.extension.ExtensionContext context) static WireMockExtension.Builder
Alias fornewInstance()
for use with custom subclasses, with a more relevant name for that use.int
int
getPort()
static WireMockExtension.Builder
Create a new builder for the extension.protected void
onAfterAll
(WireMockRuntimeInfo wireMockRuntimeInfo) To be overridden in subclasses in order to run code immediately after per-class cleanup of WireMock.protected void
onAfterEach
(WireMockRuntimeInfo wireMockRuntimeInfo) To be overridden in subclasses in order to run code immediately after per-test cleanup of WireMock and its associated resources.protected void
onBeforeAll
(WireMockRuntimeInfo wireMockRuntimeInfo) To be overridden in subclasses in order to run code immediately after per-class WireMock setup.protected void
onBeforeEach
(WireMockRuntimeInfo wireMockRuntimeInfo) To be overridden in subclasses in order to run code immediately after per-test WireMock setup.resolveParameter
(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) boolean
supportsParameter
(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) Methods inherited from class com.github.tomakehurst.wiremock.junit.DslWrapper
addStubMapping, countRequestsMatching, editStub, editStubMapping, findAll, findAllNearMissesFor, findAllStubsByMetadata, findAllUnmatchedRequests, findNearMissesFor, findNearMissesForAllUnmatchedRequests, findNearMissesForUnmatchedRequests, findRequestsMatching, findStubMappingsByMetadata, findTopNearMissesFor, findTopNearMissesFor, findUnmatchedRequests, getAllScenarios, getAllServeEvents, getGlobalSettings, getOptions, getRecordingStatus, getServedStub, getServeEvents, getServeEvents, getSingleStubMapping, getStubMapping, getStubMappings, givenThat, importStubs, listAllStubMappings, removeServeEvent, removeServeEventsForStubsMatchingMetadata, removeServeEventsMatching, removeStub, removeStub, removeStubMapping, removeStubMapping, removeStubMappingsByMetadata, removeStubsByMetadata, resetAll, resetMappings, resetRequests, resetScenario, resetScenarios, resetToDefaultMappings, saveMappings, setGlobalFixedDelay, setScenarioState, shutdownServer, snapshotRecord, snapshotRecord, snapshotRecord, startRecording, startRecording, startRecording, stopRecording, stubFor, updateGlobalSettings, verify, verify, verify
-
Constructor Details
-
WireMockExtension
public WireMockExtension() -
WireMockExtension
Constructor intended for subclasses. The parameter is a builder so that we can avoid a constructor explosion or backwards-incompatible changes when new options are added.- Parameters:
builder
- aWireMockExtension.Builder
instance holding the initialisation parameters for the extension.
-
-
Method Details
-
extensionOptions
Alias fornewInstance()
for use with custom subclasses, with a more relevant name for that use.- Returns:
- a new
WireMockExtension.Builder
instance.
-
newInstance
Create a new builder for the extension.- Returns:
- a new
WireMockExtension.Builder
instance.
-
onBeforeAll
To be overridden in subclasses in order to run code immediately after per-class WireMock setup.- Parameters:
wireMockRuntimeInfo
- port numbers, base URLs and HTTPS info for the running WireMock instance/
-
onBeforeEach
To be overridden in subclasses in order to run code immediately after per-test WireMock setup.- Parameters:
wireMockRuntimeInfo
- port numbers, base URLs and HTTPS info for the running WireMock instance/
-
onAfterEach
To be overridden in subclasses in order to run code immediately after per-test cleanup of WireMock and its associated resources.- Parameters:
wireMockRuntimeInfo
- port numbers, base URLs and HTTPS info for the running WireMock instance/
-
onAfterAll
To be overridden in subclasses in order to run code immediately after per-class cleanup of WireMock.- Parameters:
wireMockRuntimeInfo
- port numbers, base URLs and HTTPS info for the running WireMock instance/
-
supportsParameter
public boolean supportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws org.junit.jupiter.api.extension.ParameterResolutionException - Specified by:
supportsParameter
in interfaceorg.junit.jupiter.api.extension.ParameterResolver
- Throws:
org.junit.jupiter.api.extension.ParameterResolutionException
-
resolveParameter
public Object resolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws org.junit.jupiter.api.extension.ParameterResolutionException - Specified by:
resolveParameter
in interfaceorg.junit.jupiter.api.extension.ParameterResolver
- Throws:
org.junit.jupiter.api.extension.ParameterResolutionException
-
beforeAll
public final void beforeAll(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception - Specified by:
beforeAll
in interfaceorg.junit.jupiter.api.extension.BeforeAllCallback
- Throws:
Exception
-
beforeEach
public final void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception - Specified by:
beforeEach
in interfaceorg.junit.jupiter.api.extension.BeforeEachCallback
- Throws:
Exception
-
afterAll
public final void afterAll(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception - Specified by:
afterAll
in interfaceorg.junit.jupiter.api.extension.AfterAllCallback
- Throws:
Exception
-
afterEach
public final void afterEach(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception - Specified by:
afterEach
in interfaceorg.junit.jupiter.api.extension.AfterEachCallback
- Throws:
Exception
-
getRuntimeInfo
-
baseUrl
-
url
-
getHttpsPort
public int getHttpsPort() -
getPort
public int getPort()
-