Package io.cucumber.spring
Annotation Type CucumberContextConfiguration
@Retention(RUNTIME)
@Target(TYPE)
@API(status=STABLE)
public @interface CucumberContextConfiguration
This annotation is used on a configuration class to make the Cucumber aware
of the test configuration. This is to be used in conjunction with
@ContextConfiguration
, @ContextHierarchy
or
@BootstrapWith
. In case of SpringBoot, the configuration class can be
annotated as follows:
@CucumberContextConfiguration @SpringBootTest(classes = TestConfig.class) public class CucumberSpringConfiguration { }
Notes:
- Only one glue class should be annotated with
@CucumberContextConfiguration
otherwise an exception will be thrown. - Cucumber Spring uses Spring's
TestContextManager
framework internally. As a result a single Cucumber scenario will mostly behave like a JUnit test. - The class annotated with
CucumberContextConfiguration
is instantiated but not initialized by Spring. This instance is processed by SpringsTestExecutionListeners
. So features that depend on a test execution listener such as mock beans will work on the annotated class - but not on other step definition classes. Features that depend on initializing beans - such as AspectJ - will not work on the annotated class - but will work on step definition classes.