[jboss-cvs] jboss-seam/doc/reference/en/modules ...

Gavin King gavin.king at jboss.com
Thu Mar 15 18:07:00 EDT 2007


  User: gavin   
  Date: 07/03/15 18:07:00

  Modified:    doc/reference/en/modules  testing.xml
  Log:
  doc mocks
  
  Revision  Changes    Path
  1.13      +48 -6     jboss-seam/doc/reference/en/modules/testing.xml
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: testing.xml
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/doc/reference/en/modules/testing.xml,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- testing.xml	13 Nov 2006 20:33:18 -0000	1.12
  +++ testing.xml	15 Mar 2007 22:07:00 -0000	1.13
  @@ -120,6 +120,7 @@
       
       <section>
           <title>Integration testing Seam applications</title>
  +        
           <para>
               Integration testing is slightly more difficult. In this case, we can't eliminate
               the container infrastructure; indeed, that is part of what is being tested! At
  @@ -128,12 +129,14 @@
               just enough of the container infrastructure inside our testing environment to be 
               able to exercise the whole application, without hurting performance too much.
           </para>
  +        
           <para>
               A second problem is emulating user interactions. A third problem is where to
               put our assertions. Some test frameworks let us test the whole application
               by reproducing user interactions with the web browser. These frameworks have
               their place, but they are not appropriate for use at development time.
           </para>
  +        
           <para>
               The approach taken by Seam is to let you write tests that script your
               components while running inside a pruned down container environment (Seam,
  @@ -141,6 +144,7 @@
               is basically to reproduce the interaction between the view and the Seam components. 
               In other words, you get to pretend you are the JSF implementation!
           </para>
  +        
           <para>
               This approach tests everything except the view.
           </para>
  @@ -148,6 +152,7 @@
           <para>
               Let's consider a JSP view for the component we unit tested above:
           </para>
  +        
           <programlisting><![CDATA[<html>
    <head>
     <title>Register New User</title>
  @@ -256,6 +261,43 @@
             </imageobject>
           </mediaobject>
           
  +        <section>
  +            <title>Using mocks in integration tests</title>
  +            
  +            <para>
  +                Occasionally, we need to be able to replace the implementation of some
  +                Seam component that depends upon resources which are not available in 
  +                the integration test environment. For example, suppose we have some
  +                Seam component which is a facade to some payment processing system:
  +            </para>
  +            
  +            <programlisting><![CDATA[@Name("paymentProcessor")
  +public class PaymentProcessor {
  +    public boolean processPayment(Payment payment) { .... }
  +}]]></programlisting>
  +            
  +            <para>
  +                For integration tests, we can mock out this component as follows:
  +            </para>
  +            
  +            <programlisting><![CDATA[@Name("paymentProcessor")
  + at Install(precedence=MOCK)
  +public class MockPaymentProcessor extends PaymentProcessor {
  +    public void processPayment(Payment payment) {
  +        return true;
  +    }
  +}]]></programlisting>
  +            
  +            <para>
  +                Since the <literal>MOCK</literal> precedence is higher than the default
  +                precedence of application components, Seam will install the mock 
  +                implementation whenever it is in the classpath. When deployed into 
  +                production, the mock implementation is absent, so the real component
  +                will be installed.
  +            </para>
  +            
  +        </section>
  +        
       </section>
   	
   </chapter>
  \ No newline at end of file
  
  
  



More information about the jboss-cvs-commits mailing list