Class Funtest
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.tools.ant.taskdefs.optional.testing.Funtest
- All Implemented Interfaces:
Cloneable
Task to provide functional testing under Ant, with a fairly complex workflow of:
- Conditional execution
- Application to start
- A probe to "waitfor" before running tests
- A tests sequence
- A reporting sequence that runs after the tests have finished
- A "teardown" clause that runs after the rest.
- Automated termination of the program it executes, if a timeout is not met
- Checking of a failure property and automatic raising of a fault (with the text in failureText) if test shutdown and reporting succeeded
- Since:
- Ant 1.8
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringApplication exception : "Application Exception"static final String"Application forcibly shut down"static final String"Shutdown interrupted"static final String"Condition failed -skipping tests"static final StringTeardown exception : "Teardown Exception"static final String"Overriding previous definition of "Fields inherited from class ProjectComponent
description, location, project -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddApplication(Sequential sequence) Add an application.voidAdd 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.Add a condition element.voidexecute()Run the functional test sequence.Get the application exception.Get the task exception.Get the teardown exception.Get the test exception.protected voidignoringThrowable(String type, Throwable thrown) log that we are ignoring something rather than rethrowing it.protected voidNow 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.Methods inherited from class Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskTypeModifier and TypeMethodDescriptionfinal voidbindToOwner(Task owner) Bind a task to another; use this when configuring a newly created task to do work on behalf of another.Returns the container target of this task.Returns the wrapper used for runtime configuration.Returns the name to use in logging messages.Return the type of task.protected RuntimeConfigurableReturn the runtime configurable structure for this task.protected voidhandleErrorFlush(String output) Handles an error line by logging it with the WARN priority.protected voidhandleErrorOutput(String output) Handles an error output by logging it with the WARN priority.protected voidhandleFlush(String output) Handles output by logging it with the INFO priority.protected inthandleInput(byte[] buffer, int offset, int length) Handle an input request by this task.protected voidhandleOutput(String output) Handles output by logging it with the INFO priority.voidinit()Called by the project to let the task initialize properly.protected final booleanHas this task been marked invalid?voidLogs a message with the default (INFO) priority.voidLogs a message with the given priority.voidLogs a message with the given priority.voidLogs a message with the given priority.voidConfigures this task - if it hasn't been done already.final voidperform()Performs this task if it's still valid, or gets a replacement version and performs that otherwise.voidForce the task to be reconfigured from its RuntimeConfigurable.voidsetOwningTarget(Target target) Sets the target container of this task.voidSets the wrapper to be used for runtime configuration.voidsetTaskName(String name) Sets the name to use in logging messages.voidsetTaskType(String type) Sets the name with which the task has been invoked.Methods inherited from class ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProjectModifier and TypeMethodDescriptionclone()Returns the description of the current action.Returns the file/location where this task was defined.Returns the project to which this component belongs.voidsetDescription(String desc) Sets a description of the current action.voidsetLocation(Location location) Sets the file/location where this task was defined.voidsetProject(Project project) Sets the project object of this component.
-
Field Details
-
WARN_OVERRIDING
-
APPLICATION_FORCIBLY_SHUT_DOWN
"Application forcibly shut down"- See Also:
-
SHUTDOWN_INTERRUPTED
-
SKIPPING_TESTS
-
APPLICATION_EXCEPTION
Application exception : "Application Exception"- See Also:
-
TEARDOWN_EXCEPTION
-
-
Constructor Details
-
Funtest
public Funtest()
-
-
Method Details
-
createCondition
Add a condition element.- Returns:
ConditionBase.- Since:
- Ant 1.6.2
-
addApplication
Add an application.- Parameters:
sequence- the application to add.
-
addSetup
Add a setup sequence.- Parameters:
sequence- the setup sequence to add.
-
addBlock
-
addTests
-
addReporting
set reporting sequence of tasks.- Parameters:
sequence- a reporting sequence to use.
-
addTeardown
set teardown sequence of tasks.- Parameters:
sequence- a teardown sequence to use.
-
setFailOnTeardownErrors
public void setFailOnTeardownErrors(boolean failOnTeardownErrors) Set the failOnTeardownErrors attribute.- Parameters:
failOnTeardownErrors- the value to use.
-
setFailureMessage
Set the failureMessage attribute.- Parameters:
failureMessage- the value to use.
-
setFailureProperty
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.
-
setTimeout
public void setTimeout(long timeout) Set the timeout attribute.- Parameters:
timeout- the value to use.
-
setTimeoutUnit
Set the timeoutunit attribute.- Parameters:
unit- the value to use.
-
setShutdownUnit
Set the shutdownunit attribute.- Parameters:
unit- the value to use.
-
getApplicationException
Get the application exception.- Returns:
- the application exception.
-
getTeardownException
Get the teardown exception.- Returns:
- the teardown exception.
-
getTestException
-
getTaskException
-
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.
- Overrides:
executein classTask- Throws:
BuildException- if something was caught during the run or teardown.
-
processExceptions
protected void processExceptions()Now faults are analysed.The priority is
- 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.)
- Application exceptions (above test timeout exceptions)
- Teardown exceptions -except when they are being ignored
- Test failures as indicated by the failure property
-
ignoringThrowable
-