Class Cucumber

java.lang.Object
org.junit.runner.Runner
org.junit.runners.ParentRunner<org.junit.runners.ParentRunner<?>>
io.cucumber.junit.Cucumber
All Implemented Interfaces:
org.junit.runner.Describable, org.junit.runner.manipulation.Filterable, org.junit.runner.manipulation.Orderable, org.junit.runner.manipulation.Sortable

@Deprecated(forRemoval=true) @API(status=STABLE) public final class Cucumber extends org.junit.runners.ParentRunner<org.junit.runners.ParentRunner<?>>
Deprecated, for removal: This API element is subject to removal in a future version.
JUnit 4 is in maintenance mode. Upgrade to JUnit 5+ and switch to the cucumber-junit-platform-engine.
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")
 final 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.

Options can be provided in by (order of precedence):

  1. Properties from System.getProperties() ()}
  2. Properties from in System.getenv()
  3. Annotating the runner class with CucumberOptions
  4. Properties from "cucumber.properties"
For available properties see Constants.

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.

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private class 
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    (package private) static final class 
    Deprecated, for removal: This API element is subject to removal in a future version.
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final EventBus
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    private final List<org.junit.runners.ParentRunner<?>>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    private boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    private final Plugins
    Deprecated, for removal: This API element is subject to removal in a future version.
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Cucumber(Class<?> clazz)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Constructor called by JUnit.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.junit.runners.model.Statement
    childrenInvoker(org.junit.runner.notification.RunNotifier notifier)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    protected org.junit.runner.Description
    describeChild(org.junit.runners.ParentRunner<?> child)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    protected List<org.junit.runners.ParentRunner<?>>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    protected void
    runChild(org.junit.runners.ParentRunner<?> child, org.junit.runner.notification.RunNotifier notifier)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    void
    setScheduler(org.junit.runners.model.RunnerScheduler scheduler)
    Deprecated, for removal: This API element is subject to removal in a future version.
     

    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

    Methods inherited from class org.junit.runner.Runner

    testCount

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • children

      private final List<org.junit.runners.ParentRunner<?>> children
      Deprecated, for removal: This API element is subject to removal in a future version.
    • bus

      private final EventBus bus
      Deprecated, for removal: This API element is subject to removal in a future version.
    • plugins

      private final Plugins plugins
      Deprecated, for removal: This API element is subject to removal in a future version.
    • context

      private final CucumberExecutionContext context
      Deprecated, for removal: This API element is subject to removal in a future version.
    • multiThreadingAssumed

      private boolean multiThreadingAssumed
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Constructor Details

    • Cucumber

      public Cucumber(Class<?> clazz) throws org.junit.runners.model.InitializationError
      Deprecated, for removal: This API element is subject to removal in a future version.
      Constructor called by JUnit.
      Parameters:
      clazz - the class with the @RunWith annotation.
      Throws:
      org.junit.runners.model.InitializationError - if there is another problem
  • Method Details

    • getChildren

      protected List<org.junit.runners.ParentRunner<?>> getChildren()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      getChildren in class org.junit.runners.ParentRunner<org.junit.runners.ParentRunner<?>>
    • describeChild

      protected org.junit.runner.Description describeChild(org.junit.runners.ParentRunner<?> child)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      describeChild in class org.junit.runners.ParentRunner<org.junit.runners.ParentRunner<?>>
    • runChild

      protected void runChild(org.junit.runners.ParentRunner<?> child, org.junit.runner.notification.RunNotifier notifier)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      runChild in class org.junit.runners.ParentRunner<org.junit.runners.ParentRunner<?>>
    • childrenInvoker

      protected org.junit.runners.model.Statement childrenInvoker(org.junit.runner.notification.RunNotifier notifier)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Overrides:
      childrenInvoker in class org.junit.runners.ParentRunner<org.junit.runners.ParentRunner<?>>
    • setScheduler

      public void setScheduler(org.junit.runners.model.RunnerScheduler scheduler)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Overrides:
      setScheduler in class org.junit.runners.ParentRunner<org.junit.runners.ParentRunner<?>>