【问题标题】:Automatic Step Generation in cucumber javascript using javascript使用javascript在黄瓜javascript中自动生成步骤
【发布时间】:2014-03-06 21:05:43
【问题描述】:

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

【问题讨论】:

    标签: cucumberjs


    【解决方案1】:

    两个建议:

    1。 您可以创建一个新的 gherkin 文件,并使用 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');
               });
    

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

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

    【讨论】:

      【解决方案2】:

      您可以在 IDE 中使用“实时模板”/“代码 sn-ps”。这是提高性能的最佳方式。 https://www.jetbrains.com/help/idea/creating-code-constructs-by-live-templates.html

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-11-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多