Reputation: 21
I am learning BDD in cucumber-eclipse. I have downloaded all the jar's but still eclipse is saying it couldn't find definition for rest of the text.
Feature: Login
Scenario: Successful Login with valid Credentials
Given user is on Homepage
When user enters Username and Password
Then He can visit the practice page
In above code, it couldn't find glue codes for below text:
Upvotes: 0
Views: 2552
Reputation: 138
Check these Options
Option 1: Make sure you ran the code as Cucumber feature and get the skeleton generated with help of cucumber plugin
In your case, Cucumber will print like this
//Print start
@Given("^user is on Homepage$")
public void user_is_on_Homepage() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@When("^user enters Username and Password$")
public void user_enters_Username_and_Password() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Then("^He can visit the practice page$")
public void he_can_visit_the_practice_page() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
//Print End
Create package features.stepDefinitions and then create class file "ABC.java" with above generated skeleton. Proceed to Option 2
Option 2
If below class is the Runner, we need to have the glue of the feature file folder. Usually it will be in resources folder
package test.runner
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
@CucumberOptions(
features="src/test/resources/features/featureFileFolder",
glue = { "features.stepDefinitions"},
tags={"@UI"},
monochrome=true)
public class Runner{
}
Finally execute the runner file as Junit Test
Note:
Tag UI is something we will use to link scenario and annotations.
In this case feature file will be written as.
@UI
Scenario: Successful Login with valid Credentials
Given user is on Homepage
When user enters Username and Password
Then He can visit the practice page
Hope this may help!
Upvotes: 0
Reputation: 4323
The simplest possible start is to download or clone a getting started project by the Cucumber team https://github.com/cucumber/cucumber-java-skeleton
Run it using Maven or Gradle. When you have it running, and it runs out of the box, then add Eclipse to the mix.
Upvotes: 1