使用javascript在黄瓜javascript中自动生成步骤

时间:2014-03-06 21:05:43

标签: cucumberjs

我正在使用javascript for cucumber javascript进行自动化。我关心的是我可以自动为步骤定义生成.js文件吗?截至目前我是从命令行窗口复制粘贴它们(步骤)所以我可以跳过它并直接生成步骤文件吗?

2 个答案:

答案 0 :(得分:2)

两个建议:

1。 您可以创建一个新的小黄瓜文件,并使用cucumber.js运行它,它会自动为您生成JavaScript存根。例如:

"cucumber-js math.feature"

它将输出如下内容:

...

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');
       });



 ...

它具有根据您的测试自动生成的参数。然后,您可以将代码段复制到代码文件中。

2。 如果您使用的是Windows 10,您还可以尝试使用BDD开发工具CukeTest,它提供了一些方便的功能,例如从步骤文本生成代码,或者在代码和步骤之间导航等。

答案 1 :(得分:-1)

您可以在IDE中使用“实时模板”/“代码段”。这是改善表现的最佳方式。  https://www.jetbrains.com/help/idea/creating-code-constructs-by-live-templates.html

如果你使用VC代码,那么你可以使用扩展Cucumber(Gherkin)语法和片段:

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

相关问题