Closed LinghaoYu closed 3 years ago
The Pact framework does not support chaining interactions in this way. Each is verified in isolation. Using the provider states is the correct way to test these. You can use values from the provider state callbacks to inject into the request. See https://stackoverflow.com/questions/63955575/how-to-inject-dynamic-id-for-pact-test-from-provider-to-consumer-using-rest-assu and https://pactflow.io/blog/injecting-values-from-provider-states/
My scenario is that there are two interactions defined by the consumer, interation1 with state1, and interation2 with state2. After running interation1, there will be an id in the JSON response, and this id has to be used as the query parameter of interation2. On the provider side, is there a way to extract that id from the response of interation1? I am using pact provider junit by the way.