A base unit testing mixin that watches for MetaClass changes and unbinds them on tear down.
Constructor and description |
---|
GrailsUnitTestMixin
(java.util.Set<java.lang.String> features) |
GrailsUnitTestMixin
() |
Type Params | Return Type | Name and description |
---|---|---|
|
void |
defineBeans(boolean immediateDelivery = true, groovy.lang.Closure<?> closure) |
|
GrailsWebApplicationContext |
getApplicationContext() |
|
groovy.util.ConfigObject |
getConfig() |
|
GrailsApplication |
getGrailsApplication() |
|
GrailsWebApplicationContext |
getMainContext() |
|
org.springframework.context.MessageSource |
getMessageSource() |
|
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. |
|
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. |
Methods inherited from class | Name |
---|---|
class TestMixinRuntimeSupport |
getFeatures, getRuntime, setRuntime, setTestClass |
class groovy.lang.GroovyObjectSupport |
groovy.lang.GroovyObjectSupport#setProperty(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#getProperty(java.lang.String), groovy.lang.GroovyObjectSupport#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#setMetaClass(groovy.lang.MetaClass), groovy.lang.GroovyObjectSupport#getMetaClass(), groovy.lang.GroovyObjectSupport#wait(long, int), groovy.lang.GroovyObjectSupport#wait(long), groovy.lang.GroovyObjectSupport#wait(), groovy.lang.GroovyObjectSupport#equals(java.lang.Object), groovy.lang.GroovyObjectSupport#toString(), groovy.lang.GroovyObjectSupport#hashCode(), groovy.lang.GroovyObjectSupport#getClass(), groovy.lang.GroovyObjectSupport#notify(), groovy.lang.GroovyObjectSupport#notifyAll() |
Loads the given codec, adding the "encodeAs...()" and "decode...()" methods to objects.
codecClass
- The codec to load, e.g. HTMLCodec.Creates a new Grails mock for the given class. Use it as you would use MockFor and StubFor.
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.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.
Asserts that the given code closure fails when it is evaluated
Asserts that the given code closure fails when it is evaluated and that a particular exception is thrown.
clazz
- the class of the expected exceptioncode
- the closure that should fail