|
Griffon 1.2.0 | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | PROPERTY | CONSTR | METHOD | DETAIL: FIELD | PROPERTY | CONSTR | METHOD |
java.lang.Objectorg.codehaus.griffon.test.support.GriffonTestTypeSupport
abstract class GriffonTestTypeSupport
Provides a convenient base for GriffonTestType implementations.
Field Summary | |
---|---|
private File |
sourceDir
|
private ClassLoader |
testClassLoader
|
Property Summary | |
---|---|
Binding |
buildBinding
The binding from the build environment |
File |
compiledClassesDir
The location where the type's source was compiled to |
String |
name
The name of this test type |
String |
relativeSourcePath
The path to this type's source, relative to the root of all test source |
GriffonTestTargetPattern |
testTargetPatterns
The test target patterns that should be used to filter the tests to run |
Constructor Summary | |
GriffonTestTypeSupport(String name, String relativeSourcePath)
Sets the name and relativeSourcePath |
Method Summary | |
---|---|
void
|
cleanup()
Called after the tests have completed, regardless of success or not. |
protected SystemOutAndErrSwapper
|
createSystemOutAndErrSwapper()
Creates swapper with echo parameters based on testOptions.echoOut and testOptions.echoErr in the build binding. |
protected int
|
doPrepare()
Do any preparation and return the (approximate) number of tests that will be run. |
protected GriffonTestTypeResult
|
doRun(GriffonTestEventPublisher eventPublisher)
Performs the tests, and appropriately calls GriffonTestEventPublisher to communicate the status. |
protected void
|
eachSourceFile(Closure body)
Calls body with the GriffonTestTargetPattern that matched the source, and the File for the source. |
protected List
|
findSourceFiles(GriffonTestTargetPattern targetPattern)
Finds source based on the testSuffixes and testExtensions that match the targetPattern. |
protected GriffonApplication
|
getApplication()
Will return the application if it is present, but will throw an IllegalStateException if it is not. |
protected File
|
getSourceDir()
The location of this type's source |
protected ClassLoader
|
getTestClassLoader()
A class loader with class path additions of this type's source dir and compile classed dir. |
protected List
|
getTestExtensions()
Override to have the tests for this type require a certain file extension |
protected List
|
getTestSuffixes()
Override to have the tests for this type require a certain suffix |
protected Class
|
loadClass(String className)
Loods the class named by className using a class loader that can load the test classes, throwing a RuntimeException if the class can't be loaded. |
int
|
prepare(GriffonTestTargetPattern[] testTargetPatterns, File compiledClassesDir, Binding buildBinding)
Sets the appropriate instance variables from the parameters, and calls doPrepare() |
GriffonTestTypeResult
|
run(GriffonTestEventPublisher eventPublisher)
Sets the current thread's contextClassLoader to the test class loader, calls doRun(GriffonTestEventPublisher) and then restores the original contextClassLoader. |
protected Class
|
sourceFileToClass(File sourceFile)
Convenience method for obtaining the class file for a test class |
protected File
|
sourceFileToClassFile(File sourceFile)
Convenience method for obtaining the class file for a test class |
protected String
|
sourceFileToClassName(File sourceFile)
Gets the corresponding class name for a source file of this test type. |
Methods inherited from class Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Field Detail |
---|
private File sourceDir
private ClassLoader testClassLoader
Property Detail |
---|
Binding buildBinding
File compiledClassesDir
final String name
final String relativeSourcePath
GriffonTestTargetPattern testTargetPatterns
Constructor Detail |
---|
GriffonTestTypeSupport(String name, String relativeSourcePath)
Method Detail |
---|
void cleanup()
protected SystemOutAndErrSwapper createSystemOutAndErrSwapper()
protected int doPrepare()
protected GriffonTestTypeResult doRun(GriffonTestEventPublisher eventPublisher)
protected void eachSourceFile(Closure body)
protected List findSourceFiles(GriffonTestTargetPattern targetPattern)
protected GriffonApplication getApplication()
protected File getSourceDir()
protected ClassLoader getTestClassLoader()
protected List getTestExtensions()
protected List getTestSuffixes()
protected Class loadClass(String className)
int prepare(GriffonTestTargetPattern[] testTargetPatterns, File compiledClassesDir, Binding buildBinding)
GriffonTestTypeResult run(GriffonTestEventPublisher eventPublisher)
protected Class sourceFileToClass(File sourceFile)
protected File sourceFileToClassFile(File sourceFile)
protected String sourceFileToClassName(File sourceFile)
Groovy Documentation