Java 如何在不使用Cucumber中的大纲的情况下多次运行同一场景?

Java 如何在不使用Cucumber中的大纲的情况下多次运行同一场景?,java,cucumber,cucumber-jvm,Java,Cucumber,Cucumber Jvm,考虑以下情况: Scenario Outline: Execute a template Given I have a <template> when I execute the template Then the result should be successful. Examples: | template | | templateA | | templateB | 场景大纲:执行模板 考虑到我有一个 当我执行模板时 那么结果应该是成功的。

考虑以下情况:

Scenario Outline: Execute a template
 Given I have a <template>
 when I execute the template
 Then the result should be successful.
 Examples:
   | template  |
   | templateA |  
   | templateB |  
场景大纲:执行模板
考虑到我有一个
当我执行模板时
那么结果应该是成功的。
示例:
|模板|
|templateA|
|模板b|
因此,这将使用表中提到的值运行上述场景大纲。但这需要我提前知道需要执行的所有模板,并将它们填入表中。有没有办法动态加载模板列表,然后为每个模板执行场景

这种方法的优点是,无论何时添加新模板,我都不需要更新特性测试


谢谢

是的,将模板列表放在步骤定义中,或者更好地放在应用程序中。然后你就可以写了

  Scenario: Execute all templates
    When I execute all the templates
    Then there should get no errors
有趣的是如何实现这一点。比如:

module TemplateStepHelper
  def all_templates
    # either list all the templates here, or better still call a method in 
    # the app to get them
    ...
  end
end
World TemplateStepHelper

When "I execute all the templates" do
  @errors = []
  all_templates.each do |t|
    res = t.execute
    @errors << res unless res
  end
end

Then "there should be no errors" do
  expect(@errors).to be_empty
end
模块模板Stephelper
定义所有模板
#在这里列出所有模板,或者最好还是在中调用一个方法
#该应用程序可以获取它们
...
结束
结束
世界模板Stephelper
当“我执行所有模板”时
@错误=[]
所有模板。每个模板都有|
res=t.execute
@错误