Closed adamu closed 5 months ago
Adding on to this We run tests in parallel and test with MockServer, the problem is there doesn't seem to be an easy way to change the URL/port the clients point to.
We need a way to start a MockServer with a random port and then point the client to that random port. Basically override the config in the test
@adamu can you elaborate a little more on what you would like to see?
@tobad357 you can manually start Wiremock and make the rest-client point to it, see this for example
A test that calls countriesService.getByName(name)
and countriesService.getByNameAsync(name)
directly from the test, and shows how to assert the results would be useful.
I think that the test tools are likely to be different. The current example is using RestAssured
, but for testing the client I think it's more likely that the tester will want to call the client method directly and then perform assertions on the response object (at least, that's how I'm currently approaching it).
@adamu would you like to contribute a documentation Pull Request?
I'm currently working out how to do it nicely on the project I'm working on. Let me finish that (could be a few days), and then post what I'm doing here. If you think it's sensible, I can look at updating the guide.
Sounds like a plan
The documentation now does show how to test the client, so I am going to close this
I'm looking at the rest client guide.
It demonstrates how to set up a rest client using dependency injection. However, it doesn't demonstrate how to test the client.
It does include tests, but the tests are testing a Rest server endpoint that wraps the use of the rest client. It would be helpful to provide an example of testing the client directly, rather than via a level of indirection via a local server resource.