General question about the jvm pact implementation...
# pact-jvm
m
General question about the jvm pact implementation: when I run provider tests, I’m finding it very hard to diagnose test failures - output sent from the test through println does not appear on the console, and debug statements are not hit. How do people track down issues?
m
are you using JUnit?
there should be an HTML report that is really easy to read
m
Yes, JUnit
Is there a reason to think that output would go to the report that does not go to the console? That has not been my experience with non-generated tests in general
But that’s just a workaround - what I really need is to be able to debug. Maybe have access to a dummy test being generated by the pact annotation
m
I’m not sure, I’m not a java/jvm expert, I just know as a consumer that it can be sometimes hard to see amongst all of the other logging noise
and the html report that is generated is the most helpful I’ve experienced
I hardcoded a method to do turn the requests into curl which you can verify visually or through postman or any other api client. Maybe it’d be useful to you.
You can also log the failures to a .md file by adding this annotation to the top of your provider.
Copy code
@VerificationReports(value = {"markdown"}, reportDir = "target/pacts")
As in
Copy code
@VerificationReports(value = {"markdown"}, reportDir = "target/pacts")
public class PactProviderGcTest {
This would make the failures a bit easier to read. The file will generate under the same autogenerated target folder for pacts.
m
ooooh thanks @Francislainy Campos!
👍 1
The curl I mean - would be nice to debug the tests but this might get you to what the test is producing quick and would allow you to debug the server.
f
Yes, but the annotation is one line only so you can easily do both.
m
Maybe I’m confused, but the annotation looks like it will just output Pact’s own known data in its own format. I was looking for the option to log debug information for particular issues to the output. The curl doesn’t tell you how the test produced the json, but it sounds like it serves the same purpose
f
yes, the annotation is not for the request but for better viewing the pact error messages.
👍 1
The SO post with the curl method will give you the request and response.
m
Very cool!
🌮 for @Francislainy Campos
👍 1
f
It would be nice to have sth like this out of the box.
I’ll give the code away for free if you guys would add that in. 😉
@Matt (pactflow.io / pact-js / pact-go) @uglyog any plans to bring this in as a feature at some point: https://github.com/pact-foundation/pact-jvm/issues/1507 ?
@Phil maybe you can answer? Thank you.