I have JUnit
tests for REST web services. Now I think that JUnit
is not the best tool for that, since these tests are integration tests but not unit tests. So I probably need a Java library, which helps to send HTTP requests, verify HTTP responses, create reports and do that in parallel.
On the other hand maybe I am mistaken and Junit
(with HTTPUnit
etc.) is good enough and I don't need other tools.
What would you suggest?
HttpMaster is a web service tool that exclusively tests REST web services. It is utilized to test behavior of REST APIs and verify data output in formats including XML, JSON and HTML. HttpMaster is a great choice for simulating client activity and response behavior of an API application.
Selenium provides support to multiple libraries such as Ruby, Python, Java, etc as language bindings have been developed by Selenium developers to provide compatibility for multiple languages. For instance, if you want to use the browser driver in Python, use the Python Bindings.
I am also facing similar questions... and am starting looking around and experimenting.
I found this is other stackoverflow question: Unit testing a JAX-RS Web Service? (apparently Jersey allows to make such type of tests).
These are two options that popped up:
Keep it simple. Have a look at https://github.com/valid4j/http-matchers
// Statically import the library entry point:
import static org.valid4j.matchers.http.HttpResponseMatchers.*;
// Invoke your web service using plain JAX-RS. E.g:
Client client = ClientBuilder.newClient();
Response response = client.target("http://example.org/hello").request("text/plain").get();
// Verify the response
assertThat(response, hasStatus(Status.OK));
assertThat(response, hasHeader("Content-Encoding", equalTo("gzip")));
assertThat(response, hasEntity(equalTo("content")));
// etc...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With