TestPlugin (Grails 3.2.9)
Date: 2017-04-26

Package: grails.test.runtime

## [Groovy] Interface TestPlugin

- Interface to TestPlugin The TestRuntime is event based and handles events by TestPlugins. TestPlugins should be stateless. All state should be held in TestRuntime variables. Dependencies between plugins are expressed by "features". A "feature" is identified by a String value. For example "grailsApplication". A plugin can require or provide features. A TestRuntime instance is requested with an array of required features. The TestRuntimeFactory contains a registry of all plugins and does the dependency resolution to find out what plugins should be added to the runtime and what the order is. The order based on dependencies is the most significant. Plugins with the same dependency order are sorted by the "getOrdinal()" value (highest value comes first). It's possible to override "features" by providing a plugin with a higher ordinal value than another plugin. The overriding plugin might have to provide all of the features of the other plugin when the plugin provides several features. Custom plugins can be registered to the single TestRuntimeFactory in static initializer blocks of the test class. The plugin class can also implement TestEventInterceptor. In that case the instance will be also registered as an event interceptor.

  Authors:
    Lari Hotari
  Since:
    2.4.0

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `void` | `close(TestRuntime runtime)` this method is called when the state of the given runtime should be cleaned.
    `` | `int` | `getOrdinal()` Priority order of the plugin default value is 0
    `` | `java.lang.String[]` | `getProvidedFeatures()` @return array of provided features
    `` | `java.lang.String[]` | `getRequiredFeatures()` @return array of required features
    `` | `void` | `onTestEvent(TestEvent event)` this method gets called for all events that occur in the TestRuntime

- - ### Method Detail

    - #### void close(TestRuntime runtime)

      this method is called when the state of the given runtime should be cleaned.

      Parameters:
        `runtime` - that is to be closed

    - #### int getOrdinal()

      Priority order of the plugin default value is 0

      Returns:
        value used for sorting plugins with same dependency order. It is also used for picking a plugin when multiple plugins implement a single feature. Highest value wins.

    - #### java.lang.String[] getProvidedFeatures()

      Returns:
        array of provided features

    - #### java.lang.String[] getRequiredFeatures()

      Returns:
        array of required features

    - #### void onTestEvent(TestEvent event)

      this method gets called for all events that occur in the TestRuntime

      Parameters:
        `event,` - see TestEvent for details