I am new to cucumber and this is first sample I am working on.
Cucumber set up is done. I ran the cucumberrunner class and feature file was picked and ran gave me the error to add missing implementation.But when I add a class with the detail methods. I get syntax error. Not able to understand the error:
Feature file:
Feature: Calculator
Scenario: Login
Given user is on home page
When user navigates in home page
And user enters '<Username>' and '<Password>'
Then Message displayed as successful
|Username | Password |
| triptitest | sleep345|
Cucumber file
import org.junit.runner.RunWith;
import cucumber.api.junit.Cucumber;
import cucumber.api.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(
glue = "stepdefinition"
,features = "Feature/calculator.feature"
)
public class cucumberunner {
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
POM xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxxxxx.bdd</groupId>
<artifactId>cucumber-test</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>XXXXX</name>
<url>XXXXX</url>
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
Testrunner file
package stepdefinition;
import cucumber.api.PendingException;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.*;
public class stepdefinition_test {
public static void main(String[] args) {
@Given("^user is on home page$")
public void user_is_on_home_page() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@When("^user navigates in home page$")
public void user_navigates_in_home_page() 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("^Message displayed as successful$")
public void message_displayed_as_successful() throws Throwable {
// Write code here that turns the phrase above into concrete actions
// For automatic transformation, change DataTable to one of
// List<YourType>, List<List<E>>, List<Map<K,V>> or Map<K,V>.
// E,K,V must be a scalar (String, Integer, Date, enum etc)
throw new PendingException();
}
}
}