Cucumber | Selenium Forum
M
Posted on 20/05/2016
Why I script was showing error--could you please check
package com.selenium.cucumber;

import cucumber.api.java.en.And;
import cucumber.api.java.en.But;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;

public class Tester {

@Given("^I am a [a-zA-z]{1,} tester$")
public void I_am_a_bad_tester(){
System.out.println("@Given-I am a bad tester");
}

@When("^I go to work$")
public void I_go_to_work(){
System.out.println("@When-I go to work");
}

@Then("^I [a-zA-Z]{1,} it$")
public void I_mess_with_it(){
System.out.println("@Then-I mess it");

}

@And("^my boss [a-zA-Z]{1,} me$")
public void my_boss_fires_me(){
System.out.println("@And=my boss fires me");

}
@But("^the developer [a-zA-Z]{1,} me$")
public void the_developer_likes_me(){
System.out.println("@But-the developer likes me");
}

}
-------------------------------------------------------------------------------------------------------------------------------<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.selenium.cucumber</groupId>
<artifactId>com.cucumber</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>com.cucumber</name>
<url>http://maven.apache.org</url>

<properties>
<cucumber-jvm.version>1.1.2</cucumber-jvm.version>
<selenium.version>2.53.0</selenium.version>
<junit.version>4.11</junit.version>
</properties>




<build>

<!--testResources>
<testResource>
<directory>src/main/resources</directory>
<includes>
<include>log4j.properties</include>
</includes>
</testResource>
</testResources-->


<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>integration-test</phase>

<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<executableDependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
</executableDependency>

<mainClass>cucumber.api.cli.Main</mainClass>
<arguments>
<argument>--format</argument>
<argument>junit:target/cucumber-junit-report/allcukes.xml</argument>
<argument>--format</argument>
<argument>pretty</argument>
<argument>--format</argument>
<argument>html:target/cucumber-html-report</argument>
<argument>--glue</argument>
<argument>com/</argument>
<argument>src/</argument>

</arguments>
</configuration>
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>




</build>

<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>${cucumber-jvm.version}</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber-jvm.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.1.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>




</dependencies>




</project>

M
Replied on 21/05/2016

check all the jar files. this error is caused by jar files version mismatch.

if you can paste exception here. i can tell you what is the problem.


M
Replied on 26/05/2016

Could you please tell the location of new cucumber jars in code or what kind of jars I need to change.I have send the error screen shot.
It was telling the initialization error.
Thank you Ashish.

Responsive image

M
Replied on 26/05/2016

i misread the error the problem is there is not feature file in project.


M
Replied on 28/05/2016

There is a feature file in my project too.

Responsive image

M
Replied on 30/05/2016

zip and upload you project here.