-
-
Notifications
You must be signed in to change notification settings - Fork 481
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
Feature Request: Individual Consumer Test Case per Async Message Interaction #1801
Comments
Just saw that the example https://github.com/pact-foundation/pact-jvm/blob/master/consumer/junit5/src/test/groovy/au/com/dius/pact/consumer/junit5/V4AsyncMessageTest.groovy mentioned above the second test takes |
I gave this a little try by defining a |
I did have a brief look at this, but it looks very challenging. It will require a refactor so that the |
Fiddled around with this a bit to create a POC, added as #1815 . Implementation details are commented there. |
TLDR: Having a single test case for multiple message types to the same parser cause fast failing of the test and make it hard to determine, which message was faulty. It would be easier to have one test per interaction, which is currently only possible when defining that manually.
Assuming I got that right, the currently recommended way to pass multiple interactions of the same message parser by referencing all interactions described by
@Pact
using thepactMethods
annotation. The messages will then be passed as a list to the@PactFor
method. This has two major consequences for failed parsing.assertAll
, but isn't very nice nevertheless.@PactFor
method which one of the parsed messages corresponds to which of the interactions. The only point of reference is the current index of the loop on the message list. The content cannot be used to infer information, as it already has been converted to a byte array.The only way to circumvent this currently (to my knowledge) is to define a
@PactFor
method for each of the interactions. However, those methods would only differ in their name and their value forpactMethod
.Solution Approach:
Use a similar solution to the Provider Test implementation relying on the
@TestTemplate
annotation. I haven't work with this so far, so I don't know if that possible or which changes would be required.An example based on https://github.com/pact-foundation/pact-jvm/blob/master/consumer/junit5/src/test/groovy/au/com/dius/pact/consumer/junit5/V4AsyncMessageTest.groovy
Edit: Fixed test template assertions to be actually applicable to both interactions.
The text was updated successfully, but these errors were encountered: