com.canoo.webtest.ant
Class WebtestTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by com.canoo.webtest.ant.WebtestTask
All Implemented Interfaces:
Cloneable, TaskContainer

public class WebtestTask
extends Task
implements TaskContainer

Ant task that specifies a Web Test Sequence.

Author:
Unknown, Marc Guillemot

Field Summary
static String DEFAULT_REPORTER_CLASSNAME
           
static String REPORTER_CLASSNAME_PROPERTY
           
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
WebtestTask()
           
 
Method Summary
 void addConfig(Configuration config)
          Called by ant to add the nested "configuration ..." task.
 void addSteps(TestStepSequence steps)
          Called by ant to add the nested "webtest ..." task.
 void addTask(Task task)
          In a first time doesn't support other tasks as config and testSpec, but this class has to implement TaskContainer to work with Groovy's AntBuilder (a bug in this AntBuilder?)
protected  void assertNotNull(Object parameter, String[] msg)
           
protected  void callSelectedReporter(String reporterClass, RootStepResult result)
           
protected  Configuration createDefaultConfiguration()
          Creates the default configuration to use if no was present in the ant file.
 void execute()
          Executes the task.
protected  void executeSteps()
          Execute the nested steps (except the configuration)
 Configuration getConfig()
           
 Map getDynamicProperties()
           
 String getDynamicProperty(String name)
           
 String getName()
          gets the name of this webtest
protected  StepExecutionListener getResultBuilderListener()
          TODO: check if it should really be accessible
 TestStepSequence getStepSequence()
           
static Context getThreadContext()
          Gets the context to use for this thread.
 IWebtestCustomizer getWebtestCustomizer()
           
protected  void logRunningTestInfo(String msg)
          Log Start/Success/Failed to running.txt in results folder.
protected  void report(IResultReporter reporter, RootStepResult result)
           
protected  void setConfig(Configuration config)
           
 void setDynamicProperty(String name, String value)
           
 void setName(String name)
           
 void setProject(Project project)
           
static void setThreadContext(Context context)
          Sets the context for this thread.
protected  void stopBuildIfNeeded(RootStepResult webTestResult, Configuration config)
           
protected  void writeTestReportIfNeeded(RootStepResult result)
           
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REPORTER_CLASSNAME_PROPERTY

public static final String REPORTER_CLASSNAME_PROPERTY
See Also:
Constant Field Values

DEFAULT_REPORTER_CLASSNAME

public static final String DEFAULT_REPORTER_CLASSNAME
See Also:
Constant Field Values
Constructor Detail

WebtestTask

public WebtestTask()
Method Detail

getThreadContext

public static Context getThreadContext()
Gets the context to use for this thread. In a normal execution, this is the one that is created at the beginning of <webtest> and which should be used by all the steps from this webtest. These tests may be nested within macros, external targets, ... and may not "see" the <webtest> directly.
A step doesn't need to call this method as it can access the context through Step.getContext().

Returns:
the currently used context, null if not inside the execution of a webtest.

setThreadContext

public static void setThreadContext(Context context)
Sets the context for this thread. Normally this method should not be public and only the webtest should use it. Its visibility will be restricted once the unit tests have been adapted.

Parameters:
context - the context to set

setDynamicProperty

public void setDynamicProperty(String name,
                               String value)

getDynamicProperty

public String getDynamicProperty(String name)

getDynamicProperties

public Map getDynamicProperties()

addConfig

public void addConfig(Configuration config)
Called by ant to add the nested "configuration ..." task.

Parameters:
config - the configuration task

addTask

public void addTask(Task task)
In a first time doesn't support other tasks as config and testSpec, but this class has to implement TaskContainer to work with Groovy's AntBuilder (a bug in this AntBuilder?)

Specified by:
addTask in interface TaskContainer
See Also:
TaskContainer.addTask(org.apache.tools.ant.Task)

addSteps

public void addSteps(TestStepSequence steps)
Called by ant to add the nested "webtest ..." task.

Parameters:
steps - the steps

execute

public void execute()
             throws BuildException
Executes the task. If it doesn't contain a nested <config> a default one is created using createDefaultConfiguration().

Overrides:
execute in class Task
Throws:
BuildException

logRunningTestInfo

protected void logRunningTestInfo(String msg)
Log Start/Success/Failed to running.txt in results folder.

Parameters:
msg - Start/Success/Failed

executeSteps

protected void executeSteps()
Execute the nested steps (except the configuration)


getResultBuilderListener

protected StepExecutionListener getResultBuilderListener()
TODO: check if it should really be accessible

Returns:
the listener that will build the results

createDefaultConfiguration

protected Configuration createDefaultConfiguration()
Creates the default configuration to use if no was present in the ant file.

Returns:
the configuration

stopBuildIfNeeded

protected void stopBuildIfNeeded(RootStepResult webTestResult,
                                 Configuration config)

assertNotNull

protected void assertNotNull(Object parameter,
                             String[] msg)

setName

public void setName(String name)
Parameters:
name -

getName

public String getName()
gets the name of this webtest

Returns:
the name (as specified in <webtest name="...">)

writeTestReportIfNeeded

protected void writeTestReportIfNeeded(RootStepResult result)

callSelectedReporter

protected void callSelectedReporter(String reporterClass,
                                    RootStepResult result)

report

protected void report(IResultReporter reporter,
                      RootStepResult result)

getConfig

public Configuration getConfig()

setConfig

protected void setConfig(Configuration config)

setProject

public void setProject(Project project)
Overrides:
setProject in class ProjectComponent

getWebtestCustomizer

public IWebtestCustomizer getWebtestCustomizer()

getStepSequence

public TestStepSequence getStepSequence()

Copyright © 2001-2007 Canoo Engineering AG, Basel. All rights reserved.