pact-foundation / pact-jvm

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://docs.pact.io
Apache License 2.0
1.08k stars 479 forks source link

Enable code coverage computation #172

Closed C-Otto closed 7 years ago

C-Otto commented 8 years ago

I fail to use jacoco to compute code coverage for my PACT tests. I expect the tested class to be (partially) covered, instead I see no coverage at all. I assume this is because PACT starts a new thread/JVM which is not instrumented by jacoco.

uglyog commented 8 years ago

Are you referring to coverage in the consumer tests? What build tool do you use to run the tests?

I have jacoco coverage working, but that is with Gradle + Groovy Pact DSL + Spock.

C-Otto commented 8 years ago

Sorry, that was very imprecise.

I'd like to see coverage when running consumer tests (against the mock server provided by PACT). I run maven with jacoco (pact-jvm-consumer-junit_2.11 version 3.1.0).

uglyog commented 8 years ago

I have coverage working with Maven and with both Spock and JUnit but with groovy code. I'll try with the Pact Java DSL next.

chrisesharp commented 6 years ago

@uglyog I see exactly this problem...how did you get it working with Pact Java DSL and JUnit?

chrisesharp commented 6 years ago

To answer my own question....by switching from JUnit4 to JUnit5!

sherifkayad commented 5 months ago

@uglyog when you say you have the coverage working, do you mean you can know from the consumer side, how many interfaces / interactions are covered with Pact tests? .. Are you keen on sharing your code?

rholshausen commented 5 months ago

No, this is just normal code coverage.