错误:使用示例时无法创建方案运行器

时间:2018-07-02 03:13:27

标签: selenium automation cucumber bdd

我正在使用“示例”输入电子邮件,但是当我运行junit运行程序文件时,出现错误消息:

"  Failed to create scenario runner"

我的 Junit 运行程序代码:

package Runner;

import org.junit.runner.RunWith;


import cucumber.api.junit.Cucumber;
import cucumber.api.junit.Cucumber.Options;

@RunWith(Cucumber.class)
@Options(features="Features",glue={"stepdefinition"})


public class GmailRunner {

}

这是我的功能文件:

    Feature: Smoke test of Gmail


@GmailSignin
  Scenario Outline: Click on Sign in
    Given Open chrome 
    When  I go to gmail and  click on Sign in
    When I enter "<emailid>" 
    Then I  click on next

Examples:
    | emailid |
    | sarveshsingh.03 |    

我正在使用 Cucumber-junit-1.1.2 junit-4.11

请帮助

2 个答案:

答案 0 :(得分:0)

cumber-junit-1.1.2中已弃用

@Options 。您应该使用@CucumberOptions并在其中提供标签名称。

@CucumberOptions(features = "relative/path/to/your/featureFile.feature",
        tags = "@GmailSignin",
        format = { "pretty",
        "html:target/site/cucumber-pretty",
        "rerun:target/rerun.txt",
        "json:target/cucumber1.json" })

答案 1 :(得分:0)

这是pom依赖项...如果您使用的是纯Java,请从maven存储库下载这些版本并包含它们。

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
    </dependency>

    <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>gherkin-jvm-deps</artifactId>
            <version>1.0.4</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>gherkin</artifactId>
            <version>5.0.0</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>tag-expressions</artifactId>
            <version>1.1.1</version>
        </dependency>

    <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.12.0</version>
        </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>3.0.2</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java8</artifactId>
        <version>3.0.2</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>3.0.2</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-picocontainer</artifactId>
        <version>3.0.2</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-core</artifactId>
        <version>3.0.2</version>
    </dependency>
  </dependencies>

这是跑步类。更改功能和胶水值以适合您的环境。

@RunWith(Cucumber.class)
@CucumberOptions(features="src/test/resources/features/gmail.feature",glue={"stepdef"}, dryRun=false)
public class GmailRunner {

}