users@jersey.java.net

Re: [Jersey] Unit testing resources

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 25 Jun 2008 17:36:57 +0200

On Jun 24, 2008, at 2:31 PM, Martin Probst wrote:

>> Unfortunately the only way to properly test the resource class is
>> to deploy it in a container and make an HTTP request to it, sorry :-(
>
> Yes, I came to that conclusion, too. This is really unfortunate -
> this boils down to not being able to do "proper" TDD with Jersey :-(
>

Tis hard when classes need to be deployed e.g. like servlet, JAX-WS
or EJB.

I think one can still to TDD of resource classes but the focus is on
the HTTP interface, which IMHO is not a bad thing since this is what
matters most?

If you could extend from say a class JerseyUnitTest that helped you
'deploy' or 'mock up' just what you need and you could utilize the
Jersey client API you might get reasonable rapid test driven
development. Would that work for you?

I have written many many unit tests for resource classes testing
Jersey and JAX-RS feature, i have found it reasonably productive but
i think we could make some improvements to make it easier. For
example NBs uses WADL to help drive testing, perhaps we could do
something there...

Paul.