:wave: Hello, team! I’m starting to implement Cont...
# pact-jvm
i
👋 Hello, team! I’m starting to implement Contract Testing in our organization using Bazel Mono-repo with Pact. Has anyone set this up before or worked with Pact in a Bazel environment? I would appreciate any guidance. Issue: My test is running using a sandbox path, which gets deleted once the tests complete. I’ve tried changing the path using
pact.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)
Copy code
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.
y
i
I have few questions over this, @Yousaf Nabi (pactflow.io) / @Olivier Picaud -- Let me know, when we can connect? Thanks!
y
Hey Imran, Happy to help out but I am not a bazel expert. It’s best if you can ask questions here, as we have a wider audience. I’ll help in any way I can. If you could also put a sample project up on github that replicates your setup, I am more than happy to take a look into it, see if I can get it working on my machine and post back the solution (if I find it). I’ve been meaning to take some time to look at Bazel