Groovy Documentation

grails.test.mixin.support
[Groovy] Class GrailsUnitTestMixin

java.lang.Object
  grails.test.mixin.support.GrailsUnitTestMixin

class GrailsUnitTestMixin
extends java.lang.Object

A base unit testing mixin that watches for MetaClass changes and unbinds them on tear down.

Authors:
Graeme Rocher
Since:
2.0


Property Summary
static GrailsWebApplicationContext applicationContext

static groovy.util.ConfigObject config

static GrailsApplication grailsApplication

java.util.Set loadedCodecs

static org.springframework.context.MessageSource messageSource

java.util.Map validationErrorsMap

 
Method Summary
static void cleanupModifiedMetaClasses()

static void defineBeans(groovy.lang.Closure callable)

static void deregisterMetaClassCleaner()

static void initGrailsApplication()

void mockCodec(java.lang.Class codecClass)

Loads the given codec, adding the "encodeAs...()" and "decode...()" methods to objects.

GrailsMock mockFor(java.lang.Class clazz, boolean loose = false)

Creates a new Grails mock for the given class.

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.

static void registerMetaClassRegistryWatcher()

void resetGrailsApplication()

java.lang.String shouldFail(groovy.lang.Closure code)

Asserts that the given code closure fails when it is evaluated

java.lang.String shouldFail(java.lang.Class clazz, groovy.lang.Closure code)

Asserts that the given code closure fails when it is evaluated and that a particular exception is thrown.

static void shutdownApplicationContext()

 
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

applicationContext

static GrailsWebApplicationContext applicationContext


config

static groovy.util.ConfigObject config


grailsApplication

static GrailsApplication grailsApplication


loadedCodecs

java.util.Set loadedCodecs


messageSource

static org.springframework.context.MessageSource messageSource


validationErrorsMap

java.util.Map validationErrorsMap


 
Method Detail

cleanupModifiedMetaClasses

static void cleanupModifiedMetaClasses()


defineBeans

static void defineBeans(groovy.lang.Closure callable)


deregisterMetaClassCleaner

@AfterClass
static void deregisterMetaClassCleaner()


initGrailsApplication

@BeforeClass
static void initGrailsApplication()


mockCodec

void mockCodec(java.lang.Class codecClass)
Loads the given codec, adding the "encodeAs...()" and "decode...()" methods to objects.
Parameters:
codecClass - The codec to load, e.g. HTMLCodec.


mockFor

GrailsMock mockFor(java.lang.Class clazz, boolean loose = false)
Creates a new Grails mock for the given class. Use it as you would use MockFor and StubFor.
Parameters:
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.


mockForConstraintsTests

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. This can then be used to test the constraints on the class.


registerMetaClassRegistryWatcher

static void registerMetaClassRegistryWatcher()


resetGrailsApplication

@After
void resetGrailsApplication()


shouldFail

java.lang.String shouldFail(groovy.lang.Closure code)
Asserts that the given code closure fails when it is evaluated
Parameters:
code
Returns:
the message of the thrown Throwable


shouldFail

java.lang.String shouldFail(java.lang.Class clazz, groovy.lang.Closure code)
Asserts that the given code closure fails when it is evaluated and that a particular exception is thrown.
Parameters:
clazz - the class of the expected exception
code - the closure that should fail
Returns:
the message of the expected Throwable


shutdownApplicationContext

@AfterClass
static void shutdownApplicationContext()


 

Groovy Documentation