GrailsUnitTestMixin (Grails 2.3.8)
Date: 2014-04-24

Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | PROPERTY | CONSTR | METHOD | DETAIL: FIELD | PROPERTY | CONSTR | METHOD

## 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 GrailsWebApplicationContext` | `mainContext`
`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.
`protected static void` | `registerBeans()`
`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(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), 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

### mainContext

    static GrailsWebApplicationContext mainContext

### messageSource

    static org.springframework.context.MessageSource messageSource

### validationErrorsMap

    java.util.Map validationErrorsMap

Method Detail

### cleanupModifiedMetaClasses

    @groovy.transform.CompileStatic
    static void cleanupModifiedMetaClasses()

### defineBeans

    @groovy.transform.CompileStatic
    static void defineBeans(groovy.lang.Closure callable)

### deregisterMetaClassCleaner

    @org.junit.AfterClass
    @groovy.transform.CompileStatic
    static void deregisterMetaClassCleaner()

### initGrailsApplication

    @org.junit.BeforeClass
    @groovy.transform.CompileStatic
    static void initGrailsApplication()

### mockCodec

    @groovy.transform.CompileStatic
    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

    @groovy.transform.CompileStatic
    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.

### registerBeans

    protected static void registerBeans()

### registerMetaClassRegistryWatcher

    @groovy.transform.CompileStatic
    static void registerMetaClassRegistryWatcher()

### resetGrailsApplication

    @org.junit.After
    void resetGrailsApplication()

### shouldFail

    @groovy.transform.CompileStatic
    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

    @org.junit.AfterClass
    @groovy.transform.CompileStatic
    static void shutdownApplicationContext()

Groovy Documentation