Git Product home page Git Product logo

Comments (7)

aguibert avatar aguibert commented on June 10, 2024

I like the idea of giving users more low-level validation access to their HTTP endpoints. Currently users can do this if the REST client returns a javax.ws.rs.core.Response object, but in many cases REST clients do not because it's more convenient to simply return a POJO from the JAX-RS method.

One popular REST testing library I know if is REST-assured. Here is a good article about it: https://www.baeldung.com/rest-assured-tutorial
If you look at section (7) it talks about configuring the library, perhaps we could automatically detect the presence of the RestAssured class and if it's present then microshed would automatically bootstrap it (e.g. set baseURI, base path, port, etc). This would allow us to have a test case that looks like this:

@MicroShedTest
public class MyTest {
  @Container
  public static ApplicationContainer app = // usual config

  @Test
  public void testCreatePerson() {
    // validate that POST request to
    // http://<container-ip>:<container-port>/myservice/?name=Hank?age=52
    // returns HTTP 200 with content type JSON
    given()
        .contentType(JSON)
        .queryParam("name", "Hank")
        .queryParam("age", 52)
      .when()
        .post("/")
      .then()
        .statusCode(200)
        .contentType(JSON);
  }
}

from microshed-testing.

rieckpil avatar rieckpil commented on June 10, 2024

This looks quite good 👍

from microshed-testing.

aguibert avatar aguibert commented on June 10, 2024

created a draft PR for the integration here: #134

It can't be merged until the corresponding PR I made on REST-assured gets merged though

from microshed-testing.

rieckpil avatar rieckpil commented on June 10, 2024

wow, that was fast 👍 I'll try it over the weekend while building REST-Assured with your PR locally

from microshed-testing.

rieckpil avatar rieckpil commented on June 10, 2024

works great and I really like the given/when/then structure of Rest Assured.

Just out of curiosity, if now a user wants to plug a custom MessageBodyReader or MessageBodyWriter e.g JAXB or for whatever reason, he/she uses binary formats like Kryo, this would always result in effort and adjustment within RestAssured, or? I assume 80% of the use cases are fine with JSON but the rest might need something different

from microshed-testing.

aguibert avatar aguibert commented on June 10, 2024

RestAssured has builtin converters for JSON and XML formats, but if a user wants to implement a converter to handle a custom data format.

For JSON-B integration with RestAssured I could have just written the converter in MicroShed code, but then we'd need to have a dependency on RestAssured which I wanted to avoid (i.e. not even an optional dependency)

from microshed-testing.

aguibert avatar aguibert commented on June 10, 2024

PR #134 adds the integration with REST Assured and is now merged, it will be available in the next release (probably 0.6.3)

from microshed-testing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.