【问题标题】:CucumberOptions is not reading in Runner Class for java8CucumberOptions 未在 java8 的 Runner 类中读取
【发布时间】:2020-07-18 13:54:45
【问题描述】:

请任何人回答这个问题。

import org.junit.runner.RunWith;
//import io.cucumber.junit.CucumberOptions;
import cucumber.api.CucumberOptions;
import io.cucumber.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(
    features={"./src/test/java/featureFiles/feature.feature"}
    ,glue = {"stepDefs"}
    //,monochrome = true
    //,tags={"@tag1"}
//  ,dryRun=true
    //,strict = false
    //plugin = {"pretty", "html:test-output"}
    )

public class Test{
}

这里的“features”关键字不是读取特征文件的路径。并且“glue”关键字不是 stepDefination 的读取路径。因为,当我运行 Run As--> Junit Test 时。我得到了

  Apr 06, 2020 7:19:34 PM io.cucumber.junit.Cucumber <init>
WARNING: By default Cucumber is running in --non-strict mode.
This default will change to --strict and --non-strict will be removed.
You can use --strict or @CucumberOptions(strict = true) to suppress this warning
Apr 06, 2020 7:19:34 PM io.cucumber.core.runtime.FeaturePathFeatureSupplier get
WARNING: No features found at classpath:/com/packagePath

0 场景 0 步 0m0.000s

当我单击任何功能文件步骤时,我可以转到步骤定义实现的路径,但是当我从 Runner 类运行时,我看到了上面的消息。即使我将功能文件保存在 Runner 类的同一个包中并运行,我也会添加缺少的 sn-ps 代码。当我在 stepDefination 文件中添加缺少的 sn-ps 并将其保存在同一包或其他包中时,我无法看到结果。

我尝试了我所知道的所有方面。但我无法弄清楚这个问题。

【问题讨论】:

  • 将此用于功能选项 - {"src/test/java/featureFiles/feature.feature"}。将粘合代码放在 runner 包的同一个包或子包中,则无需提及显式粘合选项。

标签: cucumber


【解决方案1】:

第 3 行:

import cucumber.api.CucumberOptions;

删除它并替换为

import io.cucumber.junit.CucumberOptions;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-02-11
    • 2016-10-16
    • 1970-01-01
    • 2018-10-22
    • 1970-01-01
    • 2020-10-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多