代码之家  ›  专栏  ›  技术社区  ›  Jakub Troszok

Cucumber:自动创建步骤文件?

  •  4
  • Jakub Troszok  · 技术社区  · 17 年前

    当我运行黄瓜时,它会显示 我应该定义的可能步骤,RSpec书中的一个例子:

    1 scenario (1 undefined)
    4 steps (4 undefined)
    0m0.001s
    You can implement step definitions for undefined steps with these snippets:
    Given /^I am not yet playing$/ do
      pending
    end
    When /^I start a new game$/ do
      pending
    end
    Then /^the game should say “Welcome to CodeBreaker”$/ do
      pending
    end
    Then /^the game should say “Enter guess:”$/ do
      pending
    end
    

    有没有一种方法可以自动创建步骤定义文件,这样我就不必了 手工重写或复制粘贴,但我可以对它们进行自定义,使其更通用?

    6 回复  |  直到 17 年前
        1
  •  3
  •   kevinrutherford    17 年前

    Cucumber不提供此功能。可能是因为你必须告诉它把步骤定义文件放在哪里,以及给它起什么名字。

        2
  •  3
  •   Aslak Hellesøy    16 年前

    正如Kevin所说,Cucumber必须知道文件的名称才能将其放入其中,除了使用与功能文件相同的文件名外,没有其他好的默认值。我认为这是一种反模式: http://wiki.github.com/aslakhellesoy/cucumber/feature-coupled-steps-antipattern

        3
  •  3
  •   DanLebrero    16 年前

    • 检测缺失的步骤定义
    • 在新文件(您选择文件名)或现有步骤定义文件中创建缺少的步骤定义
    • 突出显示匹配的步骤参数

    http://i48.tinypic.com/10r63o4.gif

    享受

        4
  •  1
  •   Sam Murray-Sutton    16 年前

        5
  •  0
  •   Moamen Sayed    12 年前

    试试这个 https://github.com/unxusr/kiwi 它会自动生成您的特征文件,并为您创建步骤定义文件,您只需用代码填写步骤即可。 在后续版本中,将自动编写步骤代码并运行测试

        6
  •  0
  •   Hussam Kurd    8 年前

    您可以使用变通方法生成步骤文件 您所要做的就是在没有定义步骤的功能上运行Cucumber,通过以下命令标识特定功能:

    1) 使用路径

    bundle exec cucumber {PATH}
    note path would start with features/....
    for example 
    features/users/login.feature
    

    1) 使用标签

    bundle exec cucumber --tags=@{TAG}
    note tag should be above your scenario in the steps file
    for example 
      @TAG
       Scenario:
    

    推荐文章