A mixin that can be applied to JUnit or Spock tests to add testing support to a users test classes. Can be used in combination with ControllerUnitTestMixin to fully test controller interaction with domains without needing a database
The majority of GORM features are mocked by this unit test mixin including:
Mocking can be applied to any domain class by simply calling the DomainClassUnitTestMixin.mockDomain method
Constructor and description |
---|
DomainClassUnitTestMixin
(java.util.Set<java.lang.String> features) |
DomainClassUnitTestMixin
() |
Type | Name and description |
---|---|
protected void |
enhanceSingleEntity(org.grails.datastore.mapping.model.PersistentEntity entity) |
protected java.lang.Object |
getFailOnError() |
org.grails.datastore.mapping.simple.SimpleMapDatastore |
getSimpleDatastore() |
org.springframework.transaction.PlatformTransactionManager |
getTransactionManager() |
protected void |
initialMockDomainSetup() |
protected void |
initializeMappingContext() |
java.lang.Object |
mockDomain(java.lang.Class<?> domainClassToMock, java.util.List domains = []) Mocks a domain class providing the equivalent GORM behavior but against an in-memory concurrent hash map instead of a database |
java.lang.Object |
mockDomains(java.lang.Class<?>... domainClassesToMock) |
protected org.springframework.validation.Validator |
registerDomainClassValidator(GrailsDomainClass domain) |
protected GrailsDomainClass |
registerGrailsDomainClass(java.lang.Class<?> domainClassToMock) |
protected void |
saveDomainList(org.grails.datastore.mapping.model.PersistentEntity entity, java.util.List domains) |
Methods inherited from class | Name |
---|---|
class GrailsUnitTestMixin |
defineBeans, getApplicationContext, getConfig, getGrailsApplication, getMainContext, getMessageSource, mockCodec, mockFor, mockForConstraintsTests, shouldFail, shouldFail |
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#getMetaClass(), groovy.lang.GroovyObjectSupport#setMetaClass(groovy.lang.MetaClass), 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() |
Mocks a domain class providing the equivalent GORM behavior but against an in-memory concurrent hash map instead of a database
domainClassToMock
- The domain class to mock