org.apache.tools.ant.taskdefs.optional.testing

Class Funtest

public class Funtest extends Task

Task to provide functional testing under Ant, with a fairly complex worflow of: The task is designed to be framework neutral; it will work with JUnit, TestNG and other test frameworks That can be executed from Ant. It bears a resemblance to the FunctionalTest task from SmartFrog, as the attribute names were chosen to make migration easier. However, this task benefits from the ability to tweak Ant's internals, and so simplify the workflow, and from the experience of using the SmartFrog task. No code has been shared.

Since: Ant 1.8

Field Summary
static StringAPPLICATION_EXCEPTION
Application exception :
static StringAPPLICATION_FORCIBLY_SHUT_DOWN
static StringSHUTDOWN_INTERRUPTED
static StringSKIPPING_TESTS
static StringTEARDOWN_EXCEPTION
Teardown exception :
static StringWARN_OVERRIDING
Method Summary
voidaddApplication(Sequential sequence)
Add an application.
voidaddBlock(BlockFor sequence)
Add a block.
voidaddReporting(Sequential sequence)
set reporting sequence of tasks.
voidaddSetup(Sequential sequence)
Add a setup sequence.
voidaddTeardown(Sequential sequence)
set teardown sequence of tasks.
voidaddTests(Sequential sequence)
add tests.
ConditionBasecreateCondition()
Add a condition element.
voidexecute()
Run the functional test sequence.
BuildExceptiongetApplicationException()
Get the application exception.
BuildExceptiongetTaskException()
Get the task exception.
BuildExceptiongetTeardownException()
Get the teardown exception.
BuildExceptiongetTestException()
Get the test exception.
protected voidignoringThrowable(String type, Throwable thrown)
log that we are ignoring something rather than rethrowing it.
protected voidprocessExceptions()
Now faults are analysed.
voidsetFailOnTeardownErrors(boolean failOnTeardownErrors)
Set the failOnTeardownErrors attribute.
voidsetFailureMessage(String failureMessage)
Set the failureMessage attribute.
voidsetFailureProperty(String failureProperty)
Set the failureProperty attribute.
voidsetShutdownTime(long shutdownTime)
Set the shutdownTime attribute.
voidsetShutdownUnit(WaitFor.Unit unit)
Set the shutdownunit attribute.
voidsetTimeout(long timeout)
Set the timeout attribute.
voidsetTimeoutUnit(WaitFor.Unit unit)
Set the timeoutunit attribute.

Field Detail

APPLICATION_EXCEPTION

public static final String APPLICATION_EXCEPTION
Application exception : {@value }

APPLICATION_FORCIBLY_SHUT_DOWN

public static final String APPLICATION_FORCIBLY_SHUT_DOWN
{@value }

SHUTDOWN_INTERRUPTED

public static final String SHUTDOWN_INTERRUPTED
{@value }

SKIPPING_TESTS

public static final String SKIPPING_TESTS
{@value }

TEARDOWN_EXCEPTION

public static final String TEARDOWN_EXCEPTION
Teardown exception : {@value }

WARN_OVERRIDING

public static final String WARN_OVERRIDING
{@value }

Method Detail

addApplication

public void addApplication(Sequential sequence)
Add an application.

Parameters: sequence the application to add.

addBlock

public void addBlock(BlockFor sequence)
Add a block.

Parameters: sequence the block for to add.

addReporting

public void addReporting(Sequential sequence)
set reporting sequence of tasks.

Parameters: sequence a reporting sequence to use.

addSetup

public void addSetup(Sequential sequence)
Add a setup sequence.

Parameters: sequence the setup sequence to add.

addTeardown

public void addTeardown(Sequential sequence)
set teardown sequence of tasks.

Parameters: sequence a teardown sequence to use.

addTests

public void addTests(Sequential sequence)
add tests.

Parameters: sequence a sequence to add.

createCondition

public ConditionBase createCondition()
Add a condition element.

Returns: ConditionBase.

Since: Ant 1.6.2

execute

public void execute()
Run the functional test sequence.

This is a fairly complex workflow -what is going on is that we try to clean up no matter how the run ended, and to retain the innermost exception that got thrown during cleanup. That is, if teardown fails after the tests themselves failed, it is the test failing that is more important.

Throws: BuildException if something was caught during the run or teardown.

getApplicationException

public BuildException getApplicationException()
Get the application exception.

Returns: the application exception.

getTaskException

public BuildException getTaskException()
Get the task exception.

Returns: the task exception.

getTeardownException

public BuildException getTeardownException()
Get the teardown exception.

Returns: the teardown exception.

getTestException

public BuildException getTestException()
Get the test exception.

Returns: the test exception.

ignoringThrowable

protected void ignoringThrowable(String type, Throwable thrown)
log that we are ignoring something rather than rethrowing it.

Parameters: type name of exception thrown what was thrown

processExceptions

protected void processExceptions()
Now faults are analysed.

The priority is

  1. testexceptions, except those indicating a build timeout when the application itself failed.
    (because often it is the application fault that is more interesting than the probe failure, which is usually triggered by the application not starting
  2. Application exceptions (above test timeout exceptions)
  3. Teardown exceptions -except when they are being ignored
  4. Test failures as indicated by the failure property

setFailOnTeardownErrors

public void setFailOnTeardownErrors(boolean failOnTeardownErrors)
Set the failOnTeardownErrors attribute.

Parameters: failOnTeardownErrors the value to use.

setFailureMessage

public void setFailureMessage(String failureMessage)
Set the failureMessage attribute.

Parameters: failureMessage the value to use.

setFailureProperty

public void setFailureProperty(String failureProperty)
Set the failureProperty attribute.

Parameters: failureProperty the value to use.

setShutdownTime

public void setShutdownTime(long shutdownTime)
Set the shutdownTime attribute.

Parameters: shutdownTime the value to use.

setShutdownUnit

public void setShutdownUnit(WaitFor.Unit unit)
Set the shutdownunit attribute.

Parameters: unit the value to use.

setTimeout

public void setTimeout(long timeout)
Set the timeout attribute.

Parameters: timeout the value to use.

setTimeoutUnit

public void setTimeoutUnit(WaitFor.Unit unit)
Set the timeoutunit attribute.

Parameters: unit the value to use.