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,org.junit.jupiter.api.extension.TestInstantiationAwareExtension
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 ClassesNested classes/interfaces inherited from interface org.junit.jupiter.api.extension.TestInstantiationAwareExtension
org.junit.jupiter.api.extension.TestInstantiationAwareExtension.ExtensionContextScope -
Field Summary
Fields inherited from class com.github.tomakehurst.wiremock.junit.DslWrapper
admin, stubbing -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor intended for subclasses. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidafterAll(org.junit.jupiter.api.extension.ExtensionContext context) final voidafterEach(org.junit.jupiter.api.extension.ExtensionContext context) baseUrl()final voidbeforeAll(org.junit.jupiter.api.extension.ExtensionContext context) final voidbeforeEach(org.junit.jupiter.api.extension.ExtensionContext context) static WireMockExtension.BuilderAlias fornewInstance()for use with custom subclasses, with a more relevant name for that use.intintgetPort()static WireMockExtension.BuilderCreate a new builder for the extension.protected voidonAfterAll(WireMockRuntimeInfo wireMockRuntimeInfo) To be overridden in subclasses in order to run code immediately after per-class cleanup of WireMock.protected voidonAfterAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext, WireMockRuntimeInfo wireMockRuntimeInfo) To be overridden in subclasses in order to run code immediately after per-class cleanup of WireMock.protected voidonAfterEach(WireMockRuntimeInfo wireMockRuntimeInfo) To be overridden in subclasses in order to run code immediately after per-test cleanup of WireMock and its associated resources.protected voidonAfterEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext, WireMockRuntimeInfo wireMockRuntimeInfo) To be overridden in subclasses in order to run code immediately after per-class cleanup of WireMock.protected voidonBeforeAll(WireMockRuntimeInfo wireMockRuntimeInfo) To be overridden in subclasses in order to run code immediately after per-class WireMock setup.protected voidonBeforeAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext, WireMockRuntimeInfo wireMockRuntimeInfo) To be overridden in subclasses in order to run code immediately after per-class WireMock setup.protected voidonBeforeEach(WireMockRuntimeInfo wireMockRuntimeInfo) To be overridden in subclasses in order to run code immediately after per-test WireMock setup.protected voidonBeforeEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext, WireMockRuntimeInfo wireMockRuntimeInfo) To be overridden in subclasses in order to run code immediately after per-test cleanup of WireMock and its associated resources.resolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) booleansupportsParameter(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, findUnmatchedStubs, getAllScenarios, getAllServeEvents, getGlobalSettings, getOptions, getRecordingStatus, getServedStub, getServeEvents, getServeEvents, getSingleStubMapping, getStubMapping, getStubMappings, givenThat, importStubs, listAllStubMappings, removeServeEvent, removeServeEventsForStubsMatchingMetadata, removeServeEventsMatching, removeStub, 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, verifyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.junit.jupiter.api.extension.TestInstantiationAwareExtension
getTestInstantiationExtensionContextScope
-
Constructor Details
-
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.Builderinstance 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.Builderinstance.
-
newInstance
Create a new builder for the extension.- Returns:
- a new
WireMockExtension.Builderinstance.
-
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/
-
onBeforeAll
protected void onBeforeAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext, WireMockRuntimeInfo wireMockRuntimeInfo) To be overridden in subclasses in order to run code immediately after per-class WireMock setup.- Parameters:
extensionContext- the current extension context; nevernullwireMockRuntimeInfo- 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/
-
onBeforeEach
protected void onBeforeEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext, WireMockRuntimeInfo wireMockRuntimeInfo) To be overridden in subclasses in order to run code immediately after per-test cleanup of WireMock and its associated resources.- Parameters:
extensionContext- the current extension context; nevernullwireMockRuntimeInfo- 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/
-
onAfterEach
protected void onAfterEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext, WireMockRuntimeInfo wireMockRuntimeInfo) To be overridden in subclasses in order to run code immediately after per-class cleanup of WireMock.- Parameters:
extensionContext- the current extension context; nevernullwireMockRuntimeInfo- 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/
-
onAfterAll
protected void onAfterAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext, WireMockRuntimeInfo wireMockRuntimeInfo) To be overridden in subclasses in order to run code immediately after per-class cleanup of WireMock.- Parameters:
extensionContext- the current extension context; nevernullwireMockRuntimeInfo- 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:
supportsParameterin 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:
resolveParameterin 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:
beforeAllin interfaceorg.junit.jupiter.api.extension.BeforeAllCallback- Throws:
Exception
-
beforeEach
public final void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception - Specified by:
beforeEachin interfaceorg.junit.jupiter.api.extension.BeforeEachCallback- Throws:
Exception
-
afterAll
public final void afterAll(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception - Specified by:
afterAllin interfaceorg.junit.jupiter.api.extension.AfterAllCallback- Throws:
Exception
-
afterEach
public final void afterEach(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception - Specified by:
afterEachin interfaceorg.junit.jupiter.api.extension.AfterEachCallback- Throws:
Exception
-
getRuntimeInfo
-
baseUrl
-
url
-
getHttpsPort
public int getHttpsPort() -
getPort
public int getPort()
-