quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.35k stars 2.56k forks source link

Consumer-Driven Contracts integration/support #6276

Open x80486 opened 4 years ago

x80486 commented 4 years ago

Description

Having something like this, that works out-of-the-box without developers need to do all the Jiu Jitsu for the integration would come handy — even more for testing micro-services.

I'm thinking about integrating something like Pact JVM with abilities to test (a) contracts for REST or HTTP as a means of communication, (b) message brokers (like the output from a method or a message), (c) you name it.

One can achieve something similar by using JsonSchemaValidator.matchesJsonSchemaInClasspath, but that wouldn't be a "clear way" to define the contracts:

RestAssured.given()
  .when()
    .header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON)
    .get(Constant.Uri.Comments)
  .then()
    .body("$.size()", Matchers.greaterThanOrEqualTo(4))
    .body(JsonSchemaValidator.matchesJsonSchemaInClasspath("schema/json/comments__get-all.json"))
    .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
    .statusCode(HttpStatus.SC_OK);
bpechiney commented 4 years ago

Has there been any work done to support contract testing in Quarkus?

dicolasi commented 3 years ago

Same question here :)

ambition-consulting commented 2 years ago

It's a shame that a framework, which is meant for microservice orchestration, has only testing support for monolithic applications. We need orchestration support like provided by spring-cloud-contracts or pact.

wabrit commented 2 years ago

I would agree with @ambition-consulting - CDC is a big part of our Spring Boot microservice qa process, and it would be very desirable to have an equivalent in quarkus. Ideally the framework should be language-agnostic so that e.g. contracts published by a Quarkus microservice producer can be tested by a Nodejs consumer - spring-cloud-contracts AFAIK does not support that.

ambition-consulting commented 2 years ago

Apparently Pact tests can at least get executed again with Quarkus 2: https://github.com/skattela/pact-workshop-jvm-quarkus

holly-cummins commented 1 year ago

See #27729, which is arguably a duplicate of this, but with the extension-proposal type.

holly-cummins commented 1 year ago

See also #9677 which sets many pact artifacts to be parentfirst in a core pom, with a comment

                        <!-- Pact[<4.1.0] support. It would be great if there was somewhere better to put this-->

Those updates should perhaps? move to this extension once implemented.

holly-cummins commented 1 year ago

See https://github.com/quarkiverse/quarkus-pact/, and also https://www.youtube.com/watch?v=d9CSY8HuZ9U, which discusses some of the roadmap for CDC support in Quarkus.