is not current version
Last Version 3.5.24

au.com.dius:pact-jvm-consumer-junit_2.11 2.0.9

pact-jvm-consumer-junit ======================= Bindings for the junit library ##Dependency The library is available on maven central using: group-id = `au.com.dius` artifact-id = `pact-jvm-consumer-junit_2.10` version-id = `2.0.6` ##Usage To write a pact spec extend ConsumerPactTest Here is an example: ``` import au.com.dius.pact.model.PactFragment; import java.util.HashMap; import java.util.Map; import static org.junit.Assert.assertEquals; public class ExampleJavaConsumerPactTest extends ConsumerPactTest { @Override protected PactFragment createFragment(ConsumerPactBuilder.PactDslWithProvider builder) { Map<String, String> headers = new HashMap<String, String>(); headers.put("testreqheader", "testreqheadervalue"); return builder .given("test state") // NOTE: Using provider states are optional, you can leave it out .uponReceiving("java test interaction") .path("/") .method("GET") .headers(headers) .body("{\"test\":true}") .willRespondWith() .status(200) .headers(headers) .body("{\"responsetest\":true}").toFragment(); } @Override protected String providerName() { return "test_provider"; } @Override protected String consumerName() { return "test_consumer"; } @Override protected void runTest(String url) { try { assertEquals(new ConsumerClient(url).get("/"), "{\"responsetest\":true}"); } catch (Exception e) { // NOTE: if you want to see any pact failure, do not throw an exception here. This should be // fixed at some point (see Issue #40 https://github.com/DiUS/pact-jvm/issues/40) throw new RuntimeException(e); } } } ``` ## Debugging pact failures When the test runs, Pact will start a mock provider that will listen for requests and match them against the expectations you setup in `createFragment`. If the request does not match, it will return a 500 error response. Each request received and the generated response is logged using [SLF4J](http://www.slf4j.org/). Just enable debug level logging for au.com.dius.pact.consumer.UnfilteredMockProvider. Most failures tend to be mismatched headers or bodies.

Categories

Categories

JUnit Unit Testing
GroupId

GroupId

au.com.dius
ArtifactId

ArtifactId

pact-jvm-consumer-junit_2.11
Version

Version

2.0.9
Type

Type

jar

Download pact-jvm-consumer-junit_2.11 2.0.9


<!-- https://jarcasting.com/artifacts/au.com.dius/pact-jvm-consumer-junit_2.11/ -->
<dependency>
    <groupId>au.com.dius</groupId>
    <artifactId>pact-jvm-consumer-junit_2.11</artifactId>
    <version>2.0.9</version>
</dependency>
// https://jarcasting.com/artifacts/au.com.dius/pact-jvm-consumer-junit_2.11/
implementation 'au.com.dius:pact-jvm-consumer-junit_2.11:2.0.9'
// https://jarcasting.com/artifacts/au.com.dius/pact-jvm-consumer-junit_2.11/
implementation ("au.com.dius:pact-jvm-consumer-junit_2.11:2.0.9")
'au.com.dius:pact-jvm-consumer-junit_2.11:jar:2.0.9'
<dependency org="au.com.dius" name="pact-jvm-consumer-junit_2.11" rev="2.0.9">
  <artifact name="pact-jvm-consumer-junit_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='au.com.dius', module='pact-jvm-consumer-junit_2.11', version='2.0.9')
)
libraryDependencies += "au.com.dius" % "pact-jvm-consumer-junit_2.11" % "2.0.9"
[au.com.dius/pact-jvm-consumer-junit_2.11 "2.0.9"]