Friday, December 25, 2015

First Cucumber JVM project

1) Download template project

Download cucumber-jvm-template project from github [or checkout if you are comfortable using git]. Unzip the project on your file system. I unzipped it into C:\GitProjects\some folder\cucumber-jvm-template.

Import it in Eclipse as Maven project

Click File – Import in Eclipse and select the below option
Then point it to the directory where you download the project. In my case as mentioned above, I copy pasted the location of the directory as below. Then CHECK the box against pom.xml and then finish. The project should appear in Eclipse now

2)cucumber-jvm and dependent jars

So far we have been talking only about set up. But where is cucumber-jvm and other jars. This is where we look into pom.xml, which has all necessary dependent information that is required for this project
The libraries or dependent jars that we will use are
  • cucumber-java: This library is being developed and is dependent on cucumber-core, which has most of the core api’s
  • cucumber-testng: cucumber can be run through testng too
  • cucumber-junit: This is the most popular way to kick off cucumber tests written in java
  • selenium-java: Selenium jars that are required for our browser based tests.
  • junit, log4j, apache-poi, xmlapis, xerces: All of these jars will be used over time.
  • maven-surefire plugin: This plugin is used for kicking off junit, testng and java main classes etc. It just makes life easy


3)Project structure


  • src/main/java: This will ideally contain source code
  • src/test/java: This will contain all java code that runs automation
  • src/test/resources: This will contain our feature files
  • BlankStepDefs.java: This file contains the step definitions. We will explain below. There can be any number of such files with different names [java classes]
  • Hooks.java: I have put this class so that we can have @Before and @After hooks for cucumber in one place. This contains the code for pre and post conditions of every scenario run.
  • RunCukesTest.java: This file contains the logic that will kick off the cucumber scenarios and other cucumber options that might be required.
  • features: This folder contains all the feature files

No comments:

Post a Comment