6. <david.schmitz@senacor.com>
Enter Wiremock
• Stub and Mock framework
for testing HTTP(s) traffic
• Features include
• Request verification,
• record, playback,
• fault injection,
• unit test and stand alone
Client Unit Test
Embedded
Wiremock
Client
Standalone
Wiremock
7. <david.schmitz@senacor.com>
How does it work?
Client Wiremock
Request
Mapping
Response Data
$ curl -H ‘Accept: application/json’ http://localhost:8080/sample/
8. <david.schmitz@senacor.com>
How does it work?
Client Wiremock
Request
Mapping
Response Data
• Starts embedded Jetty
Server
• Acts as a proxy to the
actual service
• Is used by the client
transparently
10. <david.schmitz@senacor.com>
How does it work?
Client Wiremock
Request
Mapping
Response
Data
body.json:
[{"publicId":"...","data":"..."},
{"publicId":"...","data":"..."}]
18. <david.schmitz@senacor.com>
…but what about bad responses?
Client Service
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
[300 MB of random garbage]
GET http://service/resource/12
25. <david.schmitz@senacor.com>
Summary
• Resilience can be tested
• Do not rely on happy paths and mocks only
• Use stubs and verify in unit tests
• Use record and playback for external services
• Make sure not to be the developer responsible for a downtime
during the busy-business-time :D