org.apache.tools.ant.taskdefs.optional.junit

Class FormatterElement

public class FormatterElement extends Object

A wrapper for the implementations of JUnitResultFormatter. In particular, used as a nested <formatter> element in a <junit> task.

For example,

       <junit printsummary="no" haltonfailure="yes" fork="false">
           <formatter type="plain" usefile="false" />
           <test name="org.apache.ecs.InternationalCharTest" />
       </junit>
adds a plain type implementation (PlainJUnitResultFormatter) to display the results of the test.

Either the type or the classname attribute must be set.

See Also: JUnitTask XMLJUnitResultFormatter BriefJUnitResultFormatter PlainJUnitResultFormatter FailureRecorder JUnitResultFormatter

Nested Class Summary
static classFormatterElement.TypeAttribute

Enumerated attribute with the values "plain", "xml", "brief" and "failure".

Field Summary
static StringBRIEF_FORMATTER_CLASS_NAME
brief formatter class
static StringFAILURE_RECORDER_CLASS_NAME
failure recorder class
static StringPLAIN_FORMATTER_CLASS_NAME
plain formatter class
static StringXML_FORMATTER_CLASS_NAME
xml formatter class
Method Summary
StringgetClassname()
Get name of class to be used as the formatter.
StringgetExtension()
Get the extension used for the report file.
voidsetClassname(String classname)

Set name of class to be used as the formatter.

voidsetExtension(String ext)
Set the extension to use for the report file.
voidsetIf(Object ifCond)
Set whether this formatter should be used.
voidsetIf(String ifCond)
Set whether this formatter should be used.
voidsetOutput(OutputStream out)

Set output stream for formatter to use.

voidsetProject(Project project)
Store the project reference for passing it to nested components.
voidsetType(FormatterElement.TypeAttribute type)

Quick way to use a standard formatter.

voidsetUnless(Object unlessCond)
Set whether this formatter should NOT be used.
voidsetUnless(String unlessCond)
Set whether this formatter should NOT be used.
voidsetUseFile(boolean useFile)
Set whether the formatter should log to file.
booleanshouldUse(Task t)
Ensures that the selector passes the conditions placed on it with if and unless properties.

Field Detail

BRIEF_FORMATTER_CLASS_NAME

public static final String BRIEF_FORMATTER_CLASS_NAME
brief formatter class

FAILURE_RECORDER_CLASS_NAME

public static final String FAILURE_RECORDER_CLASS_NAME
failure recorder class

PLAIN_FORMATTER_CLASS_NAME

public static final String PLAIN_FORMATTER_CLASS_NAME
plain formatter class

XML_FORMATTER_CLASS_NAME

public static final String XML_FORMATTER_CLASS_NAME
xml formatter class

Method Detail

getClassname

public String getClassname()
Get name of class to be used as the formatter.

Returns: the name of the class.

getExtension

public String getExtension()
Get the extension used for the report file.

Returns: the extension.

setClassname

public void setClassname(String classname)

Set name of class to be used as the formatter.

This class must implement JUnitResultFormatter

Parameters: classname the name of the formatter class.

setExtension

public void setExtension(String ext)
Set the extension to use for the report file.

Parameters: ext the extension to use.

setIf

public void setIf(Object ifCond)
Set whether this formatter should be used. It will be used if the expression evaluates to true or the name of a property which has been set, otherwise it won't.

Parameters: ifCond name of property

Since: Ant 1.8.0

setIf

public void setIf(String ifCond)
Set whether this formatter should be used. It will be used if the expression evaluates to true or the name of a property which has been set, otherwise it won't.

Parameters: ifCond name of property

setOutput

public void setOutput(OutputStream out)

Set output stream for formatter to use.

Defaults to standard out.

Parameters: out the output stream to use.

setProject

public void setProject(Project project)
Store the project reference for passing it to nested components.

Parameters: project the reference

Since: Ant 1.8

setType

public void setType(FormatterElement.TypeAttribute type)

Quick way to use a standard formatter.

At the moment, there are three supported standard formatters.

Sets classname attribute - so you can't use that attribute if you use this one.

Parameters: type the enumerated value to use.

setUnless

public void setUnless(Object unlessCond)
Set whether this formatter should NOT be used. It will be used if the expression evaluates to false or the name of a property which has not been set, orthwise it will not be used.

Parameters: unlessCond name of property

Since: Ant 1.8.0

setUnless

public void setUnless(String unlessCond)
Set whether this formatter should NOT be used. It will be used if the expression evaluates to false or the name of a property which has not been set, orthwise it will not be used.

Parameters: unlessCond name of property

setUseFile

public void setUseFile(boolean useFile)
Set whether the formatter should log to file.

Parameters: useFile if true use a file, if false send to standard out.

shouldUse

public boolean shouldUse(Task t)
Ensures that the selector passes the conditions placed on it with if and unless properties.

Parameters: t the task the this formatter is used in.

Returns: true if the formatter should be used.