How to handle decimal numbers in form params with WireMock
I wrote about WireMock last year. It's a very powerful tool that lets us replace external services with stubs while testing. Since it can be configured on the fly by tests, it allows us to validate virtually any behavior. Here's how I use it:
In this sequence diagram, a test tells WireMock to return a JSON body for every request to /fetch-details
. During execution, the test calls /some-endpoint
to validate it. This endpoint needs data from an external service to produce a response, so it requests /fetch-details
and gets the JSON body that the test fed WireMock at the start. By changing what /fetch-details
returns, we can easily simulate various scenarios.
In this post, I want to cover a case I dealt with recently: form data with decimal numbers.