-
Notifications
You must be signed in to change notification settings - Fork 145
pact-python manages the mock service #8
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
Conversation
- Pact now has a `start` method that will start the Ruby mock service - Pact also has a `stop` method that is expected to be called elsewhere in the user’s test code - This work is incomplete, the end to end tests don’t produce the desired JSON file as the service is wiping the interactions too soon - The README.md needs to be updated with new instructions based on these changes
- Change the API so the user can control when the mock service starts and stops - Update the README.md to illustrate controlling the mock service - Switch the command line arguments to the mock service to be separate items in a list so that they are properly quoted for the shell - Increment the project to version 0.2.0
|
You're a machine! Great stuff. |
|
One thing to consider is when the verification call is made. You may want to consider exposing this to the DSL somehow to the user. In larger Pact tests, if you have several request/response related unit tests but one of them doesn't call the mock service correctly, you won't know if it fails until the process exists (based on what I can glean, this occurs using Line 221 in 4bf7b8b
This could make it hard to see why or where the test failed (i.e. which tests didn't send through the Interaction or sent an unexpected one). |
Python has a concept called context managers that allow you to run code before and after a block, for example: pact = Consumer('Consumer').has_pact_with(Provider('Provider'))
with.pact:
# perform my testsBefore my tests I'll ponder that for a bit and may rearrange some things to make it more clear. |
|
Is that at the test class level or individual tests? Another thing to consider is that people may break up tests to a single provider across files as pact tests can be quite lengthy, and that they'll need to use the same running mock server for all of them (this will be made easier when we get the shared lib). That being said, having an opinionated workflow isn't necessarily a bad thing. |
- Extracted the logic configuring the mock service and verifying interactions to methods for users if they need more control than a context manager provides
|
@mefellows I pulled out the setup/verify logic to separate methods so users now have two ways to use the
I also renamed the |
|
That seems like a great compromise @matthewbalvanz-wf! |
resolves #5 and possibly #7
@mefellows @jslvtr