Navigating from Feature file to step defination: Any Plugins

谁说我不能喝 提交于 2020-05-17 08:07:09

问题


In visual studio cod, How to navigate from feature to step definition. Do we need any additional plugins or any configuration needs to be added. I have downloaded the Cucumber (Gherkin) Full Support plugin but still cannot navigate from .feature to the step definition.


回答1:


The documentation of Cucumber (Gherkin) Full Support plugin has the explanation for it.

You need to add the below in your settings:

{
"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 => provide the path of the step definitions. cucumberautocomplete.syncfeatures => provide the path of the feature files

After this(might be after a restart), cmd + click(on mac) would take to the step definition.

Thanks, Naveen




回答2:


Having installed the extension alexkrechik.cucumberautocomplete, I tried modifying the settings from both the UI of the extension and its corresponding settings JSON (by default, mine were in ~/.config/Code/User/settings.json). But this didn't work because I got this error in the *.feature files: Was unable to find step for "Some feature description".

I noticed I had skipped a step mentioned in the extension docs... By default, it was getting the settings.json from my userspace and not my work(project)space.

For me, the solution was to go to the root directory of my project (usually outside of /src, where you have the package.json and node_modules/) and create a .vscode/ folder. Then, create a settings.json file and paste there the cucumberautocomplete configuration with the paths relative to this brand new file.

Below I show a schema:

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

An example of configuration would be:

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

Note that you could use **/*.steps.ts and **/*.feature paths but every time the extension settings file changes, when you Ctr + Click on a feature description, you will need to wait for the editor to resolve the paths. Otherwise, there is no waiting time.



来源:https://stackoverflow.com/questions/55363967/navigating-from-feature-file-to-step-defination-any-plugins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!