Creating a cucumber project in
eclipse
1 .
Create a maven
project in eclipse using following link.
2.
Add the below
dependencies in your pom.xml.
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.1.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.1.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.41.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.39.0</version>
</dependency>
3.
The project
structure would be as shown below.
4.
Here in the project
structure, we need to add the below things :
a)
src/main/java –
Write your java code.
b)
src/main/resources –
Place your resource file in this folder.
c)
src/test/java –
Place your test code in this folder.
d)
src/main/resources –
Place your test resources in this folder.
5.
For a cucumber
project you need
a)
Feature File
b)
Step Definitions
c)
Runner file
6.
Now first create the
feature file under src/main/resources folder.
Steps to create feature file is as below:
a)
Right click on the src/main/resources
folder and create a new file.
b)
Create a file with
extension .feature. Name the file as HelloStepsDefs.feature
c)
Now write the
Gherkin language code in the feature file.
Feature: Hello World
Scenario: Say hello
Given I have a hello app with "Hello"
When I ask it to say hi
Then it should answer with "Hello
World"
7.
Now run the feature
file directly. Right click on the feature file and run as à cucumber feature. You will get an error as below.
9.
Copy the above steps
and to add the java code this can invoke the steps written in the feature file.
Steps to write
the java code
a)
Right click on src/test/java
and create a new class file. This class file will be step definition file.
package test.cucumber;
import junit.framework.Assert;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class HelloStepDefs {
@Given("^I
have a hello app with Hello$")
public
void I_have_a_hello_app_with_Hello() throws Throwable {
System.out.println(" I have a app which
says hello");
}
@When("^I
ask it to say hi$")
public
void I_ask_it_to_say_hi() throws Throwable {
System.out.println("
I say Hi");
}
@Then("^it
should answer with Hello World$")
public
void it_should_answer_with_Hello_World() throws Throwable {
System.out.println("
It answers with Hello World");
}
}
10.
To create reports
and run the test easily. Now create a runner file in src/main/java folder
structure.
a)
Right click on src/main/java
and create a new class file. This class file will be the runner file. Name the
class as RunCukesTest
b)
Write the below code
in the runner file.
package test.cucumber;
import
cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
// Associates Cucumber-JVM with the
JUnit runner
@RunWith(Cucumber.class)
@CucumberOptions(format =
{"html:target/cucumber-html-report",
"json:target/cucumber-json-" +"report.json"})
public class RunCukesTest {
}
11.
Now run the runner
file as Run as -- > Junit Test case. You will see the below result.
1 12.
You will see results
and reports in target folder of the project. You can find the HTML reports in
the folder structure of your project
Eg : D:\Workspace\cucumber-jvm\target\cucumber-html-report\
Open the
index.html. It looks like report as shown below.
I hope your Testing tools content has unique identity across the world. Each and every blog in your website is very informative users. I am eagerly waiting for the next content.
ReplyDeleteQtp training institutes in chennai
Qtp training Chennai
awesome post presented by you..your writing style is fabulous and keep update with your blogs Ruby on Rails Online Course Bangalore
ReplyDeleteThanks you for sharing this unique useful information content with us. Really awesome work. keep on blogging
ReplyDeletejava training in omr
java training in annanagar | java training in chennai
java training in marathahalli | java training in btm layout
java training in rajaji nagar | java training in jayanagar
Thanks for the informative article. This is one of the best resources I have found in quite some time. Nicely written and great info. I really cannot thank you enough for sharing.
ReplyDeleterpa training in marathahalli
rpa training in btm
rpa training in kalyan nagar
rpa training in electronic city
rpa training in chennai
rpa training in pune
rpa online training
I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
ReplyDeleteData Science training in btm
Data Science training in rajaji nagar
Data Science training in chennai
Data Science training in kalyan nagar
Data Science training in electronic city
Data Science training in USA
selenium training in chennai
selenium training in bangalore
I have picked cheery a lot of useful clothes outdated of this amazing blog. I’d love to return greater than and over again. Thanks!
ReplyDeletepython training in annanagar
python training in chennai
python training in chennai
python training in Bangalore
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeleteDevops Training in pune
Devops Training in Chennai
Devops training in sholinganallur
Devops training in velachery
Devops training in annanagar
Devops training in tambaram
Your story is truly inspirational and I have learned a lot from your blog. Much appreciated.
ReplyDeleteangularjs Training
in chennai
angularjs Training in chennai
angularjs-Training in tambaram
angularjs-Training in sholinganallur
angularjs-Training in velachery
ReplyDeleteHello. This post couldn’t be written any better! Reading this post reminds me of my previous roommate. He always kept chatting about this. I will forward this page to him. Fairly certain he will have a good read. Thank you for sharing.
AWS Training in Bangalore |Best AWS Training Institute in Bangalore BTM, Marathahalli
AWS Training in Chennai | AWS Training Institute in Chennai Velachery, Tambaram, OMR
Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
ReplyDeleteBest Selenium Training in Chennai | Selenium Training Institute in Chennai | Besant Technologies
You truly did more than visitors’ expectations. Thank you for rendering these helpful, trusted, edifying and also cool thoughts on the topic to Kate.
ReplyDeletebest safety course in chennai
Fantastic work! This is the type of information that should follow collective approximately the web. Embarrassment captivating position Google for not positioning this transmit higher! Enlarge taking place greater than and visit my web situate
ReplyDeleteangularjs online training
apache spark online training
informatica mdm online training
devops online training
aws online training
Very well written blog and I always love to read blogs like these because they offer very good information to readers with very less amount of words....thanks for sharing your info with us and keep sharing.
ReplyDeleteMicrosoft Azure online training
Selenium online training
Java online training
Java Script online training
Share Point online training
Your very own commitment to getting the message throughout came to be rather powerful and have consistently enabled employees just like me to arrive at their desired goals.
ReplyDeleteBest PHP Training Institute in Chennai|PHP Course in chennai
Best .Net Training Institute in Chennai
Dotnet Training in Chennai
Dotnet Training in Chennai
such a great word which you use in your article and article is amazing knowledge. thank you for sharing it.
ReplyDeleteSoftgen Infotech is the Best SAP HANA Training in Bangalore located in BTM Layout, Bangalore providing quality training with Realtime Trainers and 100% Job Assistance.
Thank you for writing such a great articles
ReplyDeleteSelenium corporate training
Automation Testing Training in Marathahalli
Selenium realtime training with projects
Best Selenium Training in Bangalore
Selenium Software Training in Bangalore
Manual testing training in bangalore
Best Selenium Training Institute in Bangalore
Selenium Training in Marathahalli
Selenium Training in Bangalore
Automation Testing Training in Marathahalli
Automation Testing Training in Bangalore
Selenium Training in Bangalore
Cucumber Training in Marathahalli
Cucumber Training in Bangalore
Java Selenium Automation Training in Bangalore
Selenium Training in Marathahalli
Manual testing training in bangalore
Software Testing Training in Bangalore
Selenium Software Training in Bangalore
This is a nice article here with some useful tips for those who are not used-to comment that frequently. Thanks for this helpful information I agree with all points you have given to us. I will follow all of them.
ReplyDeleteweb designing training in chennai
web designing training in tambaram
digital marketing training in chennai
digital marketing training in tambaram
rpa training in chennai
rpa training in tambaram
tally training in chennai
tally training in tambaram
Such a very useful information!Thanks for sharing this useful information with us. Really great effort.
ReplyDeleteangular js training in chennai
angular js training in annanagar
full stack training in chennai
full stack training in annanagar
php training in chennai
php training in annanagar
photoshop training in chennai
photoshop training in annanagar
Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.
ReplyDeletehadoop training in chennai
hadoop training in omr
salesforce training in chennai
salesforce training in omr
c and c plus plus course in chennai
c and c plus plus course in omr
machine learning training in chennai
machine learning training in omr
Thank you for posting informative insights, I think we have got some more information to share with! Do check out
ReplyDeleteoracle training in chennai and let us know your thoughts. Let’s have great learning!
Thank you for posting informative insights, I think we have got some more information to share with! Do check out
ReplyDeleteoracle dba training in chennai and let us know your thoughts. Let’s have great learning!
Grab the Digital Marketing Training in Chennai from Infycle Technologies, the best software training institute, and Placement center in Chennai which is providing professional software courses such as Data Science, Artificial Intelligence, Cyber Security, Big Data, Java, Hadoop, Selenium, Android, and iOS Development, DevOps, Oracle, etc with 100% hands-on practical training. Dial 7502633633 to get more info and a free demo and to grab the certification for having a peak rise in your career.
ReplyDeleteThis comment has been removed by the author.
ReplyDelete