Hello Everyone, in this post will learn how to download Cucumber dependencies using Gradle.

Cucumber dependencies/JAR files are required to run a cucumber test in IntelliJ. Downloading the libraries and adding those to the project’s build path one by one is a tedious and time-consuming process. To overcome this problem, we are going to use Gradle, a powerful build management tool which helps in the automatic download and configuration of dependencies or other libraries.

Pre-requisite : 

To download Cucumber dependencies, we need to create a Gradle project in IntelliJ.

Create New Gradle Project in IntelliJ

Step 1: Launch IntelliJ by double-clicking the application

Step 2: Click Create New ProjectNew Project

Step 3: In the next screen,

  1. Select Gradle
  2. IntelliJ automatically adds Project SDK (JDK)
  3. JAVA (Default option)
  4. Click Next


Step 4: Enter ArtifactId and Click Next

Note: ArtifactId is basically our Project Name


Step 5: In the next screen,

  • Select auto-import (Option to resolve all changes made to Gradle project automatically)
  • Select Create separate module per source set (Default Option)
  • Use default gradle wrapper (Default option)
  • Click Next


Step 6: Click Finish

Step 7: New Gradle Project has been created successfully. Project Structure should exactly look similar.

IntelliJ Project

Download Cucumber Dependencies

Following Cucumber dependencies are required to run a cucumber test,

  • Cucumber Core
  • Cucumber Java
  • Cucumber JUnit

Step 1: Open the build.gradle file Gradle file

Step 2: Let’s understand the build.gradle file quickly. Two important sections to note down are,

  • Repositories
    • Repositories section has the name of the remote repository that is used to search for dependencies. Gradle supports Maven and Ivy repository to look for dependencies.
  • Dependencies
    • Dependencies section has the entry to the dependencies. This triggers Gradle to download the libraries/JAR files during the gradle build from the remote repository specified in the repository section.

Build.Gradle File

Step 3: Navigate to https://mvnrepository.com/

Step 4: Search for ‘Cucumber’ in the search box and Click Search

Search Cucumber

Step 5: You should see the search results as below,

Search Results

Step 6: Click Cucumber JVM: Junit -> Select the latest version – > Select the Gradle tab

Gradle tab

Step 7: Copy the text and paste in the build.gradle file under the dependencies section

// https://mvnrepository.com/artifact/info.cukes/cucumber-junit
testCompile group: 'info.cukes', name: 'cucumber-junit', version: '1.2.5'

After you pasted the code, Gradle automatically triggers the download and add the required JAR files to the project. JAR files are found under External Libraries section.
JAR files

Step 8: Repeat step 6 and 7 for Cucumber Java and Cucumber Core dependencies as well. Copy the text and paste in the build.gradle file

// https://mvnrepository.com/artifact/info.cukes/cucumber-java
compile group: 'info.cukes', name: 'cucumber-java', version: '1.2.5'

// https://mvnrepository.com/artifact/info.cukes/cucumber-core
compile group: 'info.cukes', name: 'cucumber-core', version: '1.2.5'

Step 9: build.gradle file and External Dependencies section should exactly look similar.
Download Cucumber Dependencies

Cucumber Dependencies are downloaded successfully!

Troubleshooting tips

If dependencies are not downloaded,

  • Check the auto-import option for Gradle in Preferences/Settings screen.
  • Try using ‘jcenter()’ instead of ‘mavenCentral()’ under the repositories section in the build.gradle file

Know anyone who would like to learn Cucumber (BDD) Automation Testing tool for enhancing their career? Let them know by sharing this article on Facebook, Twitter, or Google Plus.

Leave a Reply

Your email address will not be published. Required fields are marked *

Discover more from Letzdotesting

Subscribe now to keep reading and get access to the full archive.

Continue reading