wiremock-stub-mapping-tracker is a set of WireMock extensions for tracking which stub mappings have been used in a request and easily deleting unmatched mappings. This is useful in conjunction with Record and Playback for pruning generated stub mappings. Tracking is done independently of the request journal.
Requires Java 1.8+
Run ./gradlew jar
to build the JAR without dependencies or ./gradlew fatJar
to build a standalone JAR. These will be placed in build/libs/
.
Standalone server:
java -jar build/libs/wiremock-stub-mapping-tracker-0.1-standalone.jar
With WireMock standalone JAR:
wget -nc http://repo1.maven.org/maven2/com/github/tomakehurst/wiremock-standalone/2.14.0/wiremock-standalone-2.14.0.jar
java \
-cp wiremock-standalone-2.14.0.jar:build/libs/wiremock-stub-mapping-tracker-0.1.jar \
com.github.tomakehurst.wiremock.standalone.WireMockServerRunner \
--extensions="com.github.masonm.StubMappingTrackerAdminExtension,com.github.masonm.StubMappingTrackerPostServeExtension"
Programmatically in Java:
new WireMockServer(wireMockConfig()
.extensions("com.github.masonm.StubMappingTrackerAdminExtension", "com.github.masonm.StubMappingTrackerPostServeExtension"))
POST /__admin/mappings_tracker/reset
- Clear journal of tracked stub mappingsGET /__admin/mappings_tracker/matched
- Return all stub mappings that have matched a requestGET /__admin/mappings_tracker/unmatched
- Return all stub mappings that haven't matched a requestDELETE /__admin/mappings_tracker/unmatched
- Delete all stub mappings that haven't matched a request