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 JUnitResultFormatter

Nested Class Summary
static classFormatterElement.TypeAttribute

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

Field Summary
static StringBRIEF_FORMATTER_CLASS_NAME
static StringPLAIN_FORMATTER_CLASS_NAME
static StringXML_FORMATTER_CLASS_NAME
Method Summary
StringgetClassname()
Get name of class to be used as the formatter.
StringgetExtension()
voidsetClassname(String classname)

Set name of class to be used as the formatter.

voidsetExtension(String ext)
voidsetIf(String ifProperty)
Set whether this formatter should be used.
voidsetOutput(OutputStream out)

Set output stream for formatter to use.

voidsetType(FormatterElement.TypeAttribute type)

Quick way to use a standard formatter.

voidsetUnless(String unlessProperty)
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

PLAIN_FORMATTER_CLASS_NAME

public static final String PLAIN_FORMATTER_CLASS_NAME

XML_FORMATTER_CLASS_NAME

public static final String XML_FORMATTER_CLASS_NAME

Method Detail

getClassname

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

getExtension

public String getExtension()

setClassname

public void setClassname(String classname)

Set name of class to be used as the formatter.

This class must implement JUnitResultFormatter

setExtension

public void setExtension(String ext)

setIf

public void setIf(String ifProperty)
Set whether this formatter should be used. It will be used if the property has been set, otherwise it won't.

Parameters: ifProperty name of property

setOutput

public void setOutput(OutputStream out)

Set output stream for formatter to use.

Defaults to standard out.

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.

setUnless

public void setUnless(String unlessProperty)
Set whether this formatter should NOT be used. It will not be used if the property has been set, orthwise it will be used.

Parameters: unlessProperty name of property

setUseFile

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

shouldUse

public boolean shouldUse(Task t)
Ensures that the selector passes the conditions placed on it with if and unless properties.
Copyright B) 2000-2007 Apache Software Foundation. All Rights Reserved.