pact-foundation / pact-jvm

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://docs.pact.io
Apache License 2.0
1.07k stars 473 forks source link

Consumer using PactJS and Provider using PactJVM issue with interactions filtering #1773

Closed rakeyshc closed 3 months ago

rakeyshc commented 3 months ago

This is more of a question than a issue to be honest.

My consumer application which is a single page application uses Pact JS to product the json file by naming my consumer as frontend-project-name for a service-1-backend-project-name.

My consumer i.e. frontend interacts with different endpoints on the same service-1-backend-project-name. All the interactions I make end up in the same consumer file as per the OOTB pact behaviour I hunch.So for example if I am executing the tests for states a. get details of the item id b. getAll items c. create item d. delete item e. update item

  1. get details of the key id
  2. getAll keys
  3. create key

So in the Above my consumer json file will have a + b + c + d + e + 1 + 2 + 3

Now on the provider side i have a Pact JVM Spring based implementation for service-1-backend-project-name as provider and my requirement is to obliviously test the contract layer here but problem is now after introducing

interactions 1 , 2 and 3 above

My Provider test class 1 i.e. ItemsProviderTest starts to expect the interactions for 1,2,3

whereas

My Provider test class 2 i.e. KeysProviderTest starts to expect the interactions for a,b,c,d,e

I am not able to understand how can I neglect or filter only test states for given test methods in a particular provider class.

I tried using @IgnoreMissingStateChange but the provider test class still reads all the interactions

rificationStateChangeExtension$Companion : Did not find a test class method annotated with

image
rakeyshc commented 3 months ago

@PactFilter("matching string")

@PactVerifyProvider("matching string") does the trick