This requires a little bit of background. Our product is sold highly customized so we utilize a forking model for development. The UI has a clear interface to the backend (no backend rendering), there are only a few files (not a sprawling website of content).
Wiremock provides a http(s) server which will respond to a request based on matching criteria (this can be the url, header, or body content).
Wiremock exposes a rest api allowing for the mocking to be defined with the tests and posted to the server before test execution (or as part of). This keeps the test self contained, preventing the need to maintain a "test" environment.
Multithreaded testing can be challenging in this situation because the mappings can conflict with each other if the match criteria is not sufficiently unique to the test session.
Wiremock is our chosen mocking solution. We have hosted our product in a docker container with Wiremock serving the UI and the UI configured to communicate back to wiremock for all requests. This provides a self contained UI build where our selenium tests can handle and mock all UI interactions.
To add this testing into a pipeline, we needed to stand up the container and have a predictable url. This meant we have Nginx provide redirection based on project and branch. It also provide an environmental config our test solution utilizes. This is needed because we host for many projects and branches, so the container selects a random port.
Wiremock standalone HTTP server Docker image
Supported tags :
The image includes
EXPOSE 8080 8443: the wiremock http/https server port
VOLUME /home/wiremock: the wiremock data storage
How to use this image
uid: the container executor uid, useful to avoid file creation owned by root
JAVA_OPTS: for passing any custom options to Java e.g.
Pull latest image
docker pull rodolpheche/wiremock
Start a Wiremock container
docker run -it --rm -p 8080:8080 rodolpheche/wiremock
Access http://localhost:8080/__admin to display the mappings (empty set)
Start a Wiremock container with Wiremock arguments
To start with these Wiremock arguments :
--https-port 8443 --verbose
docker run -it --rm -p 8443:8443 rodolpheche/wiremock --https-port 8443 --verbose
Access https://localhost:8443/__admin to check https working