Skip to content

WireMock extensions to track stub mapping usage

License

Notifications You must be signed in to change notification settings

MasonM/wiremock-stub-mapping-tracker

Repository files navigation

Overview

Build Status Maven Central

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+

Building

Run ./gradlew jar to build the JAR without dependencies or ./gradlew fatJar to build a standalone JAR. These will be placed in build/libs/.

Running

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"))

Usage

  • POST /__admin/mappings_tracker/reset - Clear journal of tracked stub mappings
  • GET /__admin/mappings_tracker/matched - Return all stub mappings that have matched a request
  • GET /__admin/mappings_tracker/unmatched - Return all stub mappings that haven't matched a request
  • DELETE /__admin/mappings_tracker/unmatched - Delete all stub mappings that haven't matched a request

About

WireMock extensions to track stub mapping usage

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published