@API(status=STABLE)
public class Cucumber
extends org.junit.runners.ParentRunner<io.cucumber.junit.FeatureRunner>
Classes annotated with @RunWith(Cucumber.class)
will run a Cucumber Feature.
In general, the runner class should be empty without any fields or methods.
For example:
@RunWith(Cucumber.class) @CucumberOptions(plugin = "pretty") public class RunCucumberTest { }
By default Cucumber will look for .feature
and glue files on the classpath, using the same resource
path as the annotated class. For example, if the annotated class is com.example.RunCucumber
then
features and glue are assumed to be located in com.example
.
Additional hints can be provided to Cucumber by annotating the class with CucumberOptions
.
Cucumber also supports JUnits ClassRule
, BeforeClass
and AfterClass
annotations.
These will be executed before and after all scenarios. Using these is not recommended as it limits the portability
between different runners; they may not execute correctly when using the commandline, IntelliJ IDEA or
Cucumber-Eclipse. Instead it is recommended to use Cucumbers `Before` and `After` hooks.
CucumberOptions
Constructor and Description |
---|
Cucumber(Class clazz)
Constructor called by JUnit.
|
Modifier and Type | Method and Description |
---|---|
protected org.junit.runners.model.Statement |
childrenInvoker(org.junit.runner.notification.RunNotifier notifier) |
protected org.junit.runner.Description |
describeChild(io.cucumber.junit.FeatureRunner child) |
List<io.cucumber.junit.FeatureRunner> |
getChildren() |
protected void |
runChild(io.cucumber.junit.FeatureRunner child,
org.junit.runner.notification.RunNotifier notifier) |
void |
setScheduler(org.junit.runners.model.RunnerScheduler scheduler) |
public Cucumber(Class clazz) throws org.junit.runners.model.InitializationError
clazz
- the class with the @RunWith annotation.org.junit.runners.model.InitializationError
- if there is another problempublic List<io.cucumber.junit.FeatureRunner> getChildren()
getChildren
in class org.junit.runners.ParentRunner<io.cucumber.junit.FeatureRunner>
protected org.junit.runner.Description describeChild(io.cucumber.junit.FeatureRunner child)
describeChild
in class org.junit.runners.ParentRunner<io.cucumber.junit.FeatureRunner>
protected void runChild(io.cucumber.junit.FeatureRunner child, org.junit.runner.notification.RunNotifier notifier)
runChild
in class org.junit.runners.ParentRunner<io.cucumber.junit.FeatureRunner>
protected org.junit.runners.model.Statement childrenInvoker(org.junit.runner.notification.RunNotifier notifier)
childrenInvoker
in class org.junit.runners.ParentRunner<io.cucumber.junit.FeatureRunner>
public void setScheduler(org.junit.runners.model.RunnerScheduler scheduler)
setScheduler
in class org.junit.runners.ParentRunner<io.cucumber.junit.FeatureRunner>
Copyright © 2019. All rights reserved.