Versions of artifact au.com.dius:pact-jvm-provider-junit_2.11

pact-jvm-provider-junit_2.11

# Pact junit runner ## Overview Library provides ability to play contract tests against a provider service in JUnit fashionable way. Supports: - Out-of-the-box convenient ways to load pacts - Easy way to change assertion strategy - **org.junit.BeforeClass**, **org.junit.AfterClass** and **org.junit.ClassRule** JUnit annotations, that will be run once - before/after whole contract test suite. - **org.junit.Before**, **org.junit.After** and **org.junit.Rule** JUnit annotations, that will be run before/after each test of an interaction. - **au.com.dius.pact.provider.junit.State** custom annotation - before each interaction that requires a state change, all methods annotated by `@State` with appropriate the state listed will be invoked. These methods must either take no parameters or a single Map parameter. ## Example of HTTP test ```java @RunWith(PactRunner.class) // Say JUnit to run tests with custom Runner @Provider("myAwesomeService") // Set up name of tested provider @PactFolder("pacts") // Point where to find pacts (See also section Pacts source in documentation) public class ContractTest { // NOTE: this is just an example of embedded service that listens to requests, you should start here real service @ClassRule //Rule will be applied once: before/after whole contract test suite public static final ClientDriverRule embeddedService = new ClientDriverRule(8332); @BeforeClass //Method will be run once: before whole contract test suite public static void setUpService() { //Run DB, create schema //Run service //... } @Before //Method will be run before each test of interaction public void before() { // Rest data // Mock dependent service responses // ... embeddedService.addExpectation( onRequestTo("/data"), giveEmptyResponse() ); } @State("default", "no-data") // Method will be run before testing interactions that require "default" or "no-data" state public void toDefaultState() { // Prepare service before interaction that require "default" state // ... System.out.println("Now service in default state"); } @State("with-data") // Method will be run before testing interactions that require "with-data" state public void toStateWithData(Map data) { // Prepare service before interaction that require "with-data" state. The provider state data will be passed // in the data parameter // ... System.out.println("Now service in state using data " + data); } @TestTarget // Annotation denotes Target that will be used for tests public final Target target = new HttpTarget(8332); // Out-of-the-box implementation of Target (for more information take a look at Test Target section) } ``` ## Example of AMQP Message test ```java @RunWith(PactRunner.class) // Say JUnit to run tests with custom Runner @Provider("myAwesomeService") // Set up name of tested provider @PactBroker(host="pactbroker", port = "80") public class ConfirmationKafkaContractTest { @TestTarget // Annotation denotes Target that will be used for tests public final Target target = new AmqpTarget(); // Out-of-the-box implementation of Target (for more information take a look at Test Target section) @BeforeClass //Method will be run once: before whole contract test suite public static void setUpService() { //Run DB, create schema //Run service //... } @Before //Method will be run before each test of interaction public void before() {

Artifact Version Name Latest uploaded at
3.5.0-beta.4 pact-jvm-provider-junit_2.11 2017-05-14 11:51:00 UTC
3.3.10 pact-jvm-provider-junit_2.11 2017-05-18 04:03:01 UTC
3.4.0 pact-jvm-provider-junit_2.11 2017-05-18 05:39:21 UTC
3.5.0-rc.1 pact-jvm-provider-junit_2.11 2017-05-25 03:43:48 UTC
3.4.1 pact-jvm-provider-junit_2.11 2017-06-11 02:04:00 UTC
3.5.0-rc.2 pact-jvm-provider-junit_2.11 2017-06-11 07:14:04 UTC
3.5.0-rc.3 pact-jvm-provider-junit_2.11 2017-06-20 23:41:11 UTC
3.5.0 pact-jvm-provider-junit_2.11 2017-06-24 08:12:05 UTC
3.5.0-jre7 pact-jvm-provider-junit_2.11 2017-06-24 11:27:13 UTC
3.5.0-jre7.1 pact-jvm-provider-junit_2.11 2017-06-24 13:17:12 UTC
3.5.1-jre7.1 pact-jvm-provider-junit_2.11 2017-07-09 06:56:40 UTC
3.5.1 pact-jvm-provider-junit_2.11 2017-07-09 08:18:10 UTC
3.5.2-jre7.0 pact-jvm-provider-junit_2.11 2017-07-12 00:37:54 UTC
3.5.2 pact-jvm-provider-junit_2.11 2017-07-12 01:12:06 UTC
3.5.3 pact-jvm-provider-junit_2.11 2017-08-06 07:58:17 UTC