Hi Petr, On Mon, Jun 22, 2015 at 12:26 PM, Petr Shypila <[email protected]> wrote: > Hi Bertrand, > > Following our discussion in SLING-4541 I completely agree that unit testing > of BundleContentProvider as pretty hard and difficult to understand.
I'm unable to find a reference to such a class, where does it live? > So use > of PaxExam looks a very good idea. > Few days ago I already tried to write some PaxExam tests for > DefaultContentCreator and got a ClassNotFoundException > on DefaultContentCreator class explicit initialization. > I loaded a bundle for test but it doesn't help me. I tried it to initialize > with @Inject annotation but it didn't help me as well. Probably I do > something wrong? Does injection works only for Services? I think we've been (slowly) moving from Pax-Exam tests to Sling mocks [1] based tests. The major difference is that Pax-Exam expects you to build a container out of a list of OSGi bundles while Sling mocks attempts to wire everything up from jars in your classpath, so there is no need to set up an OSGi framework. So while Pax-Exam is closer to integration testing, Sling Mocks are closer to unit testing based on ( drumroll ... ) mocks. I personally find testing with Sling mocks simpler and easier to maintain in the long term and also better suited for Sling, but of course that's just a personal opinion. It would be interesting to see what testing scenario you had in mind and how to better address it - whether it's Sling mocks or Pax-Exam or something different. Cheers, Robert [1]: https://sling.apache.org/documentation/development/sling-mock.html
