Skip to content

MDoswaldSchiller/wiremock-junit5

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A JUnit 5 extension for WireMock

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%