You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by bu...@apache.org on 2015/02/19 11:06:59 UTC
svn commit: r940703 - in /websites/staging/isis/trunk: cgi-bin/ content/
content/more-advanced-topics/Fixture-Scripts.html
Author: buildbot
Date: Thu Feb 19 10:06:59 2015
New Revision: 940703
Log:
Staging update by buildbot for isis
Modified:
websites/staging/isis/trunk/cgi-bin/ (props changed)
websites/staging/isis/trunk/content/ (props changed)
websites/staging/isis/trunk/content/more-advanced-topics/Fixture-Scripts.html
Propchange: websites/staging/isis/trunk/cgi-bin/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Thu Feb 19 10:06:59 2015
@@ -1 +1 @@
-1660824
+1660826
Propchange: websites/staging/isis/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Thu Feb 19 10:06:59 2015
@@ -1 +1 @@
-1660824
+1660826
Modified: websites/staging/isis/trunk/content/more-advanced-topics/Fixture-Scripts.html
==============================================================================
--- websites/staging/isis/trunk/content/more-advanced-topics/Fixture-Scripts.html (original)
+++ websites/staging/isis/trunk/content/more-advanced-topics/Fixture-Scripts.html Thu Feb 19 10:06:59 2015
@@ -528,10 +528,23 @@ to any of the objects created/updated by
<pre><code>simpleObjectPojo = fs.getSimpleObjects().get(0);
</code></pre>
+<p>There's further discussion on this style of writing fixture scripts (with the input "setNumber" property and the
+output "simpleObjects" property) below.</p>
+
<h2>Writing Fixture Scripts</h2>
-<p>All fixture scripts subclass the <code>FixtureScript</code> class (defined in the applib), providing an implementation of the
-<code>execute(ExecutionContext)</code> method:</p>
+<p>We find it's helpful to distinguish:</p>
+
+<ul>
+<li>scenario fixture scripts - coarse-grained, to accomplish a particular business goal (or set up a bunch of related data)</li>
+<li>action fixture scripts - fine-grained, perform a single action on a domain object or service</li>
+</ul>
+
+<p>Scenario scripts can be called from the UI, making it easy to demonstrate new features, or for manual exploratory testing.
+These scenario scripts then call action scripts, with the action scripts as the atomic building blocks that do the actual work.</p>
+
+<p>Both scenario scripts and action scripts are subclasses of the <code>FixtureScript</code> class (defined in the applib), with an
+implementation of the <code>execute(ExecutionContext)</code> method:</p>
<pre><code>public abstract class FixtureScript ... {
@Programmatic
@@ -543,7 +556,7 @@ to any of the objects created/updated by
<p>The <code>ExecutionContext</code> provides three main capabilities to the fixture script:</p>
<ul>
-<li>the script can execute other child fixture scripts (1.8.0-SNAPSHOT)</li>
+<li>the script can execute other child fixture scripts (eg a scenario script calling an action script) (1.8.0-SNAPSHOT)</li>
</ul>
<pre>
@@ -561,7 +574,9 @@ to any of the objects created/updated by
executionContext.addResult(this, someObject);
</pre>
-<p>(Prior to 1.8.0-SNAPSHOT, child fixture scripts are executed using the inherited `FixtureScript#executeChild(FixtureScript, ExecutionContext) method. That has now been deprecated).</p>
+<blockquote>
+ <p>Prior to 1.8.0-SNAPSHOT, child fixture scripts were executed using the inherited <code>FixtureScript#executeChild(FixtureScript, ExecutionContext)</code> method. That has now been deprecated).</p>
+</blockquote>
<p>The script can do whatever is necessary within its <code>execute</code> method to set up the state of the system (read: insert data
into the database). One way of doing this would be simple SQL INSERT or UPDATE statements, or calling stored procs to
@@ -572,7 +587,7 @@ in those SQL statements will be out-of-d
on the domain objects. Then, if those actions change in the future, the scripts remain valid. Put another way: have
the fixture scripts replay the "cause" of the change (business actions) rather than the "effect" (data inserts).</p>
-<h2>Using input and output Parameters</h2>
+<h3>Execution context parameters</h3>
<p>As the screenshots above show, the <code>FixtureScripts#runFixtureScript</code> action allows optional parameters to be provided to the called fixture scripts:</p>
@@ -626,15 +641,11 @@ that parses that initial string into a s
}
</code></pre>
-<p>and so on. For example:</p>
+<p>For example:</p>
<pre>
LocalDate dob = executionContext.getParameterAsLocalDate("dateOfBirth");
-</pre>
-
-<p>Alternatively <code>getParameter(String, Class<T>)</code> can be used, specifying the desired datatype:</p>
-
-<pre>
+ // or equivalently:
LocalDate dob = executionContext.getParameterAsT("dateOfBirth", LocalDate.class);
</pre>
@@ -650,9 +661,7 @@ that parses that initial string into a s
}
</code></pre>
-<p>and so on. For example:</p>
-
-<p>and</p>
+<p>For example:</p>
<pre>
executionContext.setParameter("dateOfBirth", clockService.now().minus(new Years(18)));
@@ -660,20 +669,10 @@ that parses that initial string into a s
<p>This provides a useful mechanism for sharing data between fixture scripts that call child fixture scripts. And on that topic...</p>
-<h2>Scenario scripts and action scripts</h2>
-
-<p>We find it's helpful to distinguish:</p>
-
-<ul>
-<li>scenario fixture scripts - coarse-grained, to accomplish a particular business goal (or set up a bunch of related data)</li>
-<li>action fixture scripts - fine-grained, perform a single action on a domain object or service</li>
-</ul>
-
-<p>Scenario scripts can be called from the UI, making it easy to demonstrate new features, or for manual exploratory testing.
-These scenario scripts then call action scripts, with the action scripts as the atomic building blocks that do the actual work.</p>
+<h2>Input and output properties</h2>
-<p>We also recommend that fixture scripts define (as simple JavaBean properties) both <code>input</code> parameters and also <code>output</code> parameters.
-Input parameters/properties are used to adjust the behaviour of the fixture script, while the output properties provide the means for
+<p>We also recommend that fixture scripts define both inputs and outputs, as simple JavaBean properties.
+Input properties are used to adjust the behaviour of the fixture script, while the output properties provide the means for
the fixture script to make the object(s) created/modified available to a calling integration test.</p>
<p>So that they can be "just be executed" from the UI, scenario scripts should have defaults for all inputs. A lot of