Class Cucumber
- java.lang.Object
-
- org.junit.runner.Runner
-
- org.junit.runners.ParentRunner<ParentRunner<?>>
-
- io.cucumber.junit.Cucumber
-
- All Implemented Interfaces:
Describable,Filterable,Orderable,Sortable
@API(status=STABLE) public final class Cucumber extends ParentRunner<ParentRunner<?>>
Cucumber JUnit Runner.A class annotated with
@RunWith(Cucumber.class)will run feature files as junit tests. 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
.featureand glue files on the classpath, using the same resource path as the annotated class. For example, if the annotated class iscom.example.RunCucumberthen features and glue are assumed to be located incom.example.Options can be provided in by (order of precedence):
- Properties from
System.getProperties()()} - Properties from in
System.getenv() - Annotating the runner class with
CucumberOptions - Properties from "cucumber.properties"
Constants.Cucumber also supports JUnits
ClassRule,BeforeClassandAfterClassannotations. 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.- See Also:
CucumberOptions
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StatementchildrenInvoker(RunNotifier notifier)protected DescriptiondescribeChild(ParentRunner<?> child)protected List<ParentRunner<?>>getChildren()protected voidrunChild(ParentRunner<?> child, RunNotifier notifier)voidsetScheduler(RunnerScheduler scheduler)-
Methods inherited from class org.junit.runners.ParentRunner
classBlock, classRules, collectInitializationErrors, createTestClass, filter, getDescription, getName, getRunnerAnnotations, getTestClass, isIgnored, order, run, runLeaf, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses, withInterruptIsolation
-
-
-
-
Constructor Detail
-
Cucumber
public Cucumber(Class<?> clazz) throws InitializationError
Constructor called by JUnit.- Parameters:
clazz- the class with the @RunWith annotation.- Throws:
InitializationError- if there is another problem
-
-
Method Detail
-
getChildren
protected List<ParentRunner<?>> getChildren()
- Specified by:
getChildrenin classParentRunner<ParentRunner<?>>
-
describeChild
protected Description describeChild(ParentRunner<?> child)
- Specified by:
describeChildin classParentRunner<ParentRunner<?>>
-
runChild
protected void runChild(ParentRunner<?> child, RunNotifier notifier)
- Specified by:
runChildin classParentRunner<ParentRunner<?>>
-
childrenInvoker
protected Statement childrenInvoker(RunNotifier notifier)
- Overrides:
childrenInvokerin classParentRunner<ParentRunner<?>>
-
setScheduler
public void setScheduler(RunnerScheduler scheduler)
- Overrides:
setSchedulerin classParentRunner<ParentRunner<?>>
-
-