blob: 3824276376e8572249ae6b2afef6f1876286a807 [file] [log] [blame]
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<head>
<meta http-equiv="Content-Language" content="en-us"></meta>
<link rel="stylesheet" type="text/css" href="style.css">
<title>AntUnit Ant Library</title>
</head>
<body>
<h2>Introduction</h2>
<p>This is a library of Ant tasks that support writing tests for
tasks using build files instead of JUnit.</p>
<h2>Requirements</h2>
<p>The current version requires Ant 1.8.1 or later.</p>
<h2>Where is it?</h2>
<p>The source code for the library lives in the
ant-antlibs-antunit git repository - <a
href="https://git1-us-west.apache.org/repos/asf?p=ant-antlibs-antunit.git">https://git-wip-us.apache.org/repos/asf/ant-antlibs-antunit.git</a>.</p>
<h2>Installation</h2>
<p>If you are building this from sources, run the antlib target
and you'll get a file <code>ant-antunit.jar</code>.</p>
<p>There are several ways to use the tasks:</p>
<ul>
<li>The traditional way:
<pre>
&lt;taskdef
resource="org/apache/ant/antunit/antlib.xml"&gt;
&lt;classpath&gt;
&lt;pathelement location="YOUR-PATH-TO/ant-antunit.jar"/&gt;
&lt;/classpath&gt;
&lt;/taskdef&gt;
</pre>
With this you can use the tasks like plain Ant tasks, they'll
live in the default namespace. I.e. if you can run
&lt;exec&gt; without any namespace prefix, you can do so for
&lt;antunit&gt; as well.
</li>
<li>Similar, but assigning a namespace URI
<pre>
&lt;taskdef
uri="antlib:org.apache.ant.antunit"
resource="org/apache/ant/antunit/antlib.xml"&gt;
&lt;classpath&gt;
&lt;pathelement location="YOUR-PATH-TO/ant-antunit.jar"/&gt;
&lt;/classpath&gt;
&lt;/taskdef&gt;
</pre>
This puts you task into a separate namespace than Ant's
namespace. You would use the tasks like
<pre>
&lt;project
xmlns:au="antlib:org.apache.ant.antunit"
xmlns="antlib:org.apache.tools.ant"&gt;
...
&lt;au:assertTrue&gt;
&lt;equals arg1="1" arg2="2"/&gt;
&lt;/au:assertTrue&gt;
</pre>
or a variation thereof.
</li>
<li>Using Ant's autodiscovery. Place <code>ant-antunit.jar</code>
into a directory and use <code>ant -lib
DIR-CONTAINING-THE-JAR</code> or copy it into
<code>ANT_HOME/lib</code> - and then in your build file, simply
declare the namespace on the <code>project</code> tag:
<pre>
&lt;project
xmlns:au="antlib:org.apache.ant.antunit"
xmlns="antlib:org.apache.tools.ant"&gt;
</pre>
And all tasks of this library will automatically be available
in the <code>au</code> namespace without any
<code>taskdef</code>.
</li>
</ul>
<h2>Tasks and Types</h2>
<ul>
<li><a href="antunit.html">antunit</a> - run unit tests, the
tests are defined using build files that contain targets which
follow a certain naming convention. This task borrows a lot of
ideas from JUnit 3 and the junit task.</li>
<li><a href="assert.html">assertTrue</a> - asserts a condition
and throws a custom BuildException if the assertion fails.</li>
<li><a href="assertions.html">more assertions</a> - useful
specialized versions of assertTrue.</li>
<li><a href="expectfailure.html">expectfailure</a> - a task
container useful for tests that assert build failures.</li>
<li><a href="logcontent.html">logcontent</a> - an Ant Resource
that contains the log output of an AntUnit test.</li>
</ul>
<hr/>
</body>
</html>