简体   繁体   English

使用 IntelliJ IDEA - Ultimate Edition 的 Cucumber-js 未定义步骤参考

[英]Cucumber-js undefined step reference using IntelliJ IDEA - Ultimate Edition

Steps in feature file are highlighted saying:突出显示功能文件中的步骤说:

"Undefined step reference: The following elements are visible on "logIn" page less... ( Ctrl + F1 ) Inspection info: Highlights steps in Cucumber (or some other Gherkin) .feature files which do not have a matching step definitions. Use a quick-fix to automatically create a new step definition." “未定义的步骤参考:以下元素在“登录”页面上可见较少......( Ctrl + F1 )检查信息:突出显示黄瓜(或其他一些小黄瓜)中的步骤。特征文件没有匹配的步骤定义。使用自动创建新步骤定义的快速修复。”

Tests are running properly, but the problem is that I am unable to navigate from feature files to step definitions, which complicates my work.测试运行正常,但问题是我无法从功能文件导航到步骤定义,这使我的工作复杂化。

I've tried few of the solutions found here, but so far, nothing helped me.我已经尝试了一些在这里找到的解决方案,但到目前为止,没有任何帮助。

Here is additional info for the dependencies:以下是依赖项的附加信息:

"cucumber-html-reporter": "4.0.4", 
"cucumber-junit": "^1.7.1", 
"js-xlsx": "^0.8.22", 
"npm": "6.5.0", 
"selenium-server": "3.141.59" 
"chromedriver": "2.46.0", 
"cucumber": "^5.1.0", 
"cross-env": "^5.2.0", 
"cucumber-pretty": "^1.5.0", 
"geckodriver": "^1.14.1", 
"nightwatch": "^1.0.19", 
"nightwatch-api": "^2.1.1",

Thanks in advance!提前致谢!

Since I came up with a solution to my problem I'll provide more details.由于我想出了解决问题的方法,因此我将提供更多详细信息。

  1. Step definitions must be located in the default directory ' step_definitions ', otherwise they won't be recognized.步骤定义必须位于默认目录“ step_definitions ”中,否则将无法识别它们。 (mine was named 'step-definitions') (我的被命名为“步骤定义”)

  2. .feature files recognize only steps written as regular expressions .feature 文件仅识别编写为正则表达式的步骤

Mine were written like this: this.When('I log in as a regular user'我的是这样写的: this.When('我以普通用户身份登录'

Expected: this.When(/^I log in as a regular user$/预期: this.When(/^我以普通用户身份登录$/

Reference:参考:

https://youtrack.jetbrains.com/issue/WEB-15600 https://youtrack.jetbrains.com/issue/WEB-15600

and

https://youtrack.jetbrains.com/issue/WEB-11505 https://youtrack.jetbrains.com/issue/WEB-11505

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM