Closed havenqi closed 5 years ago
That is by design since the library is built for testing - if you define a fixed port then you cannot have multiple tests running in parallel, and there is always a chance something else could already be running on that port.
Likewise, a client API that does not allow configuration via host and port seems a bit brittle.
Not sure what a SUT is so I can't really speak to your example.
I would tend to lean against allowing fixed ports, but I will have to think about it a bit.
get what you mean.
The background is like, the service component under test is based on Spring which has target service IP and port defined in configuration file. I'm thinking about changing the config to switch among existing mock service, real downstream service, and more flexible Ersatz mock integrated in my testcases.
As an option to choose in various conditions, better to have a fixed port implementation.
I have added support for port specification in 1.9 - documented that it should very rarely be used.
I need to trigger the SUT to send out http post to Ersatz server, which I prefer running on the same server as the test runner, meaning serverA---->SUT---->serverA. So SUT has to be configured with a dedicated IP&port. But Ersatz seems generating random port every time. I didn't find a public method to set a certain port in my test run. Any idea to that?