Please follow initial steps mentioned on below link for cucumber integration with Maven.
https://sagarthakare1.wordpress.com/2015/05/15/cucumber-setup-with-maven/
Once you are done with all steps then follow below steps
you will get below output
Feature: Login
@smoke
Scenario: Login Functionality # features/login.feature:4
Given User details # TestSuit.user_details()
When UI submits the User data # TestSuit.ui_submits_the_User_data()
Then return Message user is authenticated # TestSuit.return_Message_user_is_authenticated()
1 Scenarios (1 passed)
3 Steps (3 passed)
0m0.841s
Process finished with exit code 0
Below is output from cucumber.xml file
https://sagarthakare1.wordpress.com/2015/05/15/cucumber-setup-with-maven/
Once you are done with all steps then follow below steps
1) Add Junit Jar
Add Junit jar dependency in your Pom.xml file or add this jar to your project build path.2) Create Junit
Create TestRunner class in same package and cucumber option on class using annotationpackage features;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(format = {
"pretty",
"json:target_json/cucumber.json",
"junit:taget_junit/cucumber.xml"
})
public class TestRunner {
}
3) Run junit
Right click in class and run as Junit.you will get below output
Feature: Login
@smoke
Scenario: Login Functionality # features/login.feature:4
Given User details # TestSuit.user_details()
When UI submits the User data # TestSuit.ui_submits_the_User_data()
Then return Message user is authenticated # TestSuit.return_Message_user_is_authenticated()
1 Scenarios (1 passed)
3 Steps (3 passed)
0m0.841s
Process finished with exit code 0
4) Cucumber Reporting
We have added below on Junit class@CucumberOptions(format = {
"pretty",
"json:target_json/cucumber.json",
"junit:taget_junit/cucumber.xml"
})
It will generate reports in target_json and taget_junit folder,Below is output from cucumber.xml file
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <testsuite failures="0" name="cucumber.runtime.formatter.JUnitFormatter" skipped="0" tests="1" time="0.84123"> <testcase classname="Login" name="Login Functionality" time="0.84123"> <system-out><![CDATA[Given User details..........................................................passed When UI submits the User data...............................................passed Then return Message user is authenticated...................................passed ]]></system-out> </testcase> </testsuite>Below is output from cucumber.json
[
{
"id": "login",
"description": "",
"name": "Login",
"keyword": "Feature",
"line": 1,
"elements": [
{
"id": "login;login-functionality",
"tags": [
{
"name": "@smoke",
"line": 3
}
],
"description": "",
"name": "Login Functionality",
"keyword": "Scenario",
"line": 4,
"steps": [
{
"result": {
"duration": 841194605,
"status": "passed"
},
"name": "User details",
"keyword": "Given ",
"line": 5,
"match": {
"location": "TestSuit.user_details()"
}
},
{
"result": {
"duration": 17376,
"status": "passed"
},
"name": "UI submits the User data",
"keyword": "When ",
"line": 6,
"match": {
"location": "TestSuit.ui_submits_the_User_data()"
}
},
{
"result": {
"duration": 17850,
"status": "passed"
},
"name": "return Message user is authenticated",
"keyword": "Then ",
"line": 7,
"match": {
"location": "TestSuit.return_Message_user_is_authenticated()"
}
}
],
"type": "scenario"
}
],
"uri": "features/login.feature"
}
]
No comments:
Post a Comment