+1, and some additions below

On Mon, 2016-12-05 at 20:03 +0000, Stefan Seifert wrote:
> my opinion:
> 
> - always use sling-mock and osgi-mock when it's sufficient for your
> usecases and you do not hit an area which is no supported by them
> (only a subset of OSGi and Sling is supported - but for "normale" AEM
> or sling applications most should be present). it's the fasted way
> for unit tests.
> 
> - always use the fasted resource resolver type [1] and switch only to
> a more complex one if you need it.
> 
> - if you hit the limitations of the mock implementation either use
> teleporter rule or paxexam to use the "real implementations"
> underneath. i personally did not yet use paxexam, i assume it has
> less overhead than the teleporter rule. teleporter rule is a bit
> closer to a "real integration test" and you can combine them with
> HTTP-bases integration tests.

Pax-exam can allow you to use a small set of bundles if needed. For
instance the commons.log bundle only pulls in slf4j-api using pax-exam

  https://github.com/apache/sling/blob/2272376537ab6cdfd2ac0ca78c44b1da
d0a41794/bundles/commons/log/src/test/java/org/apache/sling/commons/log
/logback/integration/LogTestBase.java#L85-L89

Using a full Sling instance would be overkill.

But when you do need a full sling instance teleporter tests are
probably better as they allow you to depend on a certain launchpad
release. 

Robert

> 
> stefan
> 
> [1] https://sling.apache.org/documentation/development/sling-mock.htm
> l#resource-resolver-types
> 
> 
> 
> 
> > -----Original Message-----
> > From: Roy Teeuwen [mailto:[email protected]]
> > Sent: Sunday, December 4, 2016 7:22 PM
> > To: [email protected]
> > Subject: PAXExam vs Sling Teleporter (vs Sling Mocks)
> > 
> > Hello all,
> > 
> > I have been going through the code base of Apache Sling and it is
> > clear
> > there are so many ways to test the code, you have two different
> > bundles for
> > PAX Exam (org.apache.sling.testing.paxexam and
> > org.apache.sling.paxexam.util), you have the Teleporter and you
> > also have
> > the Sling Mocks. It makes me wonder in what is the criteria to
> > choose
> > between these three different ways of testing your code. When would
> > you say
> > it is enough to use Sling Mocks, where you can even go for a real
> > OAK JCR
> > based ResourceResolver, or when would you go for PAX Exam or the
> > Teleporter? What are the benefits of doing your integration tests
> > with
> > Teleporter vs PAX Exam?
> > 
> > Thanks for any clarifications!
> > Greetings,
> > Roy
> 
> 

Reply via email to