Date: 2005-01-28T12:06:39
Editor: ZacharySmith
Wiki: Apache Beehive Wiki
Page: Controls/TestingControls/Milton
URL: http://wiki.apache.org/beehive/Controls/TestingControls/Milton
no comment
Change Log:
------------------------------------------------------------------------------
@@ -28,7 +28,7 @@
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:
+'''Here is an example Driver:'''
{{{
import org.apache.beehive.test.tools.milton.common.Report;
@@ -77,3 +77,51 @@
* 4. `modifier()` is used to change the java access modifier for your
control. By default it is `public`.
* 4. The Test Method Body
* 1. In the example this test expects to receive a non-null
`InstantiateControlBean` instance from the client. The `ControlBean` has a
method called `echoString(String s)` which should simply return back the String
passed to it. A `Report` is instantiated at the beginning of the method and
updated as the test progresses and is then returned.
+
+== Using Milton without Client Generation ==
+
+There will be cases when the limitations in the Client Generation will impare
your ability to write tests (it is generating code after all - we can't read
your mind and anticipate 'all' posibilty testing scearios) or you may just
prefer to write all the parts yourself. This section will describe the parts
you'll need to write and provide descriptions. For those who are using Client
Generation this section will be useful if you wish to understand what is
generated for your tests to run.
+
+ * 1. The Controls: You will always need to write the Test Controls no matter
how you choose to write your tests.
+ * 1. The Driver: When not using Client Generation it is still recommended
that you use the Driver style of writing tests but leave the [EMAIL PROTECTED]
annotations out. The conventions which are inforced when you use Client
Generation are still encouraged when you write it yourself.
+ * 2. The Client(s): You will need to write the JPF and JWS clients for your
test.
+ * 3. The JUnit Accessors: These are the simple JUnit files which invoke the
tests on your clients.
+
+'''JPF Example:'''
+
+{{{
+import org.apache.beehive.netui.pageflow.PageFlowController;
+import org.apache.beehive.netui.pageflow.Forward;
+import org.apache.beehive.netui.pageflow.annotations.Jpf;
+
+import org.apache.beehive.controls.api.bean.Control;
+
+import
org.apache.beehive.controls.test.controls.instantiate.InstantiateControlBean;
+import
org.apache.beehive.controls.test.driver.instantiate.InstantiationeDriver;
+
+import org.apache.beehive.test.tools.milton.common.Report;
+
[EMAIL PROTECTED](
+forwards = { @Jpf.Forward(name=Report.RESULTS,path = Report.RESULTSJSP) }
+)
+public class Controller extends PageFlowController
+{
+ @Control
+ public InstantiateControlBean icb;
+
+ @Jpf.Action
+ protected Forward begin()
+ {
+ return new Forward(Report.RESULTS, Report.KEY, new
+ Report(Report.ABORT,"begin() is not a test method!"));
+ }
+
+ @Jpf.Action
+ public Forward testInstantiation()
+ {
+ Report report = new Report()
+ InstantiationDriver id = new InstantiationDriver();
+ return new Forward(Report.RESULTS, Report.KEY,
id.testInstantiation(icb));
+ }
+}
+}}}