On 04.09.14 04:09, Andre Perez wrote:
> I am using JDK 1.7, Jersey 2.12, Tomcat 7, MongoDB and RestAssured
> <https://code.google.com/p/rest-assured/> to unit test my Rest calls...
> The issue is that RestAssured needs Tomcat to be running with my war file,
> in order, to work. Is there an embedded server or in-memory server along
> with a different unit testing framework which I can use to test my Restful
> Web Services (basically without be tightly coupled to an external server)?
> Would love to hear people's suggestions regarding best practices?
We have great experience using JerseyTest
(
https://jersey.java.net/documentation/latest/test-framework.html). The
in-memory test container works great, and enables us to run tests in
paralell, and we replace beans in some tests when we need to.
Our tests usually start a in-memory container with JerseyTest, and then
just do `jerseyTest.target(someUri).request() ...` to access the server
and perform our testing.
If you need Tomcat, you can still use JerseyTest and just configure it
to use an external container
(
https://jersey.java.net/documentation/latest/test-framework.html#d0e15742),
but I suppose you will lose some of the advantages - you most likely
have to create something to actually start Tomcat and deploy your WAR file.
Good luck!
Regards,
Vetle