Expand my Community achievements bar.

SOLVED

sling server side testing

Avatar

Former Community Member

I am trying to run server side unit testing as advised in the advance developer guide.

I am able to see my Test class under the URL" http://localhost:4502/system/sling/junit/tset.com.test.TestableClassTest.html

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi,

Have you used the annotation "@TestReference" instead of the "@Reference" annotation in your unittests? Can you provide the sourcecode for your test class?

kind regards,
Jörg

View solution in original post

2 Replies

Avatar

Level 10

instead of using annotation @reference to inject the repository, use BundleContext and that should work. refer [1]

[1] bundleContext.getServiceReference(ResourceResolverFactory.class.getName());

Avatar

Correct answer by
Employee Advisor

Hi,

Have you used the annotation "@TestReference" instead of the "@Reference" annotation in your unittests? Can you provide the sourcecode for your test class?

kind regards,
Jörg