WireMock JUnit 5 extension

A JUnit 5 extension for WireMock

License

License

Categories

Categories

JUnit Unit Testing Wire Data Data Structures
GroupId

GroupId

de.mkammerer.wiremock-junit5
ArtifactId

ArtifactId

wiremock-junit5
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

WireMock JUnit 5 extension
A JUnit 5 extension for WireMock
Project URL

Project URL

https://github.com/phxql/wiremock-junit5
Source Code Management

Source Code Management

https://github.com/phxql/wiremock-junit5

Download wiremock-junit5

How to add to project

<!-- https://jarcasting.com/artifacts/de.mkammerer.wiremock-junit5/wiremock-junit5/ -->
<dependency>
    <groupId>de.mkammerer.wiremock-junit5</groupId>
    <artifactId>wiremock-junit5</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/de.mkammerer.wiremock-junit5/wiremock-junit5/
implementation 'de.mkammerer.wiremock-junit5:wiremock-junit5:1.1.0'
// https://jarcasting.com/artifacts/de.mkammerer.wiremock-junit5/wiremock-junit5/
implementation ("de.mkammerer.wiremock-junit5:wiremock-junit5:1.1.0")
'de.mkammerer.wiremock-junit5:wiremock-junit5:jar:1.1.0'
<dependency org="de.mkammerer.wiremock-junit5" name="wiremock-junit5" rev="1.1.0">
  <artifact name="wiremock-junit5" type="jar" />
</dependency>
@Grapes(
@Grab(group='de.mkammerer.wiremock-junit5', module='wiremock-junit5', version='1.1.0')
)
libraryDependencies += "de.mkammerer.wiremock-junit5" % "wiremock-junit5" % "1.1.0"
[de.mkammerer.wiremock-junit5/wiremock-junit5 "1.1.0"]

Dependencies

compile (2)

Group / Artifact Type Version
com.github.tomakehurst : wiremock jar 2.27.2
org.junit.jupiter : junit-jupiter-api jar 5.7.0

test (2)

Group / Artifact Type Version
org.assertj : assertj-core jar 3.18.1
org.junit.jupiter : junit-jupiter jar 5.7.0

Project Modules

There are no modules declared in this project.

WireMock JUnit 5 Extension

What is this?

A JUnit 5 extension for WireMock - the JUnit 5 equivalent of @WireMockRule.

How to use

Include the dependency in your build:

<dependency>
  <groupId>de.mkammerer.wiremock-junit5</groupId>
  <artifactId>wiremock-junit5</artifactId>
  <version>1.1.0</version>
  <scope>test</scope>
</dependency>

then use WireMockExtension in your code:

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import java.net.URI;
import de.mkammerer.wiremock.WireMockExtension;

public class YourTest {
    @RegisterExtension
    WireMockExtension wireMock = new WireMockExtension();

    @Test
    void test() {
        wireMock.stubFor(
            WireMock.get("/hello").willReturn(WireMock.ok("world"))
        );
        URI uri = wireMock.getBaseUri().resolve("/hello");
        
        // Now make your call against uri, wiremock will answer with "world"
    }
}

The extension exposes the same API as WireMockServer.

See the test as a reference.

Changelog

The changelog can be found here.

License

LGPLv3

Versions

Version
1.1.0
1.0.0
0.9