Reputation:
I've investigated this issue from different sides, but didn't get anywhere so far. I have a project that runs selenium driver on JUnit using Cucumber for Java. I use Maven. Here's my TestRunner that runs the test:
package com.task.lab;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(features = "C:\\Users\\admin\\IdeaProjects\\bddtesting\\src\\test\\java\\com\\task\\lab\\features",
glue = "C:\\Users\\admin\\IdeaProjects\\bddtesting\\src\\test\\java\\com\\task\\lab\\steps")
public class TestRunner {
}
Here's feature file:
Feature: Login to Gmail
Scenario Outline: login compose and delete letter
Given: User is on SignIn page
When: User enters <Email> and <Password>
Then: User sends letter to <Receiver> and alert is displayed letter is sent
Examples:
|Email |Password |Receiver
|[email protected] |okokokokok |[email protected]
|[email protected] |okokokokok |[email protected]
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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.task.lab.bddtesting</groupId>
<artifactId>bddtesting</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<version>1.2.5</version>
<type>pom</type>
</dependency>
</dependencies>
And finally my Steps.Defs class:
package com.task.lab.steps;
import com.task.lab.decorator.bo.businessobjects.GmailMessage;
import com.task.lab.decorator.bo.businessobjects.Login;
import com.task.lab.driver.DriverObject;
import com.task.lab.propertyreader.ReadPropertyFile;
import cucumber.api.java.After;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class StepDefs {
private Login login = new Login();
@Given("^User is on SignIn page$")
public void openSignInPage(){
LOG.info("Logging in");
DriverObject.getDriver();
DriverObject.getDriver().get(ReadPropertyFile.readGmailURL());
}
@When("^User enters (\\S+) and (\\S+)$")
public void enterCredentials(String email, String password) throws Throwable {
login = new Login();
login.login(email, password);
}
@Then("^User sends letter to (\\S+) and alert is displayed letter is sent$")
public void composeLetter(String receiver){
GmailMessage gmail = new GmailMessage();
gmail.sendMessage(receiver);
}
@After
public void closeBrowser(){
DriverObject.releaseThread();
}
}
When I try to run the TestRunner from the window I get the error No tests were found. As I investigated priorly, the reason for this could be that I run Test Unit, not Main class. So I reconfigured Intelij Setting for this project to run from Cucumber for Java and specified the Main class as cucumber.api.cli.Main
. However, this gives me another error Test framework quit unexpectedly
. I also tried running features file only and in this case tests are green but in fact, no scenarios or steps are passed, as the output in the console shows:
0 Scenarios
0 Steps
0m0,000s
I also reinstalled my Intelij to Ultimate version, but the result is just the same. Could someone please help me see what I am doing wrong?
Upvotes: 1
Views: 3446
Reputation:
So, as I suspected the issue was minor. In my future file I removed ":" and closed my table with vertical lines "|":
Feature: Login to Gmail
Scenario Outline: login compose and delete letter
Given User is on SignIn page
When User enters <Email> and <Password>
Then User sends letter to <Receiver> and alert is displayed letter is sent
Examples:
|Email |Password |Receiver |
|[email protected] |okokokokok |[email protected]|
|[email protected] |okokokokok |[email protected]|
Worked like a charm.
Upvotes: 1