de.berlios.jsunit.ant
Class JsUnitTask

java.lang.Object
  extended byorg.apache.tools.ant.ProjectComponent
      extended byorg.apache.tools.ant.Task
          extended byde.berlios.jsunit.ant.JsUnitTask

public class JsUnitTask
extends org.apache.tools.ant.Task

An Ant task for JsUnit. The task allows the execution of JavaScript unit tests and creates XML reports, that can be processed by the Ant junitreport task. Define the task as follows:

      <taskdef name="jsunit" className="de.berlios.jsunit.ant.JsUnitTask" />
      
      <jsunit dir="sourceDir">
          <source file="money/IMoney.js" />
          <testsuite name="MyTestSuite" todir="build/test-reports" type="TESTSUITES">
              <fileset dir=".">
                  <include name="* /**Test.js" />
              </fileset>
          </testsuite>
      </jsunit>
 

You may declare multiple source tags, the scripts are loaded into the declared order. You may also declare multiple testsuite sections, each one will generate a separate XML report. The type of the test suite can be one of the following values:

ALLTESTS
Looks for a class AllTests derived from TestSuite and runs its suite.
TESTSUITES
Looks for all classes ending with TestSuite and that are derived from TestSuite and run their suites.
TESTCASES
Looks for all classes ending with TestCase and that are derived from TestCase and runs them (the default).

Since:
upcoming
Author:
Jörg Schaible

Nested Class Summary
 class JsUnitTask.SourceFile
          A utility bean for a SourceFile.
 
Field Summary
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
JsUnitTask()
           
 
Method Summary
 JsUnitTask.SourceFile createSource()
          Creates a new source.
 JsUnitSuite createTestSuite()
          Creates a new test suite.
 void execute()
           
 boolean isHaltOnError()
          Requests the haltOnError flag.
 boolean isHaltOnFailure()
          Requests the haltOnFailure flag.
 void setDir(java.io.File dir)
          Sets the source directory.
 void setHaltOnError(boolean haltOnError)
          Sets haltOnError flag.
 void setHaltOnFailure(boolean haltOnFailure)
          Sets haltOnFailure flag.
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsUnitTask

public JsUnitTask()
Method Detail

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Throws:
org.apache.tools.ant.BuildException

setDir

public void setDir(java.io.File dir)
Sets the source directory.

Parameters:
dir - the directory.
Since:
upcoming

isHaltOnError

public boolean isHaltOnError()
Requests the haltOnError flag.

Returns:
true if set
Since:
upcoming

setHaltOnError

public void setHaltOnError(boolean haltOnError)
Sets haltOnError flag.

Parameters:
haltOnError - the value
Since:
upcoming

isHaltOnFailure

public boolean isHaltOnFailure()
Requests the haltOnFailure flag.

Returns:
true if set
Since:
upcoming

setHaltOnFailure

public void setHaltOnFailure(boolean haltOnFailure)
Sets haltOnFailure flag.

Parameters:
haltOnFailure - the value
Since:
upcoming

createTestSuite

public JsUnitSuite createTestSuite()
Creates a new test suite.

Returns:
the test suite
Since:
upcoming

createSource

public JsUnitTask.SourceFile createSource()
Creates a new source.

Returns:
the source file reference
Since:
upcoming


Copyright © 2007 Joerg Schaible. All Rights Reserved.