Package gw.test
Class Suite<T extends Suite>
java.lang.Object
junit.framework.TestSuite
gw.test.Suite<T>
- All Implemented Interfaces:
junit.framework.Test
public class Suite<T extends Suite>
extends junit.framework.TestSuite
This Suite class streamlines and simplifies the standard JUnit TestSuite. It can be used in one of two ways:
you can add individual tests to the Suite via the withTest() methods, or you can use the filter methods to
pare down the tests that are found on the current classpath.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate TestExecutionManager
private final List<IDirectory>
private final List<IDirectory>
private boolean
private int
private int
private boolean
private boolean
private TestEnvironment
static final String
static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
final int
protected List<IDirectory>
protected List<IDirectory>
private TestEnvironment
private void
private void
boolean
final T
Used to indicate that this suite does not require assertions be enabled.void
final T
private void
private void
private Integer
private void
This is for troubleshooting suite failures by running a subset of tests within a suite without requiring any Java or Gosu code changesprivate void
final org.junit.runner.Result
run()
Runs this Suite with a TextListener tied to System.out and returns the result.void
run
(junit.framework.TestResult result) private org.junit.runner.Result
runImpl
(junit.framework.Test test) final boolean
A convenience method for running this suite from a main method.final junit.framework.Test
testAt
(int index) final int
final Enumeration<junit.framework.Test>
tests()
List<junit.framework.Test>
List<junit.framework.TestSuite>
private T
thisAsT()
Private method that casts the this value as a T to avoid unchecked cast errors all over the placeprivate void
withClasspathEntry
(File srcDir) final T
withIFileFilter
(Predicate<IFile> fileFilter) Adds a file filter to this suite, allowing certain tests to be excluded.final T
withModules
(String... moduleNames) This limits the gosu tests that are run to gosu tests that are located within the specified module in a gsrc or gtest directory AND all and java tests in the classpath that are not in a module.final T
withPackageFilter
(Predicate<String> fileFilter) Adds a package filter to this suite, which allows you to exclude certain packages from consideration.final T
withPackages
(String... packagePrefixes) Adds a package filter that will only accept packages that are subpackages of the strings passed in.final T
Adds a test to this Suite.final T
Adds a test to this Suite.final T
Adds a test to this Suite.withTestEnvironment
(TestEnvironment testEnvironment) final T
withTestTypeFilter
(Predicate<IType> filter) Adds a type filter to this suite, allowing certain tests to be excluded.final T
withTimeout
(long seconds) Methods inherited from class junit.framework.TestSuite
addTest, addTestSuite, createTest, getName, getTestConstructor, runTest, setName, toString, warning
-
Field Details
-
_testClassWrappersCreated
private boolean _testClassWrappersCreated -
_suiteHasBeenSetUp
private boolean _suiteHasBeenSetUp -
_typeFilters
-
_iFileFilters
-
_packageFilters
-
_withPackages
-
_testSpecs
-
_gosuClassSearchPath
-
_javaClassSearchPath
-
_modules
-
_logErrorInfo
private boolean _logErrorInfo -
_splitNum
private int _splitNum -
_splitPartition
private int _splitPartition -
_executionManager
-
_testEnvironment
-
GOSU_SUITE_INCLUDE_TYPES
- See Also:
-
SPLIT_PARTITION
- See Also:
-
-
Constructor Details
-
Suite
public Suite()
-
-
Method Details
-
getTestEnvironment
-
javaAssertionsNotEnabled
Used to indicate that this suite does not require assertions be enabled. In general it is recommended that you not use this option. -
withTest
Adds a test to this Suite. This method is not to be combined with the module/filter methods. -
withTest
Adds a test to this Suite. This method is not to be combined with the module/filter methods. -
withTest
Adds a test to this Suite. This method is not to be combined with the module/filter methods. -
verifyNoFilters
private void verifyNoFilters() -
withTestTypeFilter
Adds a type filter to this suite, allowing certain tests to be excluded. Note that this is a significantly slower option thanwithIFileFilter(gw.util.Predicate)
orwithPackageFilter(gw.util.Predicate)
If possible, it is advisable to use a file filter instead. -
withIFileFilter
Adds a file filter to this suite, allowing certain tests to be excluded. Consider usingwithPackageFilter(gw.util.Predicate)
if you wish to more easily apply a package filter of tests without dealing with ugly file paths. Package filters are just as fast as file filters, both of which are much faster than test type filters. -
withPackages
Adds a package filter that will only accept packages that are subpackages of the strings passed in. -
ensureNoExplictlyAddedTests
private void ensureNoExplictlyAddedTests() -
withPackageFilter
Adds a package filter to this suite, which allows you to exclude certain packages from consideration. These filters are about as fast as file filters, but are easier to write and maintain. For the common case of simply wishing to test certain packages and their sub-packages, usewithPackages(String...)
instead. -
withTimeout
-
withTestEnvironment
-
logErrors
-
withModules
This limits the gosu tests that are run to gosu tests that are located within the specified module in a gsrc or gtest directory AND all and java tests in the classpath that are not in a module.- Parameters:
moduleNames
-- Returns:
-
withClasspathEntry
-
countTestCases
public final int countTestCases()- Specified by:
countTestCases
in interfacejunit.framework.Test
- Overrides:
countTestCases
in classjunit.framework.TestSuite
-
testAt
public final junit.framework.Test testAt(int index) - Overrides:
testAt
in classjunit.framework.TestSuite
-
testCount
public final int testCount()- Overrides:
testCount
in classjunit.framework.TestSuite
-
tests
- Overrides:
tests
in classjunit.framework.TestSuite
-
maybeCreateTestClassWrappers
private void maybeCreateTestClassWrappers() -
determineTestEnvironmentBasedOnTestDefaults
-
maybeInitSuite
private void maybeInitSuite() -
createDefaultGosuClassSearchPath
-
createDefaultJavaClassSearchPath
-
initTypeSystem
private void initTypeSystem() -
logError
-
run
public void run(junit.framework.TestResult result) - Specified by:
run
in interfacejunit.framework.Test
- Overrides:
run
in classjunit.framework.TestSuite
-
beforeSuite
protected void beforeSuite() -
runViaStaticSuiteMethod
public final boolean runViaStaticSuiteMethod()A convenience method for running this suite from a main method. Subclasses of Suite can create a main method like so:public static void main(String[] args) { System.exit( new GosuSuite().runSuite() ? 0 : 1 ); }
- Returns:
- a boolean saying if all tests passed
-
runImpl
private org.junit.runner.Result runImpl(junit.framework.Test test) -
run
public final org.junit.runner.Result run()Runs this Suite with a TextListener tied to System.out and returns the result. -
testsAsList
-
testsAsListOfSuites
-
isLoggingErrors
public boolean isLoggingErrors() -
thisAsT
Private method that casts the this value as a T to avoid unchecked cast errors all over the place- Returns:
- this
-
readIntegerSystemProperty
-
restrictTestSpecsToSpecifiedPartition
private void restrictTestSpecsToSpecifiedPartition() -
restrictTestSpecsToSpecifiedNames
private void restrictTestSpecsToSpecifiedNames()This is for troubleshooting suite failures by running a subset of tests within a suite without requiring any Java or Gosu code changes
-