JsUnit |
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 Rhino to perform the JavaScript tests.
The Ant task is available from the Maven 2 repository of JsUnit at BerliOS, download here.
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.
The JsUnit Ant task has to be declared first
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:
The following JsUnit task is used in the Ant build script of the samples directory.
JsUnit © 1999, 2000, 2001, 2002, 2003, 2006, 2007 by Jörg Schaible
|
Generated on Wed Apr 15 2015 02:33:06 for JsUnit by doxygen 1.8.5
|