Bas Dijkstra
02/24/2025, 7:25 AMShrinivas Khawase
02/24/2025, 8:52 AMau.com.dius.pact.consumer:junit Version 4.6.14
but we often get the error mentioned below which blocks our pipeline , has anyone else faced this ?Its not consistent but occurs randomly
cc @Sitaram Appalla @Ramesh Kumar
Failed to transform java-semver-0.9.0.jar (com.github.zafarkhaja:java-semver:0.9.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Could not find java-semver-0.9.0.jar (com.github.zafarkhaja:java-semver:0.9.0).
Searched in the following locations:
<https://jitpack.io/com/github/zafarkhaja/java-semver/0.9.0/java-semver-0.9.0.jar>
Oleksandr Verdiev
02/24/2025, 9:58 AM"yyyy-MM-dd'T'HH:mm:ssZ"
"yyyy-MM-dd'T'HH:mm:ss.SSZ"
"yyyy-MM-dd'T'HH:mm:ss.SSSZ"
...
"yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSZ"
I have tried these so far:
return new PactDslJsonBody()
.object("Data", looksLike()
.uuid("ConsentId")
.datetime("CreationDateTime", INSTANT_ISO_DATETIME_FORMAT, Instant.now())
// "yyyy-MM-dd'T'HH:mm:ss[.[SSSSSSSSS][SSSSSSSS][SSSSSSS][SSSSSS][SSSSS][SSSS][SSS][SS][S]]'Z'";
// static final String INSTANT_ISO_DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSZ";
// static final String INSTANT_ISO_DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss[.SSSSSSSSS]Z";
static final String INSTANT_ISO_DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss(.SSSSSSSSS)?Z";
Paul Sobocinski
02/24/2025, 7:00 PMprovider.getUrl()
is returning null
, which in turn causes the test to fail before the ConsumerClient
is even invoked.
I have it set up the test and example its own repo here. The full error message I'm getting follows:
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running exampleclients.ExampleJavaConsumerPactRuleTest
Provider URL: null
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.027 s <<< FAILURE! - in exampleclients.ExampleJavaConsumerPactRuleTest
[ERROR] runTest(exampleclients.ExampleJavaConsumerPactRuleTest) Time elapsed: 0.017 s <<< FAILURE!
java.lang.AssertionError: Provider URL is null! Aborting test.
at exampleclients.ExampleJavaConsumerPactRuleTest.runTest(ExampleJavaConsumerPactRuleTest.java:57)
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] ExampleJavaConsumerPactRuleTest.runTest:57 Provider URL is null! Aborting test.
[INFO]
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
Versions used: JDK 1.8
; JUnit 4.8.2
; Pact-JVM 4.1.43
Kusuma Guntamadugu
02/25/2025, 4:15 AMval pactBody = PactDslJsonBody()
.stringMatcher("test", "^(test1|test2)$")
Przemyslaw Boszczyk
03/04/2025, 10:34 AMparameters
field is a Map<String, String> of undefined size and fields.
{
"id": "string"
"parameters": {
"additionalProp1": "string",
"additionalProp2": "string",
"additionalProp3": "string"
}
}
I'm banging my head how to tackle it:
@Pact(consumer = CONSUMER)
RequestResponsePact pact(PactDslWithProvider builder) {
return builder
.uponReceiving("Post message")
.path("/api/messages")
.method("POST")
.body(newJsonBody(body -> {
body.stringType("id", "example_id");
// body.object("parameters", values -> values.eachLike())
}).build())
.matchHeader("Content-Type", "application/json.*", "application/json")
.willRespondWith()
.status(200)
.toPact();
}
Martin Mineo
03/07/2025, 1:16 PMRuud Welling
03/14/2025, 11:10 AM@PactVerifyProvider("A command message")
public MessageAndMetadata processCommand(MessageContents messageContents) {
var jsonMessage = messageContents.getContents().valueAsString();
// this json message does not have the provider state applied
// instead it contains the example value provided by the consumer...
}
I tried to look for examples in the pact SDK, but could not really find any. Am I doing this in the right way? Is provider state supported in message pacts?Neha Munjal
03/14/2025, 11:47 PMRuud Welling
03/19/2025, 4:36 PM@Test
@PactTestFor(pactMethod = "mySyncMessagePact")
void mySyncMessagePact(V4Interaction.SynchronousMessages interaction) {
String request = "{}"; // 1: should call a method that produces the request
// 2: Validate that the request is okay according to the pact
// 3: Validate that the response message can be handled
}
How do I validate that the request message is compliant with the pact that I specified?
After looking at the library code I could not find a standard utility that allows me to easily validate thisRyan Quinn
03/25/2025, 4:19 AM@AllowOverridePactUrl
annotation set, how do I run that test class as part of my regular pipeline? It works fine when I get a request from a webhook, but I don't know how to create the appropriate URLs when running from my build pipeline. Am I confused about something?Chandramani Jha
03/26/2025, 1:22 PMSlackbot
03/26/2025, 1:22 PMErich Zimmerman
03/27/2025, 3:34 PM{
"plans": {
"ABCD32": {
"idRequired": true,
"ids": [
"1234"
]
}
}
}
I'm trying to use object(<name>)
for this, but the name isn't generally predictable.
rootResponseObject.object("plans", (plans) ->
plans.object("??????", (plan) -> {
ratePlan.booleanType("idRequired", true);
ratePlan.array("ids", (item) -> item.stringType("12345"));
})
);
I think I'm a bit confused on when we want things to be more general, and when "test by example" is the right way to go. Since I control the request and data, should I just match to that exact string as the result that fulfills the example?Adrien DEVILLERS
03/28/2025, 10:41 AMRuth
04/08/2025, 9:01 AMjava.lang.IllegalAccessException: class kotlin.reflect.jvm.internal.calls.CallerImpl$FieldGetter cannot access a member of class org.joda.time.LocalDate with modifiers "private final"
kotlin.reflect.full.IllegalCallableAccessException: java.lang.IllegalAccessException: class kotlin.reflect.jvm.internal.calls.CallerImpl$FieldGetter cannot access a member of class org.joda.time.LocalDate with modifiers "private final"
at kotlin.reflect.jvm.internal.KCallableImpl.call
Any idea what I can do? Can I use my own serializer, eg. objectMapper?Bas Dijkstra
04/08/2025, 2:11 PMmvn
, and because my provider is a Spring service, this works fine:
mvn clean "-Dpact.verifier.publishResults=true" "-Dpact.provider.version=1.0.0-address-ee07f8c04721b90be743fc1c08946663f01e6e46" test
However, I now also want to list the provider branch, but when I try this (following the docs):
mvn clean "-Dpact.verifier.publishResults=true" "-Dpact.provider.version=1.0.0-address-ee07f8c04721b90be743fc1c08946663f01e6e46" "-Dpactbroker.providerBranch=main" test
It does not record the provider branch. Any ideas? Is this even important? I know I will need it in the next step, when I'll introduce pending pacts...Shaiju B
04/21/2025, 4:02 AM<dependency>
<groupId>au.com.dius.pact.consumer</groupId>
<artifactId>junit5</artifactId>
<version>4.3.6</version>
<scope>test</scope>
</dependency>
Class
@au.com.dius.pact.consumer.junit5.Pact
Any suggestion on how I could resolve this ?Truth Opaleye
04/23/2025, 10:28 PMRishav Singh
05/14/2025, 3:49 PMjava.lang.UnsupportedOperationException: Method createPact does not conform required method signature 'public au.com.dius.pact.core.model.V4Pact xxx(PactBuilder builder)'
at au.com.dius.pact.consumer.junit.JUnitTestSupport.conformsToSignature(JUnitTestSupport.kt:35)
at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.lookupPact(PactConsumerTestExt.kt:504)
at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.setupPactForTest(PactConsumerTestExt.kt:270)
at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.setupMockServerForProvider(PactConsumerTestExt.kt:248)
at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.beforeTestExecution(PactConsumerTestExt.kt:223)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Simon Raess
05/16/2025, 1:15 PMRishav Singh
05/19/2025, 1:24 PMjava.lang.AssertionError: The following methods annotated with @Pact were not executed during the test: RulesApiConsumerTest.createPactFor200
If these are currently a work in progress, add a @Disabled annotation to the method
I don't see this error when I run them together
I have also used PactTestFor
to categorize the tests with their respective method inside my test classJames P
05/20/2025, 3:57 PMRequest to path '**********************************************contracts/publish' failed with HTTP response 500
JSON Response:
{
"error": {
"message": "source sequence is illegal/malformed utf-8",
"reference": "YeJQYFKhHV"
}
}
I think its related to use using the .matchQuery("version", "1.0.0")
as the value become encoded and then shows as "1\uB0D60\uB3DA0"
in the contract. We also have a header using .matchHeader("header", ".*")
which becomes encoded itself and then appears in the broker as "屏啾"
. We are publishing using the pact gradle plugin and the command ./gradlew pactPublish
. Weirdly though, the pipeline failed twice to publish and then with a retry for a third time it passed. I have suggested to the team to use encodedQuery
and to change the header value as its not important for the service we are using but I’m curious to know why it would fail to publish but then eventually pass with no changes, is there some sort of race condition there?GitHub
05/23/2025, 12:10 AMDeepak Chandh
05/26/2025, 12:09 PMKatrin Aleinik
06/10/2025, 3:09 PMImran Khan
06/16/2025, 11:45 AMpact.rootDir
and other configurations, but I’m still facing the same issue.
Even after adding sleep
before and after running the test cases, the tests pass, but the Pact contract file is not being generated.
Any help or pointers on how to resolve this would be greatly appreciated. Thanks in advance!
Logs when running TestCase (also looked for the path, by adding a print statement - but failed)
bazel test --nocache_test_results //access-control/contracts/openapi/v1:AccessControlConsumerPactTest
INFO: Invocation ID: 16bab404-9cf2-4e69-88d9-c46f58ef4b02
INFO: Analyzed target //access-control/contracts/openapi/v1:AccessControlConsumerPactTest (0 packages loaded, 252 targets configured).
INFO: Found 1 test target...
INFO: From Testing //access-control/contracts/openapi/v1:AccessControlConsumerPactTest:
==================== Test output for //access-control/contracts/openapi/v1:AccessControlConsumerPactTest:
OpenJDK 64-Bit Server VM warning: Ignoring option --illegal-access=debug; support was removed in 17.0
JUnit4 Test Runner
WARNING: A terminally deprecated method in java.lang.System has been called
WARNING: System::setSecurityManager has been called by com.google.testing.junit.runner.junit4.JUnit4Runner (file:/private/var/tmp/_bazel_imrankhan/b141c088e4409f9b6c4d0f13116258fa/external/remote_java_tools/java_tools/Runner_deploy.jar)
WARNING: Please consider reporting this to the maintainers of com.google.testing.junit.runner.junit4.JUnit4Runner
WARNING: System::setSecurityManager will be removed in a future release
.SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See <http://www.slf4j.org/codes.html#StaticLoggerBinder> for further details.
Pact files will be written to: /private/var/tmp/_bazel_imrankhan/b141c088e4409f9b6c4d0f13116258fa/sandbox/darwin-sandbox/28/execroot/harness_monorepo/bazel-out/darwin_arm64-fastbuild/bin/access-control/contracts/openapi/v1/AccessControlConsumerPactTest.runfiles/harness_monorepo/pacts
.Pact files will be written to: /private/var/tmp/_bazel_imrankhan/b141c088e4409f9b6c4d0f13116258fa/sandbox/darwin-sandbox/28/execroot/harness_monorepo/bazel-out/darwin_arm64-fastbuild/bin/access-control/contracts/openapi/v1/AccessControlConsumerPactTest.runfiles/harness_monorepo/pacts
.Pact files will be written to: /private/var/tmp/_bazel_imrankhan/b141c088e4409f9b6c4d0f13116258fa/sandbox/darwin-sandbox/28/execroot/harness_monorepo/bazel-out/darwin_arm64-fastbuild/bin/access-control/contracts/openapi/v1/AccessControlConsumerPactTest.runfiles/harness_monorepo/pacts
<http://localhost:60308/users/123>
Time: 0.957
OK (3 tests)
WARNING: A terminally deprecated method in java.lang.System has been called
WARNING: System::setSecurityManager has been called by com.google.testing.junit.runner.util.GoogleTestSecurityManager (file:/private/var/tmp/_bazel_imrankhan/b141c088e4409f9b6c4d0f13116258fa/external/remote_java_tools/java_tools/Runner_deploy.jar)
WARNING: Please consider reporting this to the maintainers of com.google.testing.junit.runner.util.GoogleTestSecurityManager
WARNING: System::setSecurityManager will be removed in a future release
BazelTestRunner exiting with a return value of 0
JVM shutdown hooks (if any) will run now.
The JVM will exit once they complete.
-- JVM shutdown starting at 2025-06-16 11:40:14 --
================================================================================
Target //access-control/contracts/openapi/v1:AccessControlConsumerPactTest up-to-date:
/private/var/tmp/_bazel_imrankhan/b141c088e4409f9b6c4d0f13116258fa/execroot/harness_monorepo/bazel-out/darwin_arm64-fastbuild/bin/access-control/contracts/openapi/v1/AccessControlConsumerPactTest.jar
/private/var/tmp/_bazel_imrankhan/b141c088e4409f9b6c4d0f13116258fa/execroot/harness_monorepo/bazel-out/darwin_arm64-fastbuild/bin/access-control/contracts/openapi/v1/AccessControlConsumerPactTest
INFO: Elapsed time: 3.016s, Critical Path: 2.82s
INFO: 2 processes: 1 internal, 1 darwin-sandbox.
INFO: Build completed successfully, 2 total actions
//access-control/contracts/openapi/v1:AccessControlConsumerPactTest PASSED in 2.7s
Executed 1 out of 1 test: 1 test passes.
Wojciech Wroblewski
07/31/2025, 10:22 AM<dependency>
<groupId>au.com.dius.pact.provider</groupId>
<artifactId>junit5spring</artifactId>
<version>4.6.10</version>
<scope>test</scope>
</dependency>
and started mvn clean tests
I tried also with version 4.6.17 but still getting errors like
package au.com.dius.pact.provider.junit5spring does not exist
[ERROR] /Users/MY_PATH/ProviderContractVerificationTest.java:[8,2] cannot find symbol
[ERROR] symbol: class Provider
[ERROR] /Users/MY_PATH/ProviderContractVerificationTest.java:[9,2] cannot find symbol
[ERROR] symbol: class PactBroker
[ERROR] /Users/MY_PATH/ProviderContractVerificationTest.java:[15,17] cannot find symbol
[ERROR] symbol: class PactVerificationContext
[ERROR] location: class ProviderContractVerificationTest
[ERROR] /Users/MY_PATH/ProviderContractVerificationTest.java:[21,39] cannot find symbol
[ERROR] symbol: class PactVerificationContext
[ERROR] location: class ProviderContractVerificationTest
[ERROR] /Users/MY_PATH/ProviderContractVerificationTest.java:[7,13] cannot find symbol
[ERROR] symbol: class SpringExtension
[ERROR] /Users/MY_PATH/ProviderContractVerificationTest.java:[20,17] cannot find symbol
[ERROR] symbol: class PactVerificationInvocationContextProvider
[ERROR] location: class ProviderContractVerificationTest
I've also checked in my .m2 for the artifact
❯ ls ~/.m2/repository/au/com/dius/pact/provider/
4.6.10 4.6.17 junit5 junit5spring
❯ ls ~/.m2/repository/au/com/dius/pact/provider/junit5spring
4.6.10 4.6.17
❯ ls ~/.m2/repository/au/com/dius/pact/provider/junit5spring/4.6.10
_remote.repositories junit5spring-4.6.10.jar junit5spring-4.6.10.jar.sha1 junit5spring-4.6.10.pom junit5spring-4.6.10.pom.sha1
I tried with both junit5 and junit5spring. Do you have any advices for that?Jan Měkota
07/31/2025, 11:34 AMpact-broker create-or-update-pacticipant
cli.
But since pacticipants are created automatically while publishing the pact is there any chance to pass the pacticipant repository-url info?
We use maven plugin au.com.dius.pact.provider:maven
./mvnw verify pact:publish \
-DpactBrokerUrl="${{ inputs.PACT_BROKER_BASE_URL }}" \
-Dpact.broker.user="${{ inputs.PACT_BROKER_USERNAME }}" \
-Dpact.broker.password="${{ inputs.PACT_BROKER_PASSWORD }}" \
Wojciech Wroblewski
08/05/2025, 11:01 AMservice
dir with service code and unit tests in the root dir. Contract test (which generate pact file) is placed in e2e-tests
directory directly under root. Can I also add provider verification tests in that dir or those need to be stored under service > src > test
?
I tried to create those tests in e2e-tests
but when running I got an error
Caused by: org.springframework.context.ApplicationContextException: Unable to start reactive web server; nested exception is org.springframework.boot.web.context.MissingWebServerFactoryBeanException: No qualifying bean of type 'org.springframework.boot.web.reactive.server.ReactiveWebServerFactory' available: Unable to start AnnotationConfigReactiveWebServerApplicationContext due to missing ReactiveWebServerFactory bean
And I'm not sure if it's improper usage or it requires some additional configuration?