Author: buildbot
Date: Mon May 27 12:18:52 2013
New Revision: 863284

Log:
Staging update by buildbot for sling

Modified:
    websites/staging/sling/trunk/content/   (props changed)
    
websites/staging/sling/trunk/content/documentation/tutorials-how-tos/testing-sling-based-applications.html

Propchange: websites/staging/sling/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Mon May 27 12:18:52 2013
@@ -1 +1 @@
-1485990
+1486591

Modified: 
websites/staging/sling/trunk/content/documentation/tutorials-how-tos/testing-sling-based-applications.html
==============================================================================
--- 
websites/staging/sling/trunk/content/documentation/tutorials-how-tos/testing-sling-based-applications.html
 (original)
+++ 
websites/staging/sling/trunk/content/documentation/tutorials-how-tos/testing-sling-based-applications.html
 Mon May 27 12:18:52 2013
@@ -114,7 +114,7 @@
 <h2 id="mock-classes-and-services">Mock classes and services</h2>
 <p>The next step is to use mock classes and services to simulate components 
that are needed for testing. This makes it possible to test OSGi service 
classes without an OSGi framework.</p>
 <p>We have a number of custom-written mock services in Sling, like <a 
href="https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/jcr/MockNodeType.java";>MockNodeType</a>
 for example. These handwritten mocks implement just what's needed for their 
tests, so they might not be reusable as is.</p>
-<p>In other cases we use <a href="http://www.jmock.org/";>jmock</a> 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 <a 
href="https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/event/";>org.apache.sling.event</a>
 bundle, for example, make extensive use of such mock services.</p>
+<p>In other cases we use <a href="http://www.jmock.org/";>jmock</a> or <a 
href="https://code.google.com/p/mockito/";>Mockito</a> 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 <a 
href="https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/event/";>org.apache.sling.event</a>
 bundle, for example, make extensive use of such mock services.</p>
 <p>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.</p>
 <h3 id="side-note-injecting-services-in-private-fields">Side note: injecting 
services in private fields</h3>
 <p>To inject (real or fake) services in others for testing, without having to 
create getters and setters just for this, we use a reflection-based trick, as 
in this example:</p>
@@ -152,7 +152,7 @@
 <h2 id="summary">Summary</h2>
 <p>Combining the above testing techniques has worked well for us in creating 
and testing Sling. Being able to test things at different levels of integration 
has proved an efficient way to get good test coverage without having to write 
too much boring test code.</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; 
text-align: right;">
-        Rev. 1345850 by fmeschbe on Mon, 4 Jun 2012 07:40:42 +0000
+        Rev. 1486591 by bdelacretaz on Mon, 27 May 2013 12:18:42 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache 
Sling project


Reply via email to