Closed RHervey-eb closed 2 years ago
Please remove pact-jvm-consumer-java8
, you don't need it and it is causing your issue.
Thanks so much for a quick response.
If I do that, is there another place where I can get the ability to use the Lambda Dsl which is indeed much easier to manage/read?
I'm referring to this: https://docs.pact.io/implementation_guides/jvm/consumer#a-lambda-dsl-for-pact
@uglyog My direct question is, how do I use the Lambda Dsl if I'm using Junit 5, and Java 8 with a provider and consumer?
Is that combination supported. If it is, how do I set that up (what dependencies, etc)?
JDK 8 lambda support is included by default (as the minimum is now JDK 11). You don't need a separate library for it.
The junit5 will pull in the required library as a dependency.
@uglyog I see that the LambdaDsl class is added if I use the JDK 11+ dependencies (4.2.x). This doesn't work for us since we are running Java 8 (using the 4.1.x) dependencies.
How do I get LambdaDsl to work with the producer/consumer setup given that I am running JDK8 (not 9 or later)?
To put it simply, when I have those 2 dependencies in my pom file, the LambdaDsl class is not found. How do you suggest we fix this?
The solution was simple, the needed dependencies list that worked is: (turns out the dependency artifact and group being off was the culprit) :)
<dependency>
<groupId>au.com.dius.pact.consumer</groupId>
<artifactId>junit5</artifactId>
<version>4.1.28</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>au.com.dius.pact.consumer</groupId>
<artifactId>java8</artifactId>
<version>4.1.28</version>
</dependency>
<dependency>
<groupId>au.com.dius.pact.provider</groupId>
<artifactId>junit5</artifactId>
<version>4.1.28</version>
<scope>test</scope>
</dependency>
Expected behavior -> When running junit5 using the latest Pact version for java 8 in IDE, be able to run the consumer and provider tests (separate run for each) as well as on the command line (using mvn and only including the requisite test classes).
Actual behavior -> Running the test using the IDE or mvn produces the following error:
When I exclude the dependency
au.com.dius.pact.core:support
then I am able to run the consumer test (but, obviously not the provider tests)Versions used:
Looking at the code changes, it appears the class and method that's missing the expected argument is in the ExpressionParser.kt.
Link to the change: https://github.com/pact-foundation/pact-jvm/commit/d3f49648c064ace5e95334ffe6faa6088ec812e9#diff-60f5a5b831e279e4b778ce72ce319289d154ab60ec3535191a0737371c817c8d
Please let me know how to be able to run both consumer and provider tests (I'm doing Async validation if that helps) in the same project.