FileDocCategorySizeDatePackage
JUnitTest.javaAPI DocApache Ant 1.706495Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.taskdefs.optional.junit

JUnitTest

public class JUnitTest extends BaseTest implements Cloneable

Run a single JUnit test.

The JUnit test is actually run by {@link JUnitTestRunner}. So read the doc comments for that class :)

since
Ant 1.2
see
JUnitTask
see
JUnitTestRunner

Fields Summary
private String
name
the name of the test case
private String
outfile
the name of the result file
private long
runs
private long
failures
private long
errors
private long
runTime
private Properties
props
Constructors Summary
public JUnitTest()
No arg constructor.


        
      
    
public JUnitTest(String name)
Constructor with name.

param
name the name of the test.

        this.name  = name;
    
public JUnitTest(String name, boolean haltOnError, boolean haltOnFailure, boolean filtertrace)
Constructor with options.

param
name the name of the test.
param
haltOnError if true halt the tests if there is an error.
param
haltOnFailure if true halt the tests if there is a failure.
param
filtertrace if true filter stack traces.

        this.name  = name;
        this.haltOnError = haltOnError;
        this.haltOnFail = haltOnFailure;
        this.filtertrace = filtertrace;
    
Methods Summary
voidaddFormattersTo(java.util.Vector v)
Convenient method to add formatters to a vector

        final int count = formatters.size();
        for (int i = 0; i < count; i++) {
            v.addElement(formatters.elementAt(i));
        }
    
public java.lang.Objectclone()

since
Ant 1.5
return
a clone of this test.

        try {
            JUnitTest t = (JUnitTest) super.clone();
            t.props = props == null ? null : (Properties) props.clone();
            t.formatters = (Vector) formatters.clone();
            return t;
        } catch (CloneNotSupportedException e) {
            // plain impossible
            return this;
        }
    
public longerrorCount()
Get the number of errors.

return
the number of errors.

        return errors;
    
public longfailureCount()
Get the number of failures.

return
the number of failures.

        return failures;
    
public FormatterElement[]getFormatters()
Get the formatters set for this test.

return
the formatters as an array.

        FormatterElement[] fes = new FormatterElement[formatters.size()];
        formatters.copyInto(fes);
        return fes;
    
public java.lang.StringgetName()
Get the name of the test class.

return
the name of the test.

        return name;
    
public java.lang.StringgetOutfile()
Get the name of the output file

return
the name of the output file.

        return outfile;
    
public java.util.PropertiesgetProperties()
Get the properties used in the test.

return
the properties.

        return props;
    
public longgetRunTime()
Get the run time.

return
the run time in milliseconds.

        return runTime;
    
public longrunCount()
Get the number of runs.

return
the number of runs.

        return runs;
    
public voidsetCounts(long runs, long failures, long errors)
Set the number of runs, failures and errors.

param
runs the number of runs.
param
failures the number of failures.
param
errors the number of errors.

        this.runs = runs;
        this.failures = failures;
        this.errors = errors;
    
public voidsetName(java.lang.String value)
Set the name of the test class.

param
value the name to use.

        name = value;
    
public voidsetOutfile(java.lang.String value)
Set the name of the output file.

param
value the name of the output file to use.

        outfile = value;
    
public voidsetProperties(java.util.Hashtable p)
Set the properties to be used in the test.

param
p the properties. This is a copy of the projects ant properties.

        props = new Properties();
        for (Enumeration e = p.keys(); e.hasMoreElements();) {
            Object key = e.nextElement();
            props.put(key, p.get(key));
        }
    
public voidsetRunTime(long runTime)
Set the runtime.

param
runTime the time in milliseconds.

        this.runTime = runTime;
    
public booleanshouldRun(org.apache.tools.ant.Project p)
Check if this test should run based on the if and unless attributes.

param
p the project to use to check if the if and unless properties exist in.
return
true if this test or testsuite should be run.

        if (ifProperty != null && p.getProperty(ifProperty) == null) {
            return false;
        } else if (unlessProperty != null
                    && p.getProperty(unlessProperty) != null) {
            return false;
        }

        return true;