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. It has evolved into
<a href="http://www.tcl.tk/cgi-bin/tct/tip/452.html">TIP-452</a>. 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 </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;">. </span></p>
<p>The
<span style="font-family: Monaco; font-size: 12px;"> following commands
are added to the tcl test package:</span></p>
<div>
<ul>
<li><b>::tcltest::testSetup</b> - Defines which procedures/commands are
stubbed out
<span style="font-size: 10pt;">and how they should behave for each invocation.
This should</span>
<span style="font-size: 10pt;"> only be called once per test.</span></li>
<li><b>::<b> tcltest</b>::addStub</b> - Adds a procedures/commands
to the list that are stubbed out.</li>
<li><b>::<b> tcltest</b>::saveVars</b> - Saves the values of
variables to be restored later. This should
<span style="font-size: 10pt;"> only be called once per test.</span></li>
<li><b>::<b> tcltest</b>::addVars</b> - Add a variable to the list of
variables to be restored later</li>
<li><b>::<b> tcltest</b>::callCount </b>- Returns a dictionary sorted
list of the stubbed out
<span style="font-size: 10pt;">procedures and how many times they were called.</span></li>
<li><b>::<b> tcltest</b>::testCleanup </b>- Restores saved variables
and stubbed out procedures.</li>
<li><b>::<b> tcltest</b>::sortedArrayData</b> - Return the values of an
array as a list of key value
<span style="font-size: 10pt;"> pairs sorted by the keys.</span></li>
<li><b>::<b> tcltest</b>::callProc</b> - Call the real implementation
of a stubbed out procedure.</li>
<li><b>::<b> tcltest</b>::seam </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. 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;"> </span><b style="font-size: 10pt;">::tcltest::testObject</b>
<span style="font-size: 10pt;"> <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> <i>creationArgumentList</i> --
</font>arguments to pass in when creating the object<font size="2"> </font></li>
<li><font size="2"><b>-constructor</b> <i>script</i> -- </font>override<font size="2"> the
class constructor with the </font></li>
<li><font size="2"><b>-destructor</b> <i>script</i> -- </font>
<span style="font-size: 10pt;">override</span><font size="2"> the class
destructor with the </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 defined in the class) to be "replaced" by the
contained definition. Each element of <i>stubDefList</i> is a
duple with the following format:</font></li>
<ul>
<li><font size="2"><i>methodName methodBody</i> -- The </font><i>methodBody</i> will
be executed when ever <i>methodName</i> 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