/* JsUnit - a JUnit port for JavaScript Copyright (C) 2007 Joerg Schaible Licensed 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. */ /*! \htmlonly
\endhtmlonly \page ant Apache Ant

Ant is a build tool from the Apache Software Foundation generally used for Java development. Ant uses an XML-based build script (by default build.xml to define build targets. Each target consists of a sequence of tasks that must be executed. Typically exists a target test that builds the project (because of a dependency to the compile target), runs the tests (as a result of executing the junit task) and creates a test report (created by the junitreport task).

Especially in Java-based web projects exists often also JavaScript files that are included into HTML pages. Such files can contain methods and JavaScript classes that should be also tested like the other Java source. JsUnit provides therefore a jsunit task that can be used as replacement or in addition to a junit task. It generates the XML in the same format that is used later on by the jsunitreport task to generate the reports.

The jsunit task embeds \ref rhino to perform the JavaScript tests.

\section antdownload Download Ant Task

The Ant task is available from the Maven 2 repository of JsUnit at BerliOS, download here.

\section antsetup Setting up Ant

To run the JsUnit task you must setup Ant. It must find during execution the Java classes of the task itself and the classes the task is dependent on. Following Jars are necessary:

You may provide them on command line calling Ant with the lib option, add them to the CLASSPATH, or put them into Ant's lib directory.

Note, that depending on the on the Ant installation it often happens that the junitreport task fails with a missing classes org.apache.xalan.processor.TransformerFactoryImpl or org.apache.xml.serializer.SerializerTrace. Reason is a missing Xalan version. Take a recent one (>= 2.5) and add it to Ant's lib directory. Take care what you add. The binary distribution of Xalan comes with multiple jars, you have to add xalan_j.jar and serializer.jar. If you take the Xalan version located in the Maven repository anything is already included.

\section anttask Using the Ant Task

The JsUnit Ant task has to be declared first

\code \endcode

The task itself has a dir attribute that defines the root directory for all following file declarations. A JsUnit task may contain multiple source and testsuite subtasks. A JavaScript file to test is declared with every source tag using the file attribute. The reason for an explicit declaration is a possible dependency between the files, that is resolved by loading them in the declared sequence.

The JavaScript test files are declared using the testsuite subtasks. A TestSuite subtask supports following attributes:

\section antexample Example build.xml The following JsUnit task is used in the Ant build script of the samples directory. \dontinclude build.xml \skip \endhtmlonly */