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
.feature
and glue files on the classpath, using the same resource path as the annotated class. For example, if the annotated class iscom.example.RunCucumber
then 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
,BeforeClass
andAfterClass
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.- See Also:
CucumberOptions
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Statement
childrenInvoker(RunNotifier notifier)
protected Description
describeChild(ParentRunner<?> child)
protected List<ParentRunner<?>>
getChildren()
protected void
runChild(ParentRunner<?> child, RunNotifier notifier)
void
setScheduler(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:
getChildren
in classParentRunner<ParentRunner<?>>
-
describeChild
protected Description describeChild(ParentRunner<?> child)
- Specified by:
describeChild
in classParentRunner<ParentRunner<?>>
-
runChild
protected void runChild(ParentRunner<?> child, RunNotifier notifier)
- Specified by:
runChild
in classParentRunner<ParentRunner<?>>
-
childrenInvoker
protected Statement childrenInvoker(RunNotifier notifier)
- Overrides:
childrenInvoker
in classParentRunner<ParentRunner<?>>
-
setScheduler
public void setScheduler(RunnerScheduler scheduler)
- Overrides:
setScheduler
in classParentRunner<ParentRunner<?>>
-
-