ServiceUnitTestMixin (Grails 3.2.7)
Date: 2017-03-06

Package: grails.test.mixin.services

## [Groovy] Class ServiceUnitTestMixin

- grails.test.mixin.services.ServiceUnitTestMixin

- A mixin that provides mocking capability for services.

  Authors:
    Graeme Rocher
  Since:
    2.0

- - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `T` | `mockService(java.lang.Class<T> serviceClass)` Mocks a service class, registering it with the application context
    `T` | `testFor(java.lang.Class<T> serviceClass)` Mocks a service class, registering it with the application context

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class DomainClassUnitTestMixin` | `enhanceSingleEntity, getFailOnError, getSimpleDatastore, getTransactionManager, initialMockDomainSetup, initializeMappingContext, mockDomain, mockDomains, registerDomainClassValidator, registerGrailsDomainClass, saveDomainList`
    `class GrailsUnitTestMixin` | `defineBeans, getApplicationContext, getConfig, getGrailsApplication, getMainContext, getMessageSource, mockCodec, 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#getMetaClass(), groovy.lang.GroovyObjectSupport#setMetaClass(groovy.lang.MetaClass), groovy.lang.GroovyObjectSupport#invokeMethod(java.lang.String, java.lang.Object), 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()`

- - ### Method Detail

    - #### T mockService(java.lang.Class<T> serviceClass)

      Mocks a service class, registering it with the application context

      Parameters:
        `serviceClass` - The service class
      Returns:
        An instance of the service

    - #### T testFor(java.lang.Class<T> serviceClass)

      Mocks a service class, registering it with the application context

      Parameters:
        `serviceClass` - The service class
      Returns:
        An instance of the service