New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to handle pact:verify with dependencies to other µServices ? #755
Comments
The best approach is to stub out the interactions downstream when verifying an interaction upstream. You can use a web mock server (like Mocky, Mock-Server ot the pact-stub-server), or if you are using JUnit tests to verify, you can either mock out the call to the downstream client code or use something like Wiremock. |
Thanks for your answer. Yes, I am on board with the mocking. However, since I'm using maven for the pact verify, I don't have a way to launch a mock from there (as far as I could tell). is there a way to do this with the pact-provider-maven ? Otherwise, the only place where I could launch mock through java would be the pact state change, which is not the most convenient, in my opinion. |
With Maven you can bind the plugin goals to a phase. There is an integration test phase, which has a |
Thank you. The problem in our case is that all our IT tests are bound to those phases, including the ones that do not run against pact. Not all ITs are linked to testing the interface with other µServices, and may mock within the test with other tools/context etc. |
You could use a different port for the mock server, and the tests could configure the port appropriately. But to be honest, I think using Pact Provider Junit is the better way as it gives you more control, you can use mock libraries like Mockito and you don't have to have the whole server running for the test. But, yes, nobody has raised this as an issue before ;-). |
Yes, the problem with using different port is the µService only communicates with a defined one, and I'd like to avoid redeploying each time I need a new mock, that is too costly in terms of execution time. But alright, I agree given our discussion that Pact Provider Junit is the best suited solution for our needs. |
Hello,
I was wondering if there was a common way to handle the following case:
Let's say I have 3 services that interact like this: (A) ==> (B) ==> (C)
Naturally, I have pacts between A & B, and B & C
The issue is, when B is verifying the contract from consumer A, it fails because C isn't running (and it needs to have C running for the pact to return the expected result).
We're using provider states already, but usually they pertain to data that need to exist for the pact to be verified, that can be provisioned through api.
We could, I guess, use provider states to run a mock of (C) if needed, but I was wondering if others were facing this issue and if this was the recommended way for such case or if I missed something ?
One of my issue with this solution, is that it implies that (A) needs to have a state that would be something like "given (C) is running' which doesn't make much sense (it's not something they should have to know).
Thanks in advance for any inputs, ideas ?
The text was updated successfully, but these errors were encountered: