Behavior Driven Development with JUnit 5. Part 4
The fourth part of our article on Behavior Driven Development with JUnit 5. Happy reading.
The keywords Feature, Scenario, Given, When, Then, and And are highlighted. Right-clicking this feature file shows the option to run it directly (figure 2).
Figure 2 Directly running the passengers_policy.feature file by right-clicking the file
This is possible only if two requirements are fulfilled. First, the appropriate plugins must be activated. To do this in IntelliJ, go to File > Settings > Plugins and install the Cucumber for Java and Gherkin plugins (figures 3 and 4).
Figure 3 Installing the Cucumber for Java plugin from the File > Settings > Plugins menu
Figure 4 Installing the Gherkin plugin from the File > Settings > Plugins menu
Second, we must configure the way the feature is run. Go to Run > Edit Configurations, and set the following options (figure 5):
Figure 5 Setting the feature configuration by filling in the Main Class, Glue, Feature or Folder Path, and Working Directory fields
- Main Class: cucumber.api.cli.Main
- Glue (the package where step definitions are stored): com.luxoft.bddjunit5.airport
- Feature or Folder Path: the test/resources/features folder we have created
- Working Directory: the project folder
Running the feature directly generates the skeleton of the Java Cucumber tests (figure 6).
Figure 6 Getting the skeleton of the Passengers Policy feature by directly running the feature file. The annotated methods are executed to verify the scenarios.
Interested in JUnit? Check out our trainings.
Catalin Tudose
Java and Web Technologies Expert
Originally published at https://www.luxoft-training.com.