Coverage Report - biz.xsoftware.mock.Behavior
 
Classes in this File Line Coverage Branch Coverage Complexity
Behavior
N/A
N/A
0
 
 1  
 package biz.xsoftware.mock;
 2  
 
 3  
 /**
 4  
  * <p>A way of providing snippets of code to be run when a method is called.  If you want 
 5  
  * to pass in a Behavior implementation for </p>
 6  
  * 
 7  
  * public int doSomethingCool(int i, String s, long l);
 8  
  * 
 9  
  * <p>Then your Behavior class must define the same exact method and that method will be 
 10  
  * called in your Behavior implementation when the mockobject's doSomethingCool method 
 11  
  * is called.  You must also return the same value as the doSomethingCool method which
 12  
  * in this case is an int.</p>
 13  
  * 
 14  
  * <p>This interface is intended to be implemented by helper classes to be used by
 15  
  * <code>MockObject</code>s. A <code>Behavior</code> should have a method
 16  
  * in it that matches the method used when adding it to a
 17  
  * <code>MockObject</code>.
 18  
  * 
 19  
  * We'll give a basic example on how to use a behavior.  First we'll need an
 20  
  * interface that will need to be mocked:
 21  
  * <pre>
 22  
  * public interface MyInterface {
 23  
  *     public String myMethod();
 24  
  * }
 25  
  * </pre>
 26  
  * 
 27  
  * Here is the example Behavior:
 28  
  * <pre>
 29  
  * public class MyBehavior implements Behavior {
 30  
  *     public String myMethod() {
 31  
  *         return "This is the desired behavior";
 32  
  *     }
 33  
  * }
 34  
  * </pre>
 35  
  * 
 36  
  * Here is the example of using the Behavior with a MockObject:
 37  
  * <pre>
 38  
  * public class Example {
 39  
  *     public static void main(String ... args) {
 40  
  *         MockObject myInterface = MockObjectFactory.create
 41  
  *         myInterface.addBehavior("myMethod", new MyBehavior());
 42  
  *         System.out.println(((MyInterface) myInterface).myMethod());
 43  
  *     }
 44  
  * }
 45  
  * </pre>
 46  
  * 
 47  
  * When this example is run "This is the desired behavior" will be printed to
 48  
  * console
 49  
  * 
 50  
  * @author Dean Hiller, Brian Freeman
 51  
  */
 52  
 public interface Behavior {
 53  
 
 54  
 }