-
Notifications
You must be signed in to change notification settings - Fork 28
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
Potential new feature - add an optional comments to the interaction #45
Comments
in our case, this could be entirely satisfied by exposing test names to the broker. Of course, this is a challenge with some test frameworks. |
Yes, it's easy enough in Ruby, but I don't know how many other languages expose it. |
I'm not sure how I feel about this, albeit I can see the need to want to be able to link in with other tools. Perhaps some more context of your use case @TimothyJones would help in finding an appropriate solution? |
@mefellows: the initial issue surfaces as:
I think it's solvable in a few ways, including (but probably not limited to):
2 is a bit hard (maybe impossible) to do automatically, and adding this comment facility is a workaround for that, but also maybe useful for other things? |
It's an interesting point. One thing we've been discussing is the ability to share provider states via the Broker, so that everyone can easily understand the various states of the system (and to avoid duplication in the Provider). Another feature is creating a PR-like process for consumers to request new features/states/etc. from the Provider, essentially enforcing an approval workflow before the pact is 'accepted'. This mitigates a number of situations, the main one being consumers breaking Provider builds because a new state or expectation has been shoved in the system without prior consultation. There is opportunity to capture some of this as part of that process too. I can't quite articulate why this feature doesn't feel right to me belonging in the specification, perhaps because it's specific or not general enough (maybe |
I think it feels wrong because it's immaterial. A mechanism like PRs might work. My approach to that is normally: consumers talk to providers to build the thing before they depend on it with a pact. It's not a great solution, by any means, but it's the simplest for a declaratice-currency world: it seems unreasonable to declare a dependency before the dependency is available. Drifting dependencies is a totally separate issue, which Pact addresses nicely. I guess it depends what specific problems you're trying to solve. Is Pact for contract management, or just verification? Migration or current state? etc. |
I think a metadata section would be better for this, because then you could have keys to provide some context. I.e. {
"interactions": [
{
...
"metadata": {
"comments": ["This allows me to specify just a bit more information about the interaction",
"It has no functional impact, but can be displayed in the broker HTML page, and potentially in the test output",
"It could even contain the name of the running test on the consumer side to help marry the interactions back to the test case"],
"testname": "example_test.groovy"
}
}
]
} A problem is that message interactions already have a metadata section for message metadata (for things like destination channel names and content types), so it would need a different key. |
What if the whole section were called comments? That would clearly communicate that it isn't data that's expected to be part of the contract.
As an aside, the |
Implemented the following in Pact-JVM: JUnit DSL in Test: .given("good state")
.comment("This is a comment")
.uponReceiving("V3 PactProviderTest test interaction")
.path("/")
.method("GET")
.comment("Another comment")
.willRespondWith()
.status(200)
.body("{\"responsetest\": true, \"version\": \"v3\"}")
.comment("This is also a comment")
.toPact(V4Pact.class); Pact file contents: {
"interactions": [
{
"comments": {
"testname": "runTest(au.com.dius.pact.consumer.junit.v4.V4HttpPactTest)",
"text": [
"This is a comment",
"Another comment",
"This is also a comment"
]
},
"description": "V3 PactProviderTest test interaction"
} Output when verifying:
|
Cool! Given that we're following camel case naming, is it too late to change 'testname' to 'testName'? |
Comments displayed in the Rust verifier
|
While the addition of `set_comment` allows for the comments to be used as per the Pact specification, it did not follow the original intent for comments (see the discussion in pact-foundation/pact-compatibility-suite#8). The new `add_text_comment` function allows comments to be added repeatedly and appended into an array as intended in pact-foundation/pact-specification#45. Signed-off-by: JP-Ellis <[email protected]>
While the addition of `set_comment` allows for the comments to be used as per the Pact specification, it did not follow the original intent for comments (see the discussion in pact-foundation/pact-compatibility-suite#8). The new `add_text_comment` function allows comments to be added repeatedly and appended into an array as intended in pact-foundation/pact-specification#45. Signed-off-by: JP-Ellis <[email protected]>
While the addition of `set_comment` allows for the comments to be used as per the Pact specification, it did not follow the original intent for comments (see the discussion in pact-foundation/pact-compatibility-suite#8). The new `add_text_comment` function allows comments to be added repeatedly and appended into an array as intended in pact-foundation/pact-specification#45. Signed-off-by: JP-Ellis <[email protected]>
I had a discussion with Andras and Tim the other day that resulted in this suggestion:
cc: @mefellows @uglyog @TimothyJones @abubics
The text was updated successfully, but these errors were encountered: