Groovy Documentation

grails.test.mixin.domain
[Groovy] Class DomainClassUnitTestMixin

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

class DomainClassUnitTestMixin
extends GrailsUnitTestMixin

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

Authors:
Graeme Rocher
Since:
2.0


Field Summary
protected org.grails.datastore.mapping.core.Session currentSession

 
Property Summary
static org.grails.datastore.mapping.simple.SimpleMapDatastore simpleDatastore

static org.springframework.transaction.PlatformTransactionManager transactionManager

 
Method Summary
static void cleanupDatastore()

void connectDatastore()

static void initializeDatastoreImplementation()

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

void shutdownDatastoreImplementation()

 
Methods inherited from class GrailsUnitTestMixin
cleanupModifiedMetaClasses, defineBeans, deregisterMetaClassCleaner, initGrailsApplication, mockCodec, mockFor, mockForConstraintsTests, registerMetaClassRegistryWatcher, resetGrailsApplication, shouldFail, shouldFail, 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()
 

Field Detail

currentSession

protected org.grails.datastore.mapping.core.Session currentSession


 
Property Detail

simpleDatastore

static org.grails.datastore.mapping.simple.SimpleMapDatastore simpleDatastore


transactionManager

static org.springframework.transaction.PlatformTransactionManager transactionManager


 
Method Detail

cleanupDatastore

@AfterClass
static void cleanupDatastore()


connectDatastore

@Before
void connectDatastore()


initializeDatastoreImplementation

@BeforeClass
static void initializeDatastoreImplementation()


mockDomain

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
Parameters:
domainClassToMock - The domain class to mock
Returns:
An instance of the mocked domain class


shutdownDatastoreImplementation

@After
void shutdownDatastoreImplementation()


 

Groovy Documentation