Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use rest-assured as a general purpose http client

Is there any reason to avoid using rest-assured in a non-testing-environment? The syntax the library offers for creating and parsing requests is so compact it seems a waste to only use it in testing. Which kind of begs the question, why is it targeted as a testing tool alone?

like image 387
eladidan Avatar asked Oct 21 '14 01:10

eladidan


People also ask

What is the difference between REST assured and HttpClient?

REST Assured is a high level Java DSL for simplified testing of REST based services built over HTTP. On the other hand, HttpClient is a low level client for simplifying Http Communication, In-fact HttpClient is used by REST Assured under the hood for Http communication.

What is HttpClient in REST API?

HTTP client is a client that is able to send a request to and get a response from the server in HTTP format. REST client is a client that is designed to use a service from a server and this service is RESTful.


1 Answers

I'm the founder of REST Assured and it has always primarily been targeted towards testing. For example the default port is 8080, it ships with Hamcrest matchers (which is used internally as well so it cannot be excluded) and performance could probably be optimized somewhat. It also depends on Groovy which can be quite a large dependency to add to a production system if all you need is an HTTP client.

People, including myself on occasion, are using it in production because it's easy and flexible to use. Not all use cases require state of the art performance with a minimum number of dependencies. So for certain bounded contexts REST Assured will probably make a lot of sense.

One of my goals with REST Assured is to extract a more lightweight core and remove the need for Hamcrest and potentially even Groovy in the future. Some steps have already been taken in this direction when JsonPath and XmlPath were extracted to their own projects.

like image 121
Johan Avatar answered Sep 28 '22 06:09

Johan