FormatterElement (Apache Ant API)
Keywords: org.apache.tools.ant.taskdefs.optional.junit.FormatterElement class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tools.ant.taskdefs.optional.junit
Class FormatterElement

    java.lang.Object
      org.apache.tools.ant.taskdefs.optional.junit.FormatterElement

    public class FormatterElement

extends java.lang.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 class` | `FormatterElement.TypeAttribute` Enumerated attribute with the values "plain", "xml", "brief" and "failure".

Field Summary
`static java.lang.String` | `BRIEF_FORMATTER_CLASS_NAME` brief formatter class
`static java.lang.String` | `FAILURE_RECORDER_CLASS_NAME` failure recorder class
`static java.lang.String` | `PLAIN_FORMATTER_CLASS_NAME` plain formatter class
`static java.lang.String` | `XML_FORMATTER_CLASS_NAME` xml formatter class

Constructor Summary
`FormatterElement()`

Method Summary
`java.lang.String` | `getClassname()` Get name of class to be used as the formatter.
`java.lang.String` | `getExtension()` Get the extension used for the report file.
`void` | `setClassname(java.lang.String classname)` Set name of class to be used as the formatter.
`void` | `setExtension(java.lang.String ext)` Set the extension to use for the report file.
`void` | `setIf(java.lang.Object ifCond)` Set whether this formatter should be used.
`void` | `setIf(java.lang.String ifCond)` Set whether this formatter should be used.
`void` | `setOutput(java.io.OutputStream out)` Set output stream for formatter to use.
`void` | `setProject(Project project)` Store the project reference for passing it to nested components.
`void` | `setType(FormatterElement.TypeAttribute type)` Quick way to use a standard formatter.
`void` | `setUnless(java.lang.Object unlessCond)` Set whether this formatter should NOT be used.
`void` | `setUnless(java.lang.String unlessCond)` Set whether this formatter should NOT be used.
`void` | `setUseFile(boolean useFile)` Set whether the formatter should log to file.
`boolean` | `shouldUse(Task t)` Ensures that the selector passes the conditions placed on it with `if` and `unless` properties.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### XML_FORMATTER_CLASS_NAME

    public static final java.lang.String XML_FORMATTER_CLASS_NAME

  xml formatter class

  See Also:
    Constant Field Values

### BRIEF_FORMATTER_CLASS_NAME

    public static final java.lang.String BRIEF_FORMATTER_CLASS_NAME

  brief formatter class

  See Also:
    Constant Field Values

### PLAIN_FORMATTER_CLASS_NAME

    public static final java.lang.String PLAIN_FORMATTER_CLASS_NAME

  plain formatter class

  See Also:
    Constant Field Values

### FAILURE_RECORDER_CLASS_NAME

    public static final java.lang.String FAILURE_RECORDER_CLASS_NAME

  failure recorder class

  See Also:
    Constant Field Values

Constructor Detail

### FormatterElement

    public FormatterElement()

Method Detail

### setType

    public void setType(FormatterElement.TypeAttribute type)

  Quick way to use a standard formatter.

  At the moment, there are three supported standard formatters.

  - The `xml` type uses a `XMLJUnitResultFormatter`.
  - The `brief` type uses a `BriefJUnitResultFormatter`.
  - The `plain` type (the default) uses a `PlainJUnitResultFormatter`.
  - The `failure` type uses a `FailureRecorder`.

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

  Parameters:
    `type` - the enumerated value to use.

### setClassname

    public void setClassname(java.lang.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.

### getClassname

    public java.lang.String getClassname()

  Get name of class to be used as the formatter.

  Returns:
    the name of the class.

### setExtension

    public void setExtension(java.lang.String ext)

  Set the extension to use for the report file.

  Parameters:
    `ext` - the extension to use.

### getExtension

    public java.lang.String getExtension()

  Get the extension used for the report file.

  Returns:
    the extension.

### setOutput

    public void setOutput(java.io.OutputStream out)

  Set output stream for formatter to use.

  Defaults to standard out.

  Parameters:
    `out` - the output stream to use.

### 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.

### setIf

    public void setIf(java.lang.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(java.lang.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

### setUnless

    public void setUnless(java.lang.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(java.lang.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

### 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.

### setProject

    public void setProject(Project project)

  Store the project reference for passing it to nested components.

  Parameters:
    `project` - the reference
  Since:
    Ant 1.8

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD