sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject svn commit: r1627360 - /sling/site/trunk/content/documentation/tutorials-how-tos/testing-sling-based-applications.mdtext
Date Wed, 24 Sep 2014 16:22:37 GMT
Author: sseifert
Date: Wed Sep 24 16:22:37 2014
New Revision: 1627360

SLING-3969 add hint to testing/resourceresolver-mock


Modified: sling/site/trunk/content/documentation/tutorials-how-tos/testing-sling-based-applications.mdtext
--- sling/site/trunk/content/documentation/tutorials-how-tos/testing-sling-based-applications.mdtext
+++ sling/site/trunk/content/documentation/tutorials-how-tos/testing-sling-based-applications.mdtext
Wed Sep 24 16:22:37 2014
@@ -26,6 +26,12 @@ The next step is to use mock classes and
 We have a number of custom-written mock services in Sling, like [MockNodeType](
for example. These handwritten mocks implement just what's needed for their tests, so they
might not be reusable as is.
+A quite powerful mock implementation of a Sling Resource Resolver (without underlying JCR
respository, but mimicking the behavior of the JCR Resource Provider) is provided in [testing/resourceresolver-mock](
It uses an in-memory map for storing the resource data, and supports reading, writing and
a certain level of transaction and eventing support. Usage example:
+    #!java
+    MockResourceResolverFactory factory = new MockResourceResolverFactory();
+    ResourceResolver resolver = factory.getResourceResolver(null);
 In other cases we use [jmock]( or [Mockito][1] to help create mock
objects without having to write much code - such mocking libraries take care of the plumbing
and allow you to write just the bits of code that matter (often with funny syntaxes). The
tests of the [](
bundle, for example, make extensive use of such mock services.
 The problem with mocks is that it can become hard to make sure you're actually testing something,
and not just "mocking mocks". At a certain level of complexity, it becomes quicker and clearer
to actually start an OSGi framework for automated tests.

View raw message