Groovy consumer test does not report the real reason behind failure
See original GitHub issueWhen running a consumer test and the closure passed into PactBuilder.run() throws an exception, the exception is caught and the test fails, but the real reason is not printed in the console.
The exception ends up in PactMismatch.userError, but PactMismatch.toString() does not print it out.
Example:
import au.com.dius.pact.consumer.PactVerified$
import au.com.dius.pact.consumer.VerificationResult
import au.com.dius.pact.consumer.groovy.PactBuilder
import org.junit.Test
class SwallowingUserErrorPactTest {
@Test
def void 'create a person'() {
def myService = new PactBuilder()
myService {
serviceConsumer 'some consumer'
hasPactWith 'some provider'
uponReceiving 'a request to create a person'
port 1234
withAttributes(
method: 'post',
path: '/person',
)
willRespondWith(
status: 200
)
}
VerificationResult result = myService.run() {
throw new RuntimeException('this is not reported')
}
assert result == PactVerified$.MODULE$
}
}
The output is
assert result == PactVerified$.MODULE$
| | |
| false Pact verified.
Pact verification failed for the following reasons:
The following requests were not received:
Interaction: a request to create a person
...
but there is no mention of ‘this is not reported’
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Groovy consumer test does not report the real reason behind ...
When running a consumer test and the closure passed into PactBuilder.run() throws an exception, the exception is caught and the test fails, ...
Read more >Error compiling the test file generated from spring cloud ...
I think your problem my come from a wrong declaration inside here: body([ "docId" : value(consumer('D1111'), producer(regex('.
Read more >Why tests pass locally but fail in Jenkins | Object Partners
I've seen this occur when the test assertions are actually completed before the async calls finish. If possible, you should run your assertions ......
Read more >Solved: Groovy Rerun Failed Test Case Execution Report
It is being addressed the issue incorrectly. First look for the reason why it is happening. If the services works with definitive behavior,...
Read more >Writing Contract Tests with Pact in Spring Boot - kreuzwerker
The provider test fails because the consumer's contract is violated since it expects the name field. Provider changes date format. The provider ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@uglyog if the issue is that only a single exception can be thrown, wouldn’t it be possible to wrap all the root cause exceptions into a single exception and throw that? It could then print out the messages from all the root causes providing as much detail to the user as possible.
For your test, the output is a little bit ugly, but it is all there: