Skip to main content

Cucumber Eclipse Plugin

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.

create new step definition file using Cucumber Eclipse Plugin

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.

Auto Generation of Sample Feature File in cucumber eclipse plugin

3. Pretty Formatting

You can use Pretty Formatting by right-clicking on your feature file.

use pretty formatting using Cucumber Eclipse Plugin

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.

content assistance feature in cucumber eclipse plugin

After Given, When, Then if you will press Ctrl+Space it will populate existing step definitions created by you.

content assistant in cucumber step definitions

6. Syntax Highlighting

Numeric literals have been added to the syntax highlighting. Using this feature you can change color for 

  1. Right click on your feature file and select preferences. From the preferences pop up Left Menu, Select General -> Appearance -> Colors and Fonts 
  2. 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.

syntax highlighting in Cucumber Eclipse Plugin

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.

run your feature file using Cucumber Eclipse Plugin

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$", () -> {
        });
    }
}

Cucumber Eclipse Plugin Video Tutorial

Submitted by tgoswami on August 29, 2020

Tarun has 11+ years of experience in Quality Assurance in different domains like Banking, E-commerce, Health and Education.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.