In this blog we will explore how to set up IntelliJ to create a Maven project for using Cucumber with Selenium WebDriver Java


JDK Install

Install Java Development Kit from

Add a Windows environment variable (system properties, WinKey + Pause -> Advanced System Settings -> Environment Variables) JAVA_HOME to point at the JDK directory.

Maven Install

Download Maven from and extract the zip to a location of your choice.

Add the path to the \bin folder of the Maven install to the Windows PATH environment variable (system properties, WinKey + Pause -> Advanced System Settings -> Environment Variables)

Open a new command prompt (Winkey + R then type cmd) and run mvn -v to verify the installation.

Install IntelliJ

Install from: I’m using the community edition in this blog


IntelliJ Configuration

JDK Path

As Maven uses the JDK (not JRE) we will add the path to the JDK in IntelliJ. Open IntelliJ, and use

File->Project Structure… Click on SDKs on left, click the ‘+’ add button and add the path to your JDK install from earlier.

Cucumber & Gherkin Plugins

IntelliJ, File->Settings and click on Plugins

Now click the Browse Repositories button and search for Cucumber. Install the plugin, then re-start IntelliJ


Project Setup

In IntelliJ, choose File->New Project. Choose Maven as the type. leave ‘Create from Archetype’ unchecked, and click Next

complete group id (e.g. com.edgewords.maven), the artefact id (whatever you want to call the project) and click Next

Choose a location to save the project and finish.

Expand the project structure, and under src/test/java we will create some packages to store our code bindings and runners.

Right-click on the java folder under test, and add new package. Call it bindings

Same again, another package called runners

Right-click on the test folder, and add new directory, call it resources.

Right-click on the new resources folder and choose Mark Directory as->Test Resources Root

You should now have:


POM File

We now need to specify all the project dependencies using the Maven POM.

Open the POM.xml file and add all of the code as shown below:



Obviously keep your project definition at the top as it was, it is only from the <properties> section onwards that you need to add.


Now on the right-hand side of the IntelliJ IDE, click Maven Projects tab to show Maven lifecycle. Now click re-import Maven Projects button to update from the POM.


Feature File

Right-click on our test resources folder and choose New->File. Call it basket.feature

Write your feature, example:


Execute the Feature

Now right-click on the feature and run the feature

The Feature has no code bindings so in the Run pane at the bottom of IntelliJ, it will suggest some boiler-plate code bindings for you. Select these and copy to the clipboard.

Right-click on our bindings package in the Project Explorer and choose New->Java Class.

Paste in your boiler-plate code.

Now we need our imports to fix any errors. You can click in a line of code error and use Alt-Enter to fix imports, or here are the imports we will be using for this feature:


We now need to write our WebDriver code as well. Here is the completed code for you:


We now need to tell IntelliJ where the feature files & code bindings are before we can execute Feature files. In IntelliJ menu, Run->Edit Configurations

Click on the feature name on the left and provide the Glue (package that the code bindings will reside) and the Feature or Folder Path (where are Features files reside)

Now we can execute the Feature again, and this time it should open a Web Browser and perform the test!!


Run from Maven

Now we have a working example, let’s execute using Maven. To do this we need a runner script.

Right-click on the runners package and New->Java Class, call it MyRunner and add the following code:


In the Maven POM.xml, we specified that we want to execute this class:


So now we can use Maven for execution. Open the Maven panel on the right-hand side in IntelliJ and double-click the test phase in the lifecycle. It should run.

In the bottom of IntelliJ you can also open the Terminal window and type mvn test and hit enter this should also run!



We have created several reports with the code in this blog. We have used the Surefire reporting plugin (specified in the POM.xml), if you look in your project explorer, target/surefire-reports you will see them in there.

We have also created some reports using our Cucumber Runner Class. You will find these using Windows explorer under the project there will be a reports folder with html and json cucumber reports.



Edgewords provides classroom, online and on-site training in BDD Cucumber (and SpecFlow) as well as Selenium WebDriver (Java & C#), take a look at our course schedules or phone for a quote.