【问题标题】:Navigating from Feature file to step defination: Any Plugins从功能文件导航到步骤定义:任何插件
【发布时间】:2019-03-26 18:26:35
【问题描述】:

在 Visual Studio cod 中,如何从功能导航到步骤定义。我们是否需要任何额外的插件或需要添加任何配置。我已经下载了 Cucumber (Gherkin) Full Support 插件,但仍然无法从 .feature 导航到步骤定义。

【问题讨论】:

    标签: javascript selenium visual-studio-code webdriver-io gherkin


    【解决方案1】:

    Cucumber (Gherkin) Full Support插件的文档有说明。

    您需要在设置中添加以下内容:

    {
    "cucumberautocomplete.steps": [
        "test/features/step_definitions/*.js",
        "node_modules/qa-lib/src/step_definitions/*.js"
    ],
    "cucumberautocomplete.syncfeatures": "test/features/*feature",
    "cucumberautocomplete.strictGherkinCompletion": true
    }
    

    cucumberautocomplete.steps => 提供步骤定义的路径。 cucumberautocomplete.syncfeatures => 提供功能文件的路径

    在此之后(可能是在重新启动之后),cmd + click(在 mac 上)将进入步骤定义。

    谢谢, 纳文

    【讨论】:

    • 感谢 Naveen,我在 setting.json 中添加了代码,但仍然无法正常工作
    • 能否请您提供您的 user settings 值:仅供参考,这是我所拥有的:{ "workbench.sideBar.location": "left", "npm-intellisense.packageSubfoldersIntellisense": true, "editor .multiCursorModifier”:“alt”,“window.zoomLevel”:0,“workbench.statusBar.visible”:true,“workbench.activityBar.visible”:true,“cucumberautocomplete.steps”:[“step-definitions/*. js", "step-definitions/*.ts" ], "cucumberautocomplete.syncfeatures": "features/*.feature" } 忽略其他设置。我的 vscode 是1.25.1 版本
    【解决方案2】:

    安装了扩展程序alexkrechik.cucumberautocomplete 后,我尝试从扩展程序的 UI 及其相应的 JSON 设置中修改设置(默认情况下,我的在 ~/.config/Code/User/settings.json 中)。但这不起作用,因为我在 *.feature 文件中遇到了这个错误:Was unable to find step for "Some feature description"

    我注意到我跳过了扩展文档中提到的步骤...默认情况下,它从我的用户空间而不是我的工作(项目)空间获取settings.json

    对我来说,解决方案是转到我的项目的根目录(通常在/src 之外,您有package.jsonnode_modules/)并创建一个.vscode/ 文件夹。然后,创建一个settings.json 文件并将cucumberautocomplete 配置粘贴到该全新文件的relative 路径。

    下面我展示了一个架构:

    myProject/
    ├── node_modules
    ├── package.json
    ├── subdir1
    │   ├── src
    │   └── test
    │       └── e2e
    │           └── src
    │               ├── features
    │               │   └── myfeature1.feature
    │               ├── mypageobject1.po.ts
    │               └── steps
    │                   └── mystep1.step.ts
    └── .vscode
        └── settings.json
    

    配置示例如下:

    {
        "editor.detectIndentation": false,
        "window.zoomLevel": 0,
        "cucumberautocomplete.steps": [
            "subidr1/test/e2e/src/steps/*.steps.ts"
        ],
        "cucumberautocomplete.syncfeatures": "subidr1/test/e2e/src/feature/*.feature"
    }
    

    请注意,您可以使用**/*.steps.ts**/*.feature 路径,但每次扩展设置文件更改时,当您在功能描述上Ctr + Click 时,您将需要等待编辑器解析路径。否则,没有等待时间。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-23
      • 1970-01-01
      • 1970-01-01
      • 2022-09-28
      相关资源
      最近更新 更多