Class 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 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:
    CucumberOptions