Artifact [67d842316f]

Artifact 67d842316fb2e6aa6eb5d344a2dbe202cade71a542cd5e8e4e895dfeff0f2c4e:

Wiki page [Tcl Test Utilities] by gwlester 2017-06-13 20:22:23.
D 2017-06-13T20:22:23.252
L Tcl\sTest\sUtilities
P 7be41607eb1b2ac022fa1ff51b6ef8176b2df2f08bc6d8f16cb6c9844b7a5a02
U gwlester
W 5407
<p>This project is dedicated to utilities to make Agile Software Engineering,
in particular Test Driven Development easier in Tcl. &nbsp;It has evolved into
<a href="http://www.tcl.tk/cgi-bin/tct/tip/452.html">TIP-452</a>. &nbsp;This
repository shall remain until the TIP is accepted and shipped.</p>

<p>Please do not use the code in this repository, but rather that in the tip's
branch.</p>

<p>If you intend to use this in a Tcl version prior to the TIP being accepted
and shipped, then t

<span style="font-size: 10pt;">he contents of the&nbsp;</span><font face="Monaco" style="font-size: 10pt;">

<span style="font-size: 12px;"><b>TestSeam.tcl</b> file should be placed in
your <b>init.tcl</b> file</span></font>

<span style="font-family: Monaco; font-size: 12px;">.&nbsp;</span></p>

<p>The

<span style="font-family: Monaco; font-size: 12px;">&nbsp;following commands
are added to the tcl test package:</span></p>

<div>
<ul>
<li><b>::tcltest::testSetup</b>&nbsp;- Defines which procedures/commands are
stubbed out&nbsp;

<span style="font-size: 10pt;">and how they should behave for each invocation.
This should</span>

<span style="font-size: 10pt;">&nbsp;only be called once per test.</span></li>
<li><b>::<b>&nbsp;tcltest</b>::addStub</b>&nbsp;- Adds a procedures/commands
&nbsp;to the list that are stubbed out.</li>
<li><b>::<b>&nbsp;tcltest</b>::saveVars</b>&nbsp;- Saves the values of
variables to be restored later. This should

<span style="font-size: 10pt;">&nbsp;only be called once per test.</span></li>
<li><b>::<b>&nbsp;tcltest</b>::addVars</b>&nbsp;- Add a variable to the list of
variables to be restored later</li>
<li><b>::<b>&nbsp;tcltest</b>::callCount&nbsp;</b>- Returns a dictionary sorted
list of the stubbed out&nbsp;

<span style="font-size: 10pt;">procedures and how many times they were called.</span></li>
<li><b>::<b>&nbsp;tcltest</b>::testCleanup&nbsp;</b>- Restores saved variables
and stubbed out procedures.</li>
<li><b>::<b>&nbsp;tcltest</b>::sortedArrayData</b> - Return the values of an
array as a list of key value

<span style="font-size: 10pt;">&nbsp;pairs sorted by the keys.</span></li>
<li><b>::<b>&nbsp;tcltest</b>::callProc</b>&nbsp;- Call the real implementation
of a stubbed out procedure.</li>
<li><b>::<b>&nbsp;tcltest</b>::seam&nbsp;</b>- Test seam definition and
injection (aka enabling)</li>
<li>

<span style="font-size: 10pt;"><b>::tcltest::testObject </b>- This command
creates an instance of an object, runs the specified test against it and then
destroys the object. &nbsp;The syntax is:</span></li>
</ul></div>

<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">

<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">

<div>

<span style="font-size: 10pt;">&nbsp;</span><b style="font-size: 10pt;">::tcltest::testObject</b>

<span style="font-size: 10pt;">&nbsp;<i>name description class ?-options...?</i></span></div>

<div><b style="font-size: 10pt;"><br>
</b></div></blockquote></blockquote>

<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">

<div>

<span style="font-size: 10pt;">It supports all options of</span><b style="font-size: 10pt;">::tcltest::test
</b>

<span style="font-size: 10pt;">plus those listed below:</span></div></blockquote>

<div>
<ul>
<ul>
<li><font size="2"><b>-arguments</b>&nbsp;<i>creationArgumentList</i>&nbsp;--
</font>arguments to pass in when creating the object<font size="2">&nbsp;</font></li>
<li><font size="2"><b>-constructor</b>&nbsp;<i>script</i>&nbsp;--&nbsp;</font>override<font size="2">&nbsp;the
class&nbsp;constructor with the&nbsp;</font></li>
<li><font size="2"><b>-destructor</b>&nbsp;<i>script</i>&nbsp;--&nbsp;</font>

<span style="font-size: 10pt;">override</span><font size="2">&nbsp;the class
destructor with the&nbsp;</font><br>
</li>
<li><font size="2"><b>-objectVar </b><i>variableName</i> -- name to hold the
created object, defaults to "cut"</font></li>
<li><font size="2"><b>-stubs</b> <i>stubDefList</i> -- a list of "instance"
methods (those&nbsp;defined in the class) to be "replaced" by&nbsp;the
contained definition. &nbsp;Each element of&nbsp;<i>stubDefList</i>&nbsp;is a
duple with the following format:</font></li>
<ul>
<li><font size="2"><i>methodName methodBody</i> -- The&nbsp;</font><i>methodBody</i>&nbsp;will
be executed when ever&nbsp;<i>methodName</i>&nbsp;is called instead of the
"real" definition.</li>
</ul>
</ul>
</ul>

<h2>Supporting Class</h2></div>

<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">

<h3>::tcltest::object - Class to provide useful object testing utilities</h3></blockquote>

<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">

<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">

<h4>Synopsis</h4>

<div>

<h3><font size="2">Description</font></h3>

<blockquote style="margin: 0px 0px 0px 40px; padding: 0px; border: none;"></blockquote></div>

<h3>

<span style="font-size: 10pt;">Exported Static Methods</span></h3></blockquote>

<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">

<h4>Exported Instance Methods</h4></blockquote></blockquote>

<div>

<h2>Acknowledgements</h2>
<pre>Thanks to Sean Woods for providing major help with the object based extensions.</pre>
<pre>Thanks to <a href="www.noucorp.com">Noumena Corporation</a> for encouragement and for supporting the Tcl community.</pre>
<ul>
</ul></div>

Z ab66c4270e6ee629a5ffd8a44794bc7e