|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | PROPERTY | CONSTR | METHOD | DETAIL: FIELD | PROPERTY | CONSTR | METHOD |
java.lang.Object junit.framework.Assert junit.framework.TestCase groovy.util.GroovyTestCase grails.test.GrailsUnitTestCase
class GrailsUnitTestCase extends groovy.util.GroovyTestCase
Support class for writing unit tests in Grails. It mainly provides access to various mocking options, while making sure that the meta- class magic does not leak outside of a single test.
Field Summary |
---|
Fields inherited from class groovy.util.GroovyTestCase | |
---|---|
TEST_SCRIPT_NAME_PREFIX |
Property Summary | |
---|---|
java.lang.Object |
applicationContext
|
DefaultArtefactInfo |
domainClassesInfo
Keeps track of the domain classes mocked within a single test so that the relationships can be configured for cascading validation. |
java.util.Map |
errorsMap
|
java.util.Set |
loadedCodecs
|
Method Summary | |
---|---|
protected void
|
addConverters(java.lang.Class clazz)
|
protected void
|
enableCascadingValidation()
Enables the cascading validation support for domain classes. |
protected void
|
loadCodec(java.lang.Class codecClass)
Loads the given codec, adding the "encodeAs...()" and "decode...()" methods to objects. |
protected groovy.util.ConfigObject
|
mockConfig(java.lang.String config)
|
protected void
|
mockController(java.lang.Class controllerClass)
Mocks a controller class, providing implementations of standard methods like render and redirect |
protected void
|
mockDomain(java.lang.Class domainClass, java.util.List instances = [])
Mocks a domain class, providing working implementations of the standard dynamic methods. |
protected GrailsMock
|
mockFor(java.lang.Class clazz, boolean loose = false)
Creates a new Grails mock for the given class. |
protected void
|
mockForConstraintsTests(java.lang.Class clazz, java.util.List instances = [])
Mocks the given class (either a domain class or a command object) so that a "validate()" method is added. |
protected void
|
mockLogging(java.lang.Class clazz, boolean enableDebug = false)
Provides a mock implementation of the "log" property for the given class. |
protected void
|
mockTagLib(java.lang.Class tagLibClass)
Mocks a tag library, providing the common web properties as well as "out", "throwTagError()", and an implementation of the "render" tag. |
protected void
|
registerMetaClass(java.lang.Class clazz)
Use this method when you plan to perform some meta-programming on a class. |
protected void
|
setUp()
|
protected void
|
tearDown()
|
Methods inherited from class groovy.util.GroovyTestCase | |
---|---|
groovy.util.GroovyTestCase#getName(), groovy.util.GroovyTestCase#getMethodName(), groovy.util.GroovyTestCase#assertEquals(java.lang.Object, java.lang.Object), groovy.util.GroovyTestCase#assertEquals(java.lang.String, java.lang.Object, java.lang.Object), groovy.util.GroovyTestCase#assertEquals(java.lang.String, java.lang.String), groovy.util.GroovyTestCase#notYetImplemented(), groovy.util.GroovyTestCase#notYetImplemented(junit.framework.TestCase), groovy.util.GroovyTestCase#run(), groovy.util.GroovyTestCase#run(junit.framework.TestResult), groovy.util.GroovyTestCase#toString(), groovy.util.GroovyTestCase#setName(java.lang.String), groovy.util.GroovyTestCase#countTestCases(), groovy.util.GroovyTestCase#runBare(), groovy.util.GroovyTestCase#format(java.lang.String, java.lang.Object, java.lang.Object), groovy.util.GroovyTestCase#fail(), groovy.util.GroovyTestCase#fail(java.lang.String), groovy.util.GroovyTestCase#assertNotNull(java.lang.String, java.lang.Object), groovy.util.GroovyTestCase#assertNotNull(java.lang.Object), groovy.util.GroovyTestCase#assertEquals(java.lang.String, double, double, double), groovy.util.GroovyTestCase#assertEquals(double, double, double), groovy.util.GroovyTestCase#assertEquals(java.lang.String, float, float, float), groovy.util.GroovyTestCase#assertEquals(float, float, float), groovy.util.GroovyTestCase#assertEquals(java.lang.String, long, long), groovy.util.GroovyTestCase#assertEquals(long, long), groovy.util.GroovyTestCase#assertEquals(java.lang.String, boolean, boolean), groovy.util.GroovyTestCase#assertEquals(boolean, boolean), groovy.util.GroovyTestCase#assertEquals(java.lang.String, byte, byte), groovy.util.GroovyTestCase#assertEquals(byte, byte), groovy.util.GroovyTestCase#assertEquals(java.lang.String, char, char), groovy.util.GroovyTestCase#assertEquals(char, char), groovy.util.GroovyTestCase#assertEquals(java.lang.String, short, short), groovy.util.GroovyTestCase#assertEquals(short, short), groovy.util.GroovyTestCase#assertEquals(int, int), groovy.util.GroovyTestCase#assertEquals(java.lang.String, int, int), groovy.util.GroovyTestCase#assertEquals(java.lang.String, java.lang.String, java.lang.String), groovy.util.GroovyTestCase#assertTrue(java.lang.String, boolean), groovy.util.GroovyTestCase#assertTrue(boolean), groovy.util.GroovyTestCase#failNotEquals(java.lang.String, java.lang.Object, java.lang.Object), groovy.util.GroovyTestCase#assertFalse(java.lang.String, boolean), groovy.util.GroovyTestCase#assertFalse(boolean), groovy.util.GroovyTestCase#assertNull(java.lang.String, java.lang.Object), groovy.util.GroovyTestCase#assertNull(java.lang.Object), groovy.util.GroovyTestCase#assertSame(java.lang.String, java.lang.Object, java.lang.Object), groovy.util.GroovyTestCase#assertSame(java.lang.Object, java.lang.Object), groovy.util.GroovyTestCase#assertNotSame(java.lang.Object, java.lang.Object), groovy.util.GroovyTestCase#assertNotSame(java.lang.String, java.lang.Object, java.lang.Object), groovy.util.GroovyTestCase#failSame(java.lang.String), groovy.util.GroovyTestCase#failNotSame(java.lang.String, java.lang.Object, java.lang.Object), groovy.util.GroovyTestCase#wait(), groovy.util.GroovyTestCase#wait(long), groovy.util.GroovyTestCase#wait(long, int), groovy.util.GroovyTestCase#equals(java.lang.Object), groovy.util.GroovyTestCase#hashCode(), groovy.util.GroovyTestCase#getClass(), groovy.util.GroovyTestCase#notify(), groovy.util.GroovyTestCase#notifyAll() |
Methods inherited from class junit.framework.TestCase | |
---|---|
junit.framework.TestCase#run(), junit.framework.TestCase#run(junit.framework.TestResult), junit.framework.TestCase#toString(), junit.framework.TestCase#getName(), junit.framework.TestCase#setName(java.lang.String), junit.framework.TestCase#countTestCases(), junit.framework.TestCase#runBare(), junit.framework.TestCase#format(java.lang.String, java.lang.Object, java.lang.Object), junit.framework.TestCase#fail(), junit.framework.TestCase#fail(java.lang.String), junit.framework.TestCase#assertNotNull(java.lang.String, java.lang.Object), junit.framework.TestCase#assertNotNull(java.lang.Object), junit.framework.TestCase#assertEquals(java.lang.String, java.lang.String), junit.framework.TestCase#assertEquals(java.lang.String, double, double, double), junit.framework.TestCase#assertEquals(double, double, double), junit.framework.TestCase#assertEquals(java.lang.String, float, float, float), junit.framework.TestCase#assertEquals(float, float, float), junit.framework.TestCase#assertEquals(java.lang.String, long, long), junit.framework.TestCase#assertEquals(long, long), junit.framework.TestCase#assertEquals(java.lang.String, boolean, boolean), junit.framework.TestCase#assertEquals(boolean, boolean), junit.framework.TestCase#assertEquals(java.lang.String, byte, byte), junit.framework.TestCase#assertEquals(byte, byte), junit.framework.TestCase#assertEquals(java.lang.String, char, char), junit.framework.TestCase#assertEquals(char, char), junit.framework.TestCase#assertEquals(java.lang.String, short, short), junit.framework.TestCase#assertEquals(short, short), junit.framework.TestCase#assertEquals(int, int), junit.framework.TestCase#assertEquals(java.lang.String, int, int), junit.framework.TestCase#assertEquals(java.lang.String, java.lang.Object, java.lang.Object), junit.framework.TestCase#assertEquals(java.lang.Object, java.lang.Object), junit.framework.TestCase#assertEquals(java.lang.String, java.lang.String, java.lang.String), junit.framework.TestCase#assertTrue(java.lang.String, boolean), junit.framework.TestCase#assertTrue(boolean), junit.framework.TestCase#failNotEquals(java.lang.String, java.lang.Object, java.lang.Object), junit.framework.TestCase#assertFalse(java.lang.String, boolean), junit.framework.TestCase#assertFalse(boolean), junit.framework.TestCase#assertNull(java.lang.String, java.lang.Object), junit.framework.TestCase#assertNull(java.lang.Object), junit.framework.TestCase#assertSame(java.lang.String, java.lang.Object, java.lang.Object), junit.framework.TestCase#assertSame(java.lang.Object, java.lang.Object), junit.framework.TestCase#assertNotSame(java.lang.Object, java.lang.Object), junit.framework.TestCase#assertNotSame(java.lang.String, java.lang.Object, java.lang.Object), junit.framework.TestCase#failSame(java.lang.String), junit.framework.TestCase#failNotSame(java.lang.String, java.lang.Object, java.lang.Object), junit.framework.TestCase#wait(), junit.framework.TestCase#wait(long), junit.framework.TestCase#wait(long, int), junit.framework.TestCase#equals(java.lang.Object), junit.framework.TestCase#hashCode(), junit.framework.TestCase#getClass(), junit.framework.TestCase#notify(), junit.framework.TestCase#notifyAll() |
Property Detail |
---|
java.lang.Object applicationContext
DefaultArtefactInfo domainClassesInfo
java.util.Map errorsMap
java.util.Set loadedCodecs
Method Detail |
---|
protected void addConverters(java.lang.Class clazz)
protected void enableCascadingValidation()
protected void loadCodec(java.lang.Class codecClass)
codecClass
- The codec to load, e.g. HTMLCodec.
protected groovy.util.ConfigObject mockConfig(java.lang.String config)
protected void mockController(java.lang.Class controllerClass)
protected void mockDomain(java.lang.Class domainClass, java.util.List instances = [])
domainClass
- The class to mock.instances
- An optional list of domain instances to use
as the data backing the dynamic methods.
protected GrailsMock mockFor(java.lang.Class clazz, boolean loose = false)
clazz
- The class to mock.loose
- If true
, the method returns a loose-
expectation mock, otherwise it returns a strict one. The default
is a strict mock.
protected void mockForConstraintsTests(java.lang.Class clazz, java.util.List instances = [])
protected void mockLogging(java.lang.Class clazz, boolean enableDebug = false)
enableDebug
argument.
clazz
- The class to add the log method to.enableDebug
- An optional flag to switch on printing of
debug statements.
protected void mockTagLib(java.lang.Class tagLibClass)
protected void registerMetaClass(java.lang.Class clazz)
clazz
- The class to register.
protected void setUp()
protected void tearDown()
Groovy Documentation