You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've developed pact-jvm-mock, a library that automatically generates Pact contracts from existing mocks (Mockk, Mockito) in Kotlin/Java applications. The library aims to reduce the barrier to entry for contract testing by leveraging developers' existing mocking code.
Key Features
Seamless Integration with Existing Mocks: Minimal code changes required - primarily replacing every with uponReceiving in existing mock definitions.
Multiple Mock Framework Support: Works with both Mockk (Kotlin) and Mockito (Java), with an extensible adapter system.
Spring Integration: Built-in support for Spring RestTemplate with matching rules and provider states.
fun RestTemplate.willReturnUserProfile() = uponReceiving {
getForEntity(match<String> { it.contains("user-service") }, UserProfile::class.java, *anyVararg())
} withDescription {
"get the user profile"
} given {
state("The user has a preferred shopping list", mapOf("userId" to USER_ID))
} returns
ResponseEntity.ok(
USER_PROFILE
)
Deterministic Mode: Optional strict mode to ensure consistent contract generation.
Hi @ludorival, when you say "integrating this into the official pact-jvm project", what do you envision that to be? This becomes a module in the Pact-JVM repo, or the docs for it get incorporated into the pact.io website? Or do you mean integrating it with Pact-JVM code (I notice it has it's own code for generating Pact files)?
Hi @rholshausen , thanks for your reply.
Before considering making this part of the Pact-JVM modules, I would like to get your feedback on whether it aligns with your vision for Pact. Specifically, I’d like to know if you see value in integrating it as a module or keeping it as a standalone library. Either way, I believe it could complement Pact-JVM well, and I want to ensure it aligns with the broader goals of the project.
If you think there’s potential, I’d be happy to discuss how we could collaborate further or explore ways to integrate this effectively. Your insights would be greatly appreciated.
Pact-JVM already has a lot of modules, I wouldn't want to add more unnecessarily. You are publishing to Maven Central already, so I think a better approach would be to update your repo to use the Pact-JVM modules (so you get all the V3 + V4 formats) and then integrate your docs with docs.pact.io.
Overview
I've developed
pact-jvm-mock
, a library that automatically generates Pact contracts from existing mocks (Mockk, Mockito) in Kotlin/Java applications. The library aims to reduce the barrier to entry for contract testing by leveraging developers' existing mocking code.Key Features
every
withuponReceiving
in existing mock definitions.Multiple Mock Framework Support: Works with both Mockk (Kotlin) and Mockito (Java), with an extensible adapter system.
Spring Integration: Built-in support for Spring RestTemplate with matching rules and provider states.
Benefits
Current Status
Next Steps
I believe integrating this into the official pact-jvm project would provide significant value to the community. I'm happy to:
Would you be interested in discussing this integration? I'm happy to provide more details or schedule a call to discuss further.
Repository: https://github.com/ludorival/pact-jvm-mock
The text was updated successfully, but these errors were encountered: