Questions tagged [pact]

Pact is a cross-language tool that provides Consumer Driven Contracts testing.

A Contract is a collection of agreements between a client (Consumer) and an API (Provider) that describes the interactions that can take place between them.

Consumer Driven Contracts is a pattern that drives the development of the Provider from its Consumers point of view.

Pact is a testing tool that guarantees those Contracts are satisfied.

pact.io

658 questions
20
votes
4 answers

What should be the scope of a Pact provider test?

My organization started to use Pact for creating/verifying contracts between REST services/micro services written in Java about half a year ago. We have a hard time deciding what the appropriate scope or grasp of a provider test should be and would…
Joel Andersson
  • 239
  • 2
  • 7
16
votes
2 answers

PACT vs spring cloud contract tests

I am trying to understand the better tool between PACT and Spring Cloud Contract to implement Consumer Driver Contract Tests. I dont find any clear examples to find the pros and cons. I want to implement CDCT, and I dont use Spring in my project.…
user3602058
  • 219
  • 4
  • 10
15
votes
1 answer

How to implement contract testing when kafka is involved in microservice architecture?

I am currently working on a project where we have kafka implementation in micro service architecture. Were you successful in creating contract test cases for mS to kafka topic interaction please using pact-jvm ? My implementation is microservice1…
7
votes
1 answer

Injecting Mocks in NestJS Application for Contract Testing

Issue I'm looking for a way to bring up a NestJS application with mocked providers. This is necessary for provider contract tests because a service needs to be brought up in isolation. Using the Pact library, testing the provider assumes that the…
Mojo982
  • 117
  • 1
  • 10
7
votes
3 answers

Should I test all enum values in a contract?

I have a doubt about about whether I should consider a certain type of test functional or contract. Let's say I have an API like /getToolType, that accepts a {object" "myObject"} as input, and returns at type in the form {type: "[a-z]+"} It was…
rrabio
  • 143
  • 2
  • 6
6
votes
2 answers

How to define pact-specification matching rule for single string body?

I am setting up a test for a put request uploading a file. The request body in my pact-file consists of a single string, containing a mime boundary that changes for every test run. I am trying to define a regex matching rule for the request body…
Renske
  • 98
  • 9
5
votes
1 answer

Using Pact with a generated Client Api Service

I'm currently investigating Pact as part of the development of a testing strategy. It's a microservices architecture, and there are various server-to-server connections where I can see it being expectionally useful (including messaging…
EaterOfFromage
  • 351
  • 5
  • 12
5
votes
1 answer

Pact: How do I match an object whose keys match a regular expression?

I am trying to write a pact consumer test to match the following response. [ { "accountId" : 1, "permissions" : [ { "schedule" : { "01/01/2018" : false, "01/01/1900" : true …
Quincy Bowers
  • 390
  • 2
  • 15
5
votes
2 answers

Why assert in @PactVerification?

I don't understand the use of assert in @PactVerification. To me it seams more like a complicated way of saying 1 == 1. For example: import static org.assertj.core.api.Assertions.assertThat; public class PactConsumerDrivenContractUnitTest { …
5
votes
3 answers

PACT .NET consumer test: flexible length array

I am using pactNet to test an API which should return an array of a flexible length. If i call "myApi/items/" it should return a list of items where the consumer does not know the exact size of. So the answer should look like this: [ { …
5
votes
1 answer

Why should we have 1 Pact file for EVERY consumer if all consumers use same API in same way?

I am trying to introduce Pact framework in our company, and one of the concerns raised was below: Scenario : This xyz API is called by 40 consumers, every consumer needs the same functionalities currently. So why should we maintain 40 Pact Files as…
PaChSu
  • 297
  • 3
  • 13
4
votes
1 answer

How to implement a simple PACT-JVM solution on existing Scala code-base

We are trying to implement a Hybrid approach for PACT-provider for Scala. We're looking for a simple example of Pact-JVM-provider side implementation using PACT-JVM (Java variant) We've the project code-base in Scala, but would like to try Pact JVM…
user2451016
  • 1,857
  • 3
  • 20
  • 44
4
votes
2 answers

Pact Spring/JUnit5, "At least one pact source must be present on the test class"

I'm trying to create a pact verification test with Pact/Junit5. This is the example I started with: @Provider("myAwesomeService") @PactFolder("pacts") class MockMvcTestTargetStandaloneMockMvcTestJava { @BeforeEach void…
drone
  • 43
  • 5
4
votes
1 answer

How to inject dynamic id for Pact test from provider to consumer using REST Assured

I need to check an api of the type /meeting/id using Pact tests and REST Assured. The id may change and I'd like to create an item before the test and inject their id to overwrite what is set as part of the url path for the contract but not sure how…
Francislainy Campos
  • 3,462
  • 4
  • 33
  • 81
4
votes
2 answers

How to verify stringified json in pact

I am trying to build a pact between two services using asynchronous communication. This is the code I used for generate the pact: @ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "provider", providerType =…
1
2 3
43 44