Package io.cucumber.guice


package io.cucumber.guice
Cucumber Guice configuration Api

An implementation of this interface is used to obtain an com.google.inject.Injector that is used to provide instances of all the classes that are used to run the Cucumber tests. The injector should be configured with a binding for ScenarioScope.

This module allows you to use Google Guice dependency injection in your Cucumber tests. Guice comes as standard with singleton scope and 'no scope'. This module adds Cucumber scenario scope to the scopes available for use in your test code. The rest of this documentation assumes you have at least a basic understanding of Guice. Please refer to the Guice wiki if necessary, see https://github.com/google/guice/wiki/Motivation

By including the cucumber-guice jar on your CLASSPATH your Step Definitions will be instantiated by Guice. There are two main modes of using the module: with scope annotations and with module bindings. The two modes can also be mixed. When mixing modes it is important to realise that binding a class in a scope in a module takes precedence if the same class is also bound using a scope annotation.

  • Class
    Description
    Provides a convenient Module instance that contains bindings for ScenarioScoped annotation and for ScenarioScope.
    Creates an instance of ScenarioScope for use when declaring bindings in implementations of Module.
     
    Guice implementation of the io.cucumber.core.backend.ObjectFactory.
    An implementation of this interface is used to obtain an com.google.inject.Injector that is used to provide instances of all the classes that are used to run the Cucumber tests.
     
    A custom Guice scope that enables classes to be bound in a scope that will last for the lifetime of one Cucumber scenario.
    A custom Guice scope annotation that is usually bound to an instance of ScenarioScope.