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

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

## grails.test.mixin.services
[Groovy] Class ServiceUnitTestMixin

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

    class ServiceUnitTestMixin
    extends DomainClassUnitTestMixin

A mixin that provides mocking capability for services.

Authors:
  Graeme Rocher

Since:
  2.0

Field Summary

Fields inherited from class DomainClassUnitTestMixin
currentSession

Method Summary
`java.lang.Object` | `mockService(java.lang.Class serviceClass)` Mocks a service class, registering it with the application context
`java.lang.Object` | `testFor(java.lang.Class serviceClass)` Mocks a service class, registering it with the application context

Methods inherited from class DomainClassUnitTestMixin
cleanupDatastore, connectDatastore, enhanceSingleEntity, getFailOnError, initialMockDomainSetup, initializeDatastoreImplementation, initializeMappingContext, mockDomain, mockDomains, registerDomainClassValidator, registerGrailsDomainClass, saveDomainList, shutdownDatastoreImplementation

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

Method Detail

### mockService

    java.lang.Object mockService(java.lang.Class serviceClass)

  Mocks a service class, registering it with the application context
  Parameters:
    `serviceClass` - The service class
  Returns:
    An instance of the service

### testFor

    java.lang.Object testFor(java.lang.Class serviceClass)

  Mocks a service class, registering it with the application context
  Parameters:
    `serviceClass` - The service class
  Returns:
    An instance of the service

Groovy Documentation