1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>CLUnit: Macro DEFTEST</TITLE>
</HEAD>
<BODY>
<A HREF="CLUnit.html"><img src="clunit-small.jpg" align=right width="100" height="27" border="0" alt="CLUnit"></A>
<p><I>Macro</I> <B>DEFTEST</B></p>
<p><B>Syntax:</B></p>
<p><B>deftest</B> <I>description</I> <TT>&key</TT> <I>category test-fn compare-fn output-fn output-form input-fn input-form</I> => <I>test</I></p>
<P><B>Arguments and Values:</B></P>
<P><I>description</I>---a string</P>
<P><I>category</I>---a string</P>
<P><I>test-fn</I>---a function</P>
<P><I>compare-fn</I>---a function</P>
<P><I>output-fn</I>---a function</P>
<P><I>output-form</I>---a form</P>
<P><I>input-fn</I>---a function</P>
<P><I>input-form</I>---a form</P>
<P><B>Description:</B></P>
<P><B><A HREF="deftest.html">deftest</A></B> defines a test to be run by CLUnit.
The test is automatically registered with CLUnit and is afterwards available to
be run by CLUnit.</P>
<P>The test is identified by its description, but the user can also specify a category into
which the test is to be placed. All tests from a given category can be run using the function
<B><A HREF="run-category.html">run-category</A></B>. In
addition, a specific test or all tests can be run using the functions
<B><A HREF="run-named-test.html">run-named-test</A></B> or
<B><A HREF="run-all-tests.html">run-all-tests</A></B> respectively.</p>
<p>In addition to its identification and categorization attributes, a test
also has four
functional attributes: its <I>input function</I>, its <I>test function</I>,
its <I>output function</I>, and its <I>comparison function</I>. These
attributes are used when the test is run to determine
whether the test has <I>passed</I> or <I>failed</I>.</P>
<P>The test is run using the following procedure:
<OL>
<LI> The input function of the test is evaluated to provide a set of values, collected by multiple-value-list.</LI>
<LI> The test's test function is applied to values returned by the input function
and the resulting set of output values is collected using multiple-value-list.</LI>
<LI>The output function of the test is evaluated to give a set
of values that are also collected using multiple-value-list.</LI>
<LI>The test's comparison function is used to compare the lists resulting from the
evaluation of the test function and output function.</LI>
<LI>The output of the comparison function is returned as the value of the test.</LI>
</OL>
<P>If the comparison function
returns <I>t</I>, the test is said to have passed. If the test returns nil or
an error is encountered while running the test, the test has failed.</P>
<P>In addition to its <I>description</I> parameter, <B><A HREF="deftest.html">deftest</A></B> will
accept a variety of other keyword parameters:
<UL>
<LI><TT>:category</TT> is used to specify the category for the test. If left unspecified, the
test is categorized under the category *UNCATEGORIZED*.</LI>
<LI><TT>:test-fn</TT> specifies the <I>test function</I> to be used by the test. If unspecified,
the test function defaults to <tt>#'(lambda () t)</tt>.</LI>
<LI><TT>:compare-fn</TT> specifies the <I>comparison function</I> to be used by the test.
If not specified, it defaults to <TT>#'equal</tt>.
<LI><TT>:input-fn</TT> and <TT>:input-form</TT> parameters are used to specify
the <I>input function</I>
used by the test. If <TT>:input-fn</TT> is specified, its value is used as the test's
input function. If unspecified,
the value of the <TT>:input-form</tt> parameter is used to create a function returning
that value to be used as the input function for the test. Lambda expressions used or
formed by these parameters are created within the lexical environment within which the
deftest form is located. If neither of these parameters
is provided, the test function is assumed to take no input parameters.</LI>
<LI><TT>:output-fn</TT> and <TT>:output-form</TT> parameters are used to specify
the <I>output function</I>
used by the test. If <TT>:output-fn</TT> is specified, its value is used as the test's
output function. If unspecified,
the value of the <TT>:output-form</tt> parameter is used to create a function returning
that value to be used as the output function for the test. Lambda expressions used or
formed by these parameters are created within the lexical environment within which the
deftest form is located. If neither of these parameters
is provided, the test function defaults to <TT>#'(lambda () t)</tt>.</LI>
</UL>
<P><B>See Also:</B></P>
<P><B><A HREF="run-named-test.html">run-named-test</A></B>, <B><A HREF="run-all-tests.html">run-all-tests</A></B>,
<B><A HREF="run-category.html">run-category</A></B>, <B><A HREF="remove-test.html">remove-test</A></B></P>
<P><B>Notes:</B></p>
<P>Redefining a test with a given name will replace the original test with the new one.</P>
<P>Redefining a test with a given name will move the test to the category specified in
the redefinition.</p>
<HR>
<address>
<a href="http://validator.w3.org/check/referer"><img
src="http://www.w3.org/Icons/valid-html32" height="31" width="88"
align=right border="0" alt="Valid HTML 3.2!"></a>
<a href="mailto:fadrian@qwest.net">Frank A. Adrian</a><br>
Last modified: 12 July, 2001 14:59
</address>
</body>
</html>
|