Automatic Step Generation in cucumber javascript using javascript

狂风中的少年 提交于 2021-02-07 12:24:16

问题


I am using javascript for cucumber javascript for automation.My concern is can i generate .js file for step definitions automatically? as of now am copy pasting them(steps) from command line window so can I skip it and directly generate the step file?


回答1:


Two Suggestions:

1. You can create a new gherkin file, and run it with cucumber.js, it will generate JavaScript stub automatically for you. For example:

"cucumber-js math.feature"

It will output something like:


    1) Scenario: easy maths - math.feature:7
   
    Step: Given a variable set to 1 - math.feature:8
   
    Message:

     Undefined. Implement with the following snippet:

           this.Given(/^a variable set to (\d+)$/, function (arg1, callback) {
             // Write code here that turns the phrase above into concrete actions
             callback(null, 'pending');
           });

It has the parameter automatically generated based on your tests. You can then copy the snippet into your code file.

2. If you are using Windows 10, you can also try a BDD development tool CukeTest, and it provide some convenient features like code generation from step text, or navigate between code and steps etc.




回答2:


You can use 'Live Template'/'Code snippets' in your IDE. It's the best way to improve performace. https://www.jetbrains.com/help/idea/creating-code-constructs-by-live-templates.html

If you use VC Code then you can use extension Cucumber (Gherkin) Syntax and Snippets:

https://marketplace.visualstudio.com/items?itemName=stevejpurves.cucumber



来源:https://stackoverflow.com/questions/22235948/automatic-step-generation-in-cucumber-javascript-using-javascript

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