<?xml version="1.0" encoding="ISO-8859-1"?>
<document>
<head>
    <name>Using AutoDoc</name>
    <doc-version>$Date: 2003/05/27 13:32:52 $</doc-version>
    <author>Matt Albrecht</author>
</head>
<body>
<section>Adding AutoDoc To Your Tests</section>
<P>
To get started with using AutoDoc, first declare an instance of the
AutoDoc facade in your test:

<PRE CLASS="JavaCode"><SPAN CLASS="gutter">1:</SPAN><SPAN CLASS="syntax7">import</SPAN><SPAN CLASS="syntax125"> </SPAN>net.sourceforge.groboutils.autodoc.v1.AutoDoc;
<SPAN CLASS="gutter">2:</SPAN><SPAN CLASS="syntax6">public</SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax8">class</SPAN><SPAN CLASS="syntax125"> </SPAN>MyUTest<SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax6">extends</SPAN><SPAN CLASS="syntax125"> </SPAN>TestCase
<SPAN CLASS="gutter">3:</SPAN><SPAN CLASS="syntax11">{</SPAN>
<SPAN CLASS="gutter">4:</SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax6">private</SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax6">static</SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax6">final</SPAN><SPAN CLASS="syntax125"> </SPAN>Class<SPAN CLASS="syntax125"> </SPAN>THIS_CLASS<SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax11">=</SPAN><SPAN CLASS="syntax125"> </SPAN>MyUTest.<SPAN CLASS="syntax8">class</SPAN>;
<SPAN CLASS="gutterH">5:</SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax6">private</SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax6">static</SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax6">final</SPAN><SPAN CLASS="syntax125"> </SPAN>AutoDoc<SPAN CLASS="syntax125"> </SPAN>DOC<SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax11">=</SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax6">new</SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax9">AutoDoc</SPAN>(<SPAN CLASS="syntax125"> </SPAN>THIS_CLASS<SPAN CLASS="syntax125"> </SPAN>);
</PRE>

This will create a new AutoDoc instance that has associations with its
generated documentation to this class, much like standard logging frameworks.
</P>
<P>
Then, whenever you need a bit of documentation in your test, you can reference
this <tt>DOC</tt> instance.
</P>
<P>
To add logging, use something like:
<PRE CLASS="JavaCode"><SPAN CLASS="gutter">1:</SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN>DOC.<SPAN CLASS="syntax9">getLog</SPAN>().<SPAN CLASS="syntax9">info</SPAN>(<SPAN CLASS="syntax3">&quot;</SPAN><SPAN CLASS="syntax3">=====</SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax3">Adding</SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax3">test</SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax3">for</SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax3">&quot;</SPAN><SPAN CLASS="syntax11">+</SPAN>testname);
</PRE>
The different levels of logging are <tt>debug</tt>, <tt>info</tt>, and
<tt>warn</tt>.  Each may take, as arguments: <tt>(Object)</tt>,
<tt>(Object[])</tt>, <tt>(Object, Throwable)</tt>, and
<tt>(Object[], Throwable)</tt>.
</P>
<P>
To reference a bug or problem tracker ticket, use:
<PRE CLASS="JavaCode"><SPAN CLASS="gutterH">1:</SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax125"> </SPAN>DOC.<SPAN CLASS="syntax9">getIT</SPAN>().<SPAN CLASS="syntax9">testsIssue</SPAN>(<SPAN CLASS="syntax125"> </SPAN><SPAN CLASS="syntax12">526454</SPAN><SPAN CLASS="syntax125"> </SPAN>);
</PRE>
It takes as arguments a method name (<tt>String</tt>) followed by the
ticket ID (<tt>String</tt> or <tt>long</tt>), or the ticket ID by itself.
If the ticket ID is given alone, then the method name is dynamically
discovered using stack trace evaluation.
</P>
</body>
</document>
