Hi Petr,

On Mon, Jun 29, 2015 at 10:40 AM, Petr Shypila <[email protected]> wrote:
> ...could you please take a look on my
> first test for SlingMainServlet[1]...

I think it's a good start, but I don't think it's sufficient to just
verify that the SlingRequestProcessor is called - you should verify
that it is called with the appropriate values, and that its actions
are taken into account. Best might be to mock the
SlingRequestProcessor (or maybe it's easier to instantiate a
SlingRequestProcessorImpl with a few mocks) and test both classes in
combination, which is how they are used in practice.

This diverges a bit from pure unit tests which should arguably test a
single class, but we don't really care here IMO. Testing in a more
realistic situation (so SlingMainServlet combined with
SlingRequestProcessorImpl) will probably make your tests look more
natural, which is good IMO.

Does this work for you?
-Bertrand


> [1]
> https://github.com/PetrShypila/sling-builder/blob/d4d04af973876aced8dd042ee9b3880ad4e00449/bundles/engine/src/test/java/org/apache/sling/engine/impl/SlingMainServletTest.java

Reply via email to