I have one consumer, and one provider and between ...
# general
t
I have one consumer, and one provider and between these I have two different APIs (it is a mono-repo that builds two different versions of an application, but for the sake of trying to keep it simple, lets just say there are two separate APIs, and both are to be tested before the "split" occurs). I have an IT (integration test) in which I want to test these; and I started out on the consumer side, having two
@Pact
methods, and two
@PactTestFor
methods. Each such method sends its own request with its json payload. Both tests have equal provider, and equal consumer identifier. I tried to separate them by using different strings for the "given" statement in each test. That seemed to work, until the provider test ran. So, I tried two different tests on the Provider to, one where I filter out the "first given", and another where I filter the "second given", but the tests fail since not all interactions get recorded.
r
The best way would be to change two different consumer IDs, maybe put a suffix depending on the API
🙏 1
t
Thank you, I will try that!
@rholshausen Do I need to think about something on the provider side of this? It would receive pacts for both consumers, right..?
r
Yes, that is fine. Both will be verified
t
What if I have two tests in provider.. do I need a filter of some kind?
or.. do I need two providers then as well?
Maybe that is just the easiest way.. I thought it would be nice to have a smaller "matrix" but maybe that is not that important
r
No, the provider test can test both pact files
👋 1
You only need one provider test
t
Thank you!
@rholshausen I still cant get my head around this... I now have: Consumer: "consumer1" -> "provider1" (one junit test for api 1) "consumer1" -> "provider2" (one junit test for api 2) Provider: provider1 junit test that should test consumer1 (api1), breaks because:
Copy code
Did not find a test class method annotated with @State("api2") 
for Interaction "[name for api2 interaction]" 
with Consumer "consumer1"
provider2 junit test that should test consumer1 (api2), breaks because:
Copy code
Did not find a test class method annotated with @State("api1") 
for Interaction "[name for api1 interaction]" 
with Consumer "consumer1"
Do I need tags or something to filter more?
I cannot have one single provider, since the provider uses either api1 OR api2 when it is running.
and the Pact test starts the application, starts testcontainers etc, and we try to process the request from Pact to verify it works.