skip to Main Content

I have a few noob questions about Pact JVM (Java);

  1. If the providers json structure response is already known (for example by querying the api with Postman) ,is it possible to convert Postman json body automatically into a pact contract file without the need to run a (java) Consumer Fragment creation method, or for example convert it into a java PactDslJsonBody() structure?

  2. Is the provider (spring-boot) needed to be up and running (even if the json response structure is already known) when the pact file is being created? It would be good maybe to avoid the need to launch the spring-boot server for each and every contract creation, particularly if the contract details is already known? Particularly if creating many pact contracts for many microservices at ones.

  3. Is there a more advanced example of a larger returned provider json structure than this very small json body found in the tutorial example;
    [1] http://the-creative-tester.github.io/Java-Consumer-Driven-Contract-Testing/
    Furthermore it would be good if that additional example could be shared that only verify a subset of the structure to be returned exist since we got a lot in the responses that are random.

  4. Could somebody share a pact verify java code example of a pact jvm verify towards an online https (as opposed to http) rest service, like for example google, facebook or similar provider? ( or for example this: [2] https://jsonplaceholder.typicode.com/posts )

  5. I gotten a lot of java compilation errors with above example[1]. Are there any version level of pact (and spring) that are less likely to get mismatch with java spring framework versions?

Thanks for your time!

2

Answers


  1. Hi Please find response below:

    1)Currently there is no such functionality.Consumer Fragment is basically to define the json so skipping this step doesn’t make sense.

    2) The pact file creation uses Pact Mock Server. So you dont need real service to be up. The service should be up only during verification phase.

    3,4,5) Version plays a critical role since this framework is actively evolving. Regarding handling complex json structures, there are quite a few examples to show usage of Pact DSL. You may use those to come up with the json structure of your service.
    https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-consumer-junit#dsl-matching-methods

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search