0

There are many pages on the net, declaring that they describe the creation of integration tests with JerseyTest. Such as:

https://blog.codecentric.de/en/2012/05/writing-lightweight-rest-integration-tests-with-the-jersey-test-framework/

But notice! It is not an integration test really. It mocks the whole service under the API function. So, it is a unit test. And all examples for 'integration' tests that I had found, are such mocking stubs.

And I want to create a really integration test, I want to send a JSON string and get back another JSON string (or HTML). Of course, for that Jersey in coordination with JerseyTest should collaborate somehow to create a request, call my API function, follow it to the DB queries, fulfil them, and return a response that I can assert by parts.

How can I do it? (If it is possible, of course)

Gangnus
  • 24,044
  • 16
  • 90
  • 149
  • _"It mocks the whole service under the API function."_ - Don't mock the service then. There's no reason you can't use the test framework for an integration test. That's what it's for. – Paul Samsotha May 09 '18 at 16:28
  • Then I have request, sent into class field with @Context annotation as null. No testing, no functionality. – Gangnus May 09 '18 at 19:54
  • Not sure what you're talking about. Are you talking about `HttpServletRequest`? If you are then [this](https://stackoverflow.com/q/28436040/2587435) is your problem, – Paul Samsotha May 09 '18 at 21:05

0 Answers0