|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | PROPERTY | CONSTR | METHOD | DETAIL: FIELD | PROPERTY | CONSTR | METHOD |
java.lang.Object org.codehaus.groovy.grails.test.support.GrailsTestTypeSupport
abstract class GrailsTestTypeSupport
Provides a convenient base for GrailsTestType implementations.
Property Summary | |
---|---|
groovy.lang.Binding |
buildBinding
The binding from the build environment |
java.io.File |
compiledClassesDir
The location where the type's source was compiled to |
java.lang.String |
name
The name of this test type |
java.lang.String |
relativeSourcePath
The path to this type's source, relative to the root of all test source |
GrailsTestTargetPattern |
testTargetPatterns
The test target patterns that should be used to filter the tests to run |
Constructor Summary | |
GrailsTestTypeSupport(java.lang.String name, java.lang.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 GrailsTestTypeResult
|
doRun(GrailsTestEventPublisher eventPublisher)
Performs the tests, and appropriately calls GrailsTestEventPublisher to communicate the status. |
protected void
|
eachSourceFile(groovy.lang.Closure body)
Calls body with the GrailsTestTargetPattern that matched the source, and the File for the source. |
protected java.util.List
|
findSourceFiles(GrailsTestTargetPattern targetPattern)
Finds source based on the testSuffixes and testExtensions that match the targetPattern. |
protected ApplicationContext
|
getApplicationContext()
Will return the application context if it is present, but will throw an IllegalStateException if it is not. |
protected java.io.File
|
getSourceDir()
The location of this type's source |
protected java.lang.ClassLoader
|
getTestClassLoader()
A class loader with class path additions of this type's source dir and compile classed dir. |
protected java.util.List
|
getTestExtensions()
Override to have the tests for this type require a certain file extension |
protected java.util.List
|
getTestSuffixes()
Override to have the tests for this type require a certain suffix |
protected java.lang.Class
|
loadClass(java.lang.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(GrailsTestTargetPattern[] testTargetPatterns, java.io.File compiledClassesDir, groovy.lang.Binding buildBinding)
Sets the appropriate instance variables from the parameters, and calls doPrepare() |
GrailsTestTypeResult
|
run(GrailsTestEventPublisher eventPublisher)
Sets the current thread's contextClassLoader to the test class loader, calls doRun(GrailsTestEventPublisher) and then restores the original contextClassLoader. |
protected java.lang.Class
|
sourceFileToClass(java.io.File sourceFile)
Convenience method for obtaining the class file for a test class |
protected java.io.File
|
sourceFileToClassFile(java.io.File sourceFile)
Convenience method for obtaining the class file for a test class |
protected java.lang.String
|
sourceFileToClassName(java.io.File sourceFile)
Gets the corresponding class name for a source file of this test type. |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Property Detail |
---|
groovy.lang.Binding buildBinding
java.io.File compiledClassesDir
final java.lang.String name
final java.lang.String relativeSourcePath
GrailsTestTargetPattern testTargetPatterns
Constructor Detail |
---|
GrailsTestTypeSupport(java.lang.String name, java.lang.String relativeSourcePath)
Method Detail |
---|
void cleanup()
protected SystemOutAndErrSwapper createSystemOutAndErrSwapper()
protected int doPrepare()
protected GrailsTestTypeResult doRun(GrailsTestEventPublisher eventPublisher)
protected void eachSourceFile(groovy.lang.Closure body)
protected java.util.List findSourceFiles(GrailsTestTargetPattern targetPattern)
protected ApplicationContext getApplicationContext()
protected java.io.File getSourceDir()
protected java.lang.ClassLoader getTestClassLoader()
protected java.util.List getTestExtensions()
protected java.util.List getTestSuffixes()
protected java.lang.Class loadClass(java.lang.String className)
int prepare(GrailsTestTargetPattern[] testTargetPatterns, java.io.File compiledClassesDir, groovy.lang.Binding buildBinding)
GrailsTestTypeResult run(GrailsTestEventPublisher eventPublisher)
protected java.lang.Class sourceFileToClass(java.io.File sourceFile)
protected java.io.File sourceFileToClassFile(java.io.File sourceFile)
protected java.lang.String sourceFileToClassName(java.io.File sourceFile)
Groovy Documentation