microcks / microcks-testcontainers-java

Java lib for Testcontainers that enables embedding Microcks into your JUnit tests with lightweight, throwaway instance thanks to containers.
https://microcks.io
Apache License 2.0
18 stars 3 forks source link

Allow specification of artifacts to load on MicrocksContainer creation #26

Closed lbroudoux closed 8 months ago

lbroudoux commented 8 months ago

Reason/Context

As of today, loading artifacts into the Microcks container should be done after the container is started-up using 2 methods:

However, this way of doing things doesn't really fit with existing modules' logic - all of them have withSomething() fluent API style methods that allow definition of config at creation. Moreover, our approach can be sometimes harder to achieve cause it means you have to retrieve the container once-initialized (depending on test framework this can tricky) to import artifacts.

Description

Ideally, we'd like to be able to have something like:

MicrocksContainer microcks = new MicrocksContainer(IMAGE)
      .withMainArtifacts("apipastries-openapi.yaml")
      .withSecondaryArtifacts("apipastries-postman-collection.json");

Implementation ideas

Thanks to lifecycle methods like protected void containerIsStarted(InspectContainerResponse containerInfo). existing on GenericContainer, it should be possible to delay the loading of artifact just after the container is running and healthy.