Kotest provides an extension for integration with the MockServer library.
kotest-extensions-mockserver module to be added to your build.
Mockserver allows us to define an in process HTTP server which is hard coded for routes that we want to test against.
To use in Kotest, we attach an instance of
MockServerListener to the spec under test, and Kotest will control
the lifecycle automatically.
Then it is a matter of using
MockServerClient to wire in our responses.
In the above example, we are of course just testing the mock itself, but it shows how a real test could be configured. For example, you may have an API client that you want to test, so you would configure the API routes using mock server, and then invoke methods on your API client, ensuring it handles the responses correctly.