|
| 1 | +# WireMock |
| 2 | + |
| 3 | +## What and why |
| 4 | +WireMock is a simulator for HTTP-based APIs. We use this tool in the integration tests for mocking |
| 5 | +external services. For example, for testing import of the stamps series from sites. |
| 6 | + |
| 7 | +## Running on TravisCI |
| 8 | +WireMock is automatically running/stopping during integration tests execution (`mvn verify`). |
| 9 | + |
| 10 | +## Running manually |
| 11 | +In order to run the server as a standlone process: |
| 12 | +* uncomment `<keepRunning>` option in the `pom.xml` file |
| 13 | +* execute the `mvn wiremock:run` command |
| 14 | + |
| 15 | +After that the mock server will be available on 8888 port. |
| 16 | + |
| 17 | +## Troubleshooting |
| 18 | +* [run the plugin separately](#running-manually) to be able to test it with a browser/curl |
| 19 | +* append `--verbose` flag to the options from `<params>` tag in the `pom.xml` file. This instructs |
| 20 | + WireMock to produce more detailed output to the console |
| 21 | + |
| 22 | +## Configuration |
| 23 | +WireMock is fully configured by the `wiremock-maven-plugin` in the `pom.xml` file: |
| 24 | + |
| 25 | +* the server is listening on `8888` port |
| 26 | +* you can refer to the mock server from within RobotFramework test cases by using `${MOCK_SERVER}` |
| 27 | + variable. |
| 28 | +* static files are reside inside the `src/test/wiremock/__files` directory |
| 29 | +* mocks and stubs are reside inside the `src/test/wiremock/mappings` directory |
| 30 | + |
| 31 | +By our convention the files in these directories should have the same hierarchy as their |
| 32 | +RobotFramework test cases. For instance, the mocks/files used solely by |
| 33 | +`category/creation/logic.robot` test case, should be placed into |
| 34 | +`src/test/wiremock/__files/category/creation/logic` and |
| 35 | +`src/test/wiremock/mappings/category/creation/logic` directories. |
| 36 | + |
| 37 | +In the case, mocks/files are being used by the different test cases, they should reside in a |
| 38 | +directory that is the base for all such test cases. |
| 39 | + |
| 40 | +## Links |
| 41 | +* http://wiremock.org/ |
| 42 | +* https://github.com/tomakehurst/wiremock |
| 43 | +* https://github.com/automatictester/wiremock-maven-plugin |
0 commit comments