Package groovy.test
Class AllTestSuite
java.lang.Object
junit.framework.TestSuite
groovy.test.AllTestSuite
- All Implemented Interfaces:
junit.framework.Test
public class AllTestSuite
extends junit.framework.TestSuite
AllTestSuite can be used in extension of GroovyTestSuite to execute TestCases written in Groovy
from inside a Java IDE.
AllTestSuite collects all files below a given directory that comply to a given pattern.
From these files, a TestSuite is constructed that can be run via an IDE graphical Test runner.
The files are assumed to be Groovy source files and be either a TestCase or a Script that can
be wrapped transparently into a TestCase.
The directory and the pattern can be set via System properties (see this classes' constants for details.)
When setting the log level of this class to FINEST, all file loading will be logged.
See also groovy.test.AllTestSuiteTest.groovy
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe System Property to set as base directory for collection of Test Cases.static final StringThe System Property to set as a filename excludes pattern for collection of Test Cases.static final StringThe System Property to set as the filename pattern for collection of Test Cases. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ClassCompiles the supplied Groovy source file into a class.protected voidCompiles the supplied source file and adds the resulting test to this suite.static junit.framework.Testsuite()Creates a suite using the configured system-property defaults.static junit.framework.TestCreates a suite for tests matching the supplied include pattern.static junit.framework.TestCreates a suite for tests matching the supplied include and exclude patterns.Methods inherited from class junit.framework.TestSuite
addTest, addTestSuite, countTestCases, createTest, getName, getTestConstructor, run, runTest, setName, testAt, testCount, tests, toString, warning
-
Field Details
-
SYSPROP_TEST_DIR
The System Property to set as base directory for collection of Test Cases. The pattern will be used as an Ant fileset include basedir. Key is "groovy.test.dir". Default value is "./test/".- See Also:
-
SYSPROP_TEST_PATTERN
The System Property to set as the filename pattern for collection of Test Cases. The pattern will be used as Regular Expression pattern applied with the find operator against each candidate file.path. Key is "groovy.test.pattern". Default value is "Test.groovy".- See Also:
-
SYSPROP_TEST_EXCLUDES_PATTERN
The System Property to set as a filename excludes pattern for collection of Test Cases. When non-empty, the pattern will be used as Regular Expression pattern applied with the find operator against each candidate file.path. Key is "groovy.test.excludesPattern". Default value is "".- See Also:
-
-
Constructor Details
-
AllTestSuite
public AllTestSuite()
-
-
Method Details
-
suite
public static junit.framework.Test suite()Creates a suite using the configured system-property defaults.- Returns:
- the populated test suite
-
suite
Creates a suite for tests matching the supplied include pattern.- Parameters:
basedir- the base directory to searchpattern- the include pattern used to find test sources- Returns:
- the populated test suite
-
suite
Creates a suite for tests matching the supplied include and exclude patterns.- Parameters:
basedir- the base directory to searchpattern- the include pattern used to find test sourcesexcludesPattern- the exclude pattern used to filter matching sources- Returns:
- the populated test suite
-
loadTest
Compiles the supplied source file and adds the resulting test to this suite.- Parameters:
filename- the Groovy source file to compile- Throws:
CompilationFailedException- if compilation failsIOException- if the source cannot be read
-
compile
Compiles the supplied Groovy source file into a class.- Parameters:
filename- the Groovy source file to compile- Returns:
- the compiled class
- Throws:
CompilationFailedException- if compilation failsIOException- if the source cannot be read
-