Class JUnitTest
java.lang.Object
org.apache.tools.ant.taskdefs.optional.junit.BaseTest
org.apache.tools.ant.taskdefs.optional.junit.JUnitTest
- All Implemented Interfaces:
- Cloneable
Run a single JUnit test.
 
The JUnit test is actually run by JUnitTestRunner.
 So read the doc comments for that class :)
- Since:
- Ant 1.2
- See Also:
- 
Field SummaryFields inherited from class org.apache.tools.ant.taskdefs.optional.junit.BaseTestdestDir, errorProperty, failureProperty, filtertrace, fork, formatters, haltOnError, haltOnFail, ifProperty, unlessProperty
- 
Constructor SummaryConstructorsConstructorDescriptionNo arg constructor.Constructor with name.Constructor with options.JUnitTest(String name, boolean haltOnError, boolean haltOnFailure, boolean filtertrace, String[] methods) Constructor with options.JUnitTest(String name, boolean haltOnError, boolean haltOnFailure, boolean filtertrace, String[] methods, int thread) Constructor with options.
- 
Method SummaryModifier and TypeMethodDescriptionclone()longGet the number of errors.longGet the number of failures.Get the formatters set for this test.getName()Get the name of the test class.Get the name of the output fileGet the properties used in the test.longGet the run time.intGet the Ant id of the thread running the test.static String[]parseTestMethodNamesList(String methodNames) Parses a comma-separated list of method names and check their validity.longrunCount()Get the number of runs.voidsetCounts(long runs, long failures, long errors) Set the number of runs, failures, errors, and skipped tests.voidsetCounts(long runs, long failures, long errors, long skips) Set the number of runs, failures, errors, and skipped tests.voidsetMethods(String value) Sets names of individual test methods to be executed.voidSet the name of the test class.voidsetOutfile(String value) Set the name of the output file.voidsetProperties(Hashtable<?, ?> p) Set the properties to be used in the test.voidsetRunTime(long runTime) Set the runtime.voidsetThread(int thread) Set the thread idbooleanCheck if this test should run based on the if and unless attributes.longGet the number of skipped tests.Methods inherited from class org.apache.tools.ant.taskdefs.optional.junit.BaseTestaddFormatter, getErrorProperty, getFailureProperty, getFiltertrace, getFork, getHaltonerror, getHaltonfailure, getIfCondition, getTodir, getUnlessCondition, isSkipNonTests, setErrorProperty, setFailureProperty, setFiltertrace, setFork, setHaltonerror, setHaltonfailure, setIf, setIf, setSkipNonTests, setTodir, setUnless, setUnless
- 
Constructor Details- 
JUnitTestpublic JUnitTest()No arg constructor.
- 
JUnitTestConstructor with name.- Parameters:
- name- the name of the test.
 
- 
JUnitTestConstructor with options.- Parameters:
- name- the name of the test.
- haltOnError- if true halt the tests if there is an error.
- haltOnFailure- if true halt the tests if there is a failure.
- filtertrace- if true filter stack traces.
 
- 
JUnitTestpublic JUnitTest(String name, boolean haltOnError, boolean haltOnFailure, boolean filtertrace, String[] methods) Constructor with options.- Parameters:
- name- the name of the test.
- haltOnError- if true halt the tests if there is an error.
- haltOnFailure- if true halt the tests if there is a failure.
- filtertrace- if true filter stack traces.
- methods- if non-null run only these test methods
- Since:
- 1.8.2
 
- 
JUnitTestpublic JUnitTest(String name, boolean haltOnError, boolean haltOnFailure, boolean filtertrace, String[] methods, int thread) Constructor with options.- Parameters:
- name- the name of the test.
- haltOnError- if true halt the tests if there is an error.
- haltOnFailure- if true halt the tests if there is a failure.
- filtertrace- if true filter stack traces.
- methods- if non-null run only these test methods
- thread- Ant thread ID in which test is currently running
- Since:
- 1.9.4
 
 
- 
- 
Method Details- 
setMethodsSets names of individual test methods to be executed.- Parameters:
- value- comma-separated list of names of individual test methods to be executed, or- nullif all test methods should be executed
- Since:
- 1.8.2
 
- 
setNameSet the name of the test class.- Parameters:
- value- the name to use.
 
- 
setThreadpublic void setThread(int thread) Set the thread id- Parameters:
- thread- the Ant id of the thread running this test (this is not the system process or thread id) (this will be 0 in single-threaded mode).
- Since:
- Ant 1.9.4
 
- 
setOutfileSet the name of the output file.- Parameters:
- value- the name of the output file to use.
 
- 
parseTestMethodNamesListParses a comma-separated list of method names and check their validity.- Parameters:
- methodNames- comma-separated list of method names to be parsed
- Returns:
- array of individual test method names
- Throws:
- IllegalArgumentException- if the given string is- nullor if it is not a comma-separated list of valid Java identifiers; an empty string is acceptable and is handled as an empty list
- Since:
- 1.8.2
 
- 
getNameGet the name of the test class.- Returns:
- the name of the test.
 
- 
getThreadpublic int getThread()Get the Ant id of the thread running the test.- Returns:
- the thread id
 
- 
getOutfileGet the name of the output file- Returns:
- the name of the output file.
 
- 
setCountspublic void setCounts(long runs, long failures, long errors) Set the number of runs, failures, errors, and skipped tests.- Parameters:
- runs- the number of runs.
- failures- the number of failures.
- errors- the number of errors. Kept for backward compatibility with Ant 1.8.4
 
- 
setCountspublic void setCounts(long runs, long failures, long errors, long skips) Set the number of runs, failures, errors, and skipped tests.- Parameters:
- runs- the number of runs.
- failures- the number of failures.
- errors- the number of errors.
- skips- the number of skipped tests.
- Since:
- Ant 1.9.0
 
- 
setRunTimepublic void setRunTime(long runTime) Set the runtime.- Parameters:
- runTime- the time in milliseconds.
 
- 
runCountpublic long runCount()Get the number of runs.- Returns:
- the number of runs.
 
- 
failureCountpublic long failureCount()Get the number of failures.- Returns:
- the number of failures.
 
- 
errorCountpublic long errorCount()Get the number of errors.- Returns:
- the number of errors.
 
- 
skipCountpublic long skipCount()Get the number of skipped tests.- Returns:
- the number of skipped tests.
 
- 
getRunTimepublic long getRunTime()Get the run time.- Returns:
- the run time in milliseconds.
 
- 
getPropertiesGet the properties used in the test.- Returns:
- the properties.
 
- 
setPropertiesSet the properties to be used in the test.- Parameters:
- p- the properties. This is a copy of the projects ant properties.
 
- 
shouldRunCheck if this test should run based on the if and unless attributes.- Parameters:
- p- the project to use to check if the if and unless properties exist in.
- Returns:
- true if this test or testsuite should be run.
 
- 
getFormattersGet the formatters set for this test.- Returns:
- the formatters as an array.
 
- 
clone
 
-