The testing workflow with mock server:
Mock server Java client website: http://www.mock-server.com/mock_server/getting_started.html
Mock server Python Client repository: https://github.com/internap/python-mockserver-friendly-client
Mock server Java client API on Swaggerhub: https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi
APIs for Mock Server:
Request Matcher Code Examples(It support 3 ways to match the request):
How to setup a testing project with Mock Server:
- Download Mock Server
- Run cmd start Mock Server
>>> java -jar mockserver-netty-5.6.0-jar-with-dependencies.jar -serverPort 1080 -logLevel INFO - Config test url to Mock Server address
http://localhost:1080
Python coding example use Mock server Java client:
client.stub(request(method="PUT", path=D_PATH), response(code=200, body="i'm a response"))
client.verify(request(method="PUT", path=D_PATH, body=json_contains({"key":"value"})), 2)
client.expect(request(method="PUT", path=D_PATH, body=json_contains({"key":"value"})), response(code=200, body="i'm a response"), 2) (= client.stub + client.verify)