【问题标题】:Why is my .feature file saying "Undefined step reference", although my cucumber tests run fine and detect the steps?为什么我的 .feature 文件显示“未定义的步骤参考”,尽管我的黄瓜测试运行良好并检测到步骤?
【发布时间】:2019-12-27 16:40:48
【问题描述】:

当我查看 .feature 文件时,Intellij 说我的步骤未定义。

Intellij undefined step

但是cucumber .feature 文件运行正常,在step上肯定是匹配的。

我的 TestNG 运行器代码:

package package1;

import io.cucumber.testng.AbstractTestNGCucumberTests;
import io.cucumber.testng.CucumberOptions;
import org.testng.annotations.DataProvider;

@CucumberOptions(plugin = "pretty", features = "src/test/resources/package1", glue = "package1")
public class Runner extends AbstractTestNGCucumberTests {

    @Override
    @DataProvider(parallel = true)
    public Object[][] scenarios() {
        return super.scenarios();
    }

}

特征文件中的步骤:

Feature: test feature
  Scenario: test feature scenario
  Given there has been a pebkac

我在 StepDefinitions 文件中的步骤:

Given("there has been a pebkac", () -> {
            //driver.findElement(By.id("editTextFieldId")).sendKeys("test");
            autoTools.getElement(new String[]{"editTextFieldId", "IOSIDHERE"}, AutomationTools.IdType.DEFAULT, 15).sendKeys("test");
            System.out.format("test: %n\n");

            //throw new cucumber.api.PendingException();
        });

为什么 intellij 抱怨找不到这一步?我尝试使用带注释的步骤定义文件,但遇到了同样的问题。

我注意到,如果我转到功能文件并右键单击 -> 添加步骤,它将使用已弃用的 Given 方法添加一个步骤。这让我觉得我可能使用了错误的依赖项,尽管我是从他们网站上的黄瓜教程中获得的。

我的依赖:

dependencies {
    testImplementation 'io.cucumber:cucumber-java:4.7.4'

    compile group: 'org.testng', name: 'testng', version: '6.14.3'
    compile group: 'io.cucumber', name: 'cucumber-testng', version: '4.7.4'
    compile group: 'io.appium', name: 'java-client', version: '7.1.0'
}

【问题讨论】:

    标签: java cucumber testng feature-file


    【解决方案1】:

    Intellij 已过时,更新它解决了这个问题。

    参考:https://sqa.stackexchange.com/q/40044

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-12
      • 1970-01-01
      • 2018-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多