Versions of artifact


# Pact Spring/JUnit runner ## Overview Library provides ability to play contract tests against a provider using Spring & JUnit. This library is based on and references the JUnit package, so see [junit provider support](pact-jvm-provider-junit) for more details regarding configuration using JUnit. Supports: - Standard ways to load pacts from folders and broker - Easy way to change assertion strategy - Spring Test MockMVC Controllers and ControllerAdvice using MockMvc standalone setup. - MockMvc debugger output - Multiple @State runs to test a particular Provider State multiple times - **** custom annotation - before each interaction that requires a state change, all methods annotated by `@State` with appropriate the state listed will be invoked. **NOTE:** For publishing provider verification results to a pact broker, make sure the Java system property `pact.provider.version` is set with the version of your provider. ## Example of MockMvc test ```java @RunWith(RestPactRunner.class) // Custom pact runner, child of PactRunner which runs only REST tests @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 { //Create an instance of your controller. We cannot autowire this as we're not using (and don't want to use) a Spring test runner. @InjectMocks private AwesomeController awesomeController = new AwesomeController(); //Mock your service logic class. We'll use this to create scenarios for respective provider states. @Mock private AwesomeBusinessLogic awesomeBusinessLogic; //Create an instance of your controller advice (if you have one). This will be passed to the MockMvcTarget constructor to be wired up with MockMvc. @InjectMocks private AwesomeControllerAdvice awesomeControllerAdvice = new AwesomeControllerAdvice(); //Create a new instance of the MockMvcTarget and annotate it as the TestTarget for PactRunner @TestTarget public final MockMvcTarget target = new MockMvcTarget(); @Before //Method will be run before each test of interaction public void before() { //initialize your mocks using your mocking framework MockitoAnnotations.initMocks(this); //configure the MockMvcTarget with your controller and controller advice target.setControllers(awesomeController); target.setControllerAdvice(awesomeControllerAdvice); } @State("default", "no-data") // Method will be run before testing interactions that require "default" or "no-data" state public void toDefaultState() { target.setRunTimes(3); //let's loop through this state a few times for a 3 data variants when(awesomeBusinessLogic.getById(any(UUID.class))) .thenReturn(myTestHelper.generateRandomReturnData(UUID.randomUUID(), ExampleEnum.ONE)) .thenReturn(myTestHelper.generateRandomReturnData(UUID.randomUUID(), ExampleEnum.TWO)) .thenReturn(myTestHelper.generateRandomReturnData(UUID.randomUUID(), ExampleEnum.THREE)); } @State("error-case") public void SingleUploadExistsState_Success() { target.setRunTimes(1); //tell the runner to only loop one time for this state //you might want to throw exceptions to be picked off by your controller advice when(awesomeBusinessLogic.getById(any(UUID.class))) .then(i -> { throw new NotCoolException(i.getArgumentAt(0, UUID.class).toString()); }); } } ``` ## Using a Spring runner (version 3.5.7+) You can use `SpringRestPactRunner` instead of the default Pact runner to use the Spring test ann

Artifact Version Name Latest uploaded at
3.5.18 pact-jvm-provider-spring_2.11 2018-06-17 08:28:32 UTC
3.5.17 pact-jvm-provider-spring_2.11 2018-06-03 06:28:49 UTC
3.5.16 pact-jvm-provider-spring_2.11 2018-05-06 11:04:38 UTC
3.5.15 pact-jvm-provider-spring_2.11 2018-04-22 06:56:31 UTC
3.5.14 pact-jvm-provider-spring_2.11 2018-03-19 03:43:18 UTC
3.5.13 pact-jvm-provider-spring_2.11 2018-02-22 21:15:59 UTC
3.5.12 pact-jvm-provider-spring_2.11 2018-01-27 01:52:54 UTC
3.5.11 pact-jvm-provider-spring_2.11 2017-12-22 00:28:05 UTC
3.5.10 pact-jvm-provider-spring_2.11 2017-11-21 22:01:28 UTC
3.5.9 pact-jvm-provider-spring_2.11 2017-11-15 04:09:31 UTC
3.5.8 pact-jvm-provider-spring_2.11 2017-10-13 02:45:50 UTC
3.5.7-jre7.0 pact-jvm-provider-spring_2.11 2017-10-03 05:55:24 UTC
3.5.7 pact-jvm-provider-spring_2.11 2017-10-03 00:51:50 UTC
3.5.6-jre7.0 pact-jvm-provider-spring_2.11 2017-09-28 05:20:30 UTC
3.5.6 pact-jvm-provider-spring_2.11 2017-09-27 02:19:29 UTC
3.5.5-jre7.0 pact-jvm-provider-spring_2.11 2017-09-14 02:41:18 UTC
3.5.5 pact-jvm-provider-spring_2.11 2017-09-11 23:16:08 UTC
3.5.4-jre7.0 pact-jvm-provider-spring_2.11 2017-08-19 08:02:44 UTC
3.5.4 pact-jvm-provider-spring_2.11 2017-08-18 05:41:14 UTC
3.5.3-jre7.0 pact-jvm-provider-spring_2.11 2017-08-10 00:34:07 UTC
3.5.3 pact-jvm-provider-spring_2.11 2017-08-06 08:02:48 UTC
3.5.2 pact-jvm-provider-spring_2.11 2017-07-12 01:15:04 UTC
3.5.2-jre7.0 pact-jvm-provider-spring_2.11 2017-07-12 00:40:52 UTC
3.5.1 pact-jvm-provider-spring_2.11 2017-07-09 08:21:07 UTC
3.5.1-jre7.1 pact-jvm-provider-spring_2.11 2017-07-09 06:59:59 UTC
3.5.0-jre7.1 pact-jvm-provider-spring_2.11 2017-06-24 13:20:19 UTC
3.5.0-jre7 pact-jvm-provider-spring_2.11 2017-06-24 11:30:31 UTC
3.5.0 pact-jvm-provider-spring_2.11 2017-06-24 08:15:12 UTC
3.5.0-rc.3 pact-jvm-provider-spring_2.11 2017-06-20 23:44:03 UTC
3.5.0-rc.2 pact-jvm-provider-spring_2.11 2017-06-11 07:17:05 UTC