Client driver

Neil Prosser edited this page Apr 30, 2016 · 46 revisions

The rest-client-driver is a library which simulates a RESTful service. You can set expectations on the HTTP requests you want to receive during a test.

Maven dependency


Example uses

We use JUnit's @Rule annotation to add the client-driver to a test.

public ClientDriverRule driver = new ClientDriverRule();

The driver will have all expectations cleared before each test. In your test you can add expectations to the driver:

driver.addExpectation(onRequestTo("/blah"), giveEmptyResponse().withStatus(404));

At present the expectations are matched without considering the order and one expectation must be added for each URL that is called.

At the end of each test the driver checks whether there were any requests made that it wasn't expecting or whether any of the requests it did expect were unfulfilled. If there is any discrepancy it throws an instance of ClientDriverFailedExpectationException.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.