Date: 2005-01-28T10:56:01
   Editor: ZacharySmith
   Wiki: Apache Beehive Wiki
   Page: Controls/TestingControls/Milton
   URL: http://wiki.apache.org/beehive/Controls/TestingControls/Milton

   no comment

Change Log:

------------------------------------------------------------------------------
@@ -19,3 +19,47 @@
  * a. User invokes JUnit Accessor method using either [wiki:/TCH TCH] or 
standard JUnit runner.
  * b. Test method in the JUnit Accessor sends request to corresponding test 
method on Controls client (JPF, JWS, Java)
  * c. The Client instantiates an instance of the test Control and an instance 
of the Driver.  The newly instantiated Control is passed to the corresponding 
test method on the Driver and a Report is returned.  The Report is passed back 
to the Client and the back to the Accessor where the result in recorded.
+
+= Writing Controls Tests =
+
+There are two main ways to write tests using Milton though in the end they 
have the same pieces.  The difference is in which of the four pieces you need 
ot provide.
+
+== Using Milton Client Generation ==
+
+This is the recommended way for writing Controls tests.  It is the the easiest 
and most efficient way of running end-to-end Controls tests.  Using Client 
Generation you need only write the Control(s) needed for testing and the Driver 
which excercises the test control(s).  Drivers are basically POJO which look 
similar to JUnit test cases with a few minor differences.
+
+Here is an example Driver:
+
+{{{
+import org.apache.beehive.test.tools.milton.common.Report;
+import org.apache.beehive.test.tools.milton.annotations.Milton;
+
+import 
org.apache.beehive.controls.test.controls.instantiate.InstantiateControlBean;
+
[EMAIL PROTECTED]
+public class InstantiationDriver
+{
+       @Milton.Test
+       public Report testInstantiation(InstatiateControlBean icb){
+
+               Report report = new Report();
+
+               if (icb == null) {
+                       report.setStatus(Report.FAIL);
+                       report.addMessage("InstantiateControlBean hcb is 
Null!");
+               }
+               else
+               {
+                       if (icb.echoString("hello").equals("hello"))
+                               report.setStatus(Report.PASS);
+                       else {
+                               report.setStatus(Report.FAIL);
+                               report.addMessage("hcb.echoString: " + 
hcb.echoString("hello"));
+                       }
+               }
+               return report;
+       }
+
+}
+}}}
+

Reply via email to