黄瓜在IntelliJ中的未定义步骤引用

huangapple go评论111阅读模式
英文:

Cucumber undefined step reference in Intellij

问题

我在Intellij 2019.2.4 Ultimate中遇到了问题,无法从Cucumber特性文件导航到粘合代码。Intellij抱怨"未定义的步骤引用"。然而,通过控制台或运行配置执行cucumber测试是成功的。

Cucumber版本5.5.0
Junit版本4.13

根据类似报告的问题,我迄今为止尝试过以下方法:

  • 验证已启用了Cucumber for Java和Gherkin插件
  • 使缓存无效并重新启动IDEA
  • 验证SubSteps插件未启用并与Cucumber for Java插件冲突
  • 重新启用Cucumber for Java插件

为了说明我的问题,我生成了一个简单的项目:

src/test/java/hellocucumber

package hellocucumber;

import io.cucumber.junit.CucumberOptions;
import io.cucumber.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
        plugin = {"pretty", "html:target/cucumber"},
        features = {"src/test/resources/hellocucumber"},
        glue={"hellocucumber"},
        monochrome = true
)
public class RunCucumberTest {
}

我的粘合代码:

package hellocucumber;

import io.cucumber.java.en.Given;

public class StepDefinitions {

    @Given("today is Monday")
    public void today_is_Monday() {
        System.out.println("Today is monday");
    }
}

以及我的特性文件:
src/test/resources/hellocucumber/test.feature

Feature: This is a test

  Scenario: Today is or is not Friday
    Given today is Monday

Intellij抱怨缺少粘合代码:

黄瓜在IntelliJ中的未定义步骤引用

我迷茫了,非常感谢您的一些意见。谢谢

编辑:
上传了项目OneDrive

另请注意,如果我将cucumber版本从5.5.0降级到5.x.x之前(例如4.8.1),我就能从特性导航到粘合代码!

英文:

I have problem with Intellij 2019.2.4 Ultimate where I am unable to navigate from Cucumber feature file to glue code. Intellj is complaining of "Undefined Step Reference". Executing the cucumber test from console or via run configuration is however successfull.

Cucumber version 5.5.0
Junit version 4.13

Based on similary reported issues, this is what I have tried so far:

  • Verified that both Cucumber for Java and Gherkin plugins are enabled
  • Invalidate cache and restarted IDEA
  • Verified that SubSteps plugin is not enabled and in conflict with Cucumber for Java plugin
  • Reenable Cucumber for Java plugin

To illustrate my problem I have generated a simple project:

src/test/java/hellocucumber

package hellocucumber;

import io.cucumber.junit.CucumberOptions;
import io.cucumber.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
        plugin = {"pretty", "html:target/cucumber"},
        features = {"src/test/resources/hellocucumber"},
        glue={"hellocucumber"},
        monochrome = true
)
public class RunCucumberTest {
}

my glue code

package hellocucumber;

import io.cucumber.java.en.Given;

public class StepDefinitions {

    @Given("today is Monday")
    public void today_is_Monday() {
        System.out.println("Today is monday");
    }
}

and my feature file:
src/test/resources/hellocucumber/test.feature

Feature: This is a test

  Scenario: Today is or is not Friday
    Given today is Monday

Intellij complain of missing glue code:

黄瓜在IntelliJ中的未定义步骤引用

I am lost and would much appreciate some input. Thanks

EDIT:
Uploaded project<a href="https://1drv.ms/u/s!AkkQjQvpQNm7geVRfvHmk6sQFTTABw?e=d6QYKs">OneDrive</a>

Also note, if I downgrade cucumber version from 5.5.0 to pre 5.x.x (e.g. 4.8.1) I am able to navigate from feature to glue!

答案1

得分: 3

这个项目在IntelliJ IDEA 2019.3.3中正常工作,请考虑更新,如果您正在使用最近的Cucumber版本。

黄瓜在IntelliJ中的未定义步骤引用

英文:

This project works fine in IntelliJ IDEA 2019.3.3, please consider updating if you are using the recent Cucumber version.

黄瓜在IntelliJ中的未定义步骤引用

huangapple
  • 本文由 发表于 2020年3月17日 03:50:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/60712374.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定