Using Cucumber Eclipse Plugin, eclipse understands the basic Gherkin syntax. This plugin highlights all the main syntax in the Feature file, making it more readable and clear. You can also execute feature files using its runner without using TestNG or JUnit.
To install Cucumber Eclipse Plugin follow this article
Features of Cucumber Eclipse Plugin
1. New Step-Definition File Wizard
User can create a new Step definition file from Eclipse 'File' Menu. Go to File > New > Other > Cucumber > Step-Definition class > Next >.
While creating the step definition file, give the source folder, package name, and name of your java class file. You can also select any annotation from here, and a new step definition Java file will be created for Selected annotations.
2. Auto Generation of Sample Feature File
When you create a new feature file (.feature), your feature file will display one scenario and scenario outline sample that can be used as a sample reference.
3. Pretty Formatting
You can use Pretty Formatting by right-clicking on your feature file.
4. Click through from Step to Step Definition
You can click on corresponding step definition by using Ctrl+Click on Step in feature file. Currently only works in English, and from pop up menu.
5. Content Assistance For Feature File
With the Cucumber Eclipse plugin, Content assistance is provided for keywords and Steps. You can use the [Ctrl]+[Space] keys while writing feature files to use this feature.
In new line if you will press Ctrl+Space it will suggest you Gherkin Keywords.
After Given, When, Then if you will press Ctrl+Space it will populate existing step definitions created by you.
6. Syntax Highlighting
Numeric literals have been added to the syntax highlighting. Using this feature you can change color for
- Right click on your feature file and select preferences. From the preferences pop up Left Menu, Select General -> Appearance -> Colors and Fonts
- Select Gherkin Folder and then any of option from Comment, Keyword etc and Double click on that. You will get color palette from there you can select color and then click on Apply and Close button.
7. Feature Runner
Using Feature Runner, you can execute the feature file without Cucumber Runner by Right-clicking on the feature file. You can also define your runner with different formatter from run configurations.
Here you can specify path for feature, glue code and select formatter.
8. Lambda Expression support
Cucumber-eclipse plugin is also enhanced to support both Content-Assistance and Glue-code features for Lambda Expressions.
public class TestLambdaStepdefs implements En
{
//Lambda-steps inside Constructors
public TestLambdaStepdefs()
{
Given("testlambda", () -> {
System.out.println("Inside Given");
});
}
//Lambda-steps inside method
private void testLambdaSteps()
{
Before((Scenario scenario) -> {
log.info("Before scenario : " + scenario.getName());
});
When("^I do this$", () -> {
});
}
}