黄瓜:如何使用多个场景大纲与一个示例? [英] Cucumber: How do I use Multiple Scenario Outlines with one Example?

查看:434
本文介绍了黄瓜:如何使用多个场景大纲与一个示例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Scenario Outline:
   blah blah

Scenarios:
 | col | col |
 | dat | dat |

Scenario Outline
  blah blah
  <use first scenarios table>

是一种方法吗?我不喜欢复制表... = \

is ther a way to do this? I'd hate to have to copy a table... =\

推荐答案

您使用的数据不应取决于该场景,所以如果你将数据从一个场景复制/粘贴到下一个场景没有什么大不了。我知道这不是DRY - 所以如果你复制数据多于几次,可以考虑使用工厂(见#2)。

The data you use shouldn't depend on the scenario, so it's no big deal if you copy/paste the data from one scenario to the next. I know this isn't DRY - so if you're copying the data more than a couple of times, consider using a Factory instead (see #2).


  1. 如果 blah blah 被实现为一个步骤定义,那么假设您在需要时可以重用它,这是
  2. 的一部分。
  3. 您的col / dat表可能可以被替换与工厂(通过FactoryGirl)。在Cucumber旁边使用FactoryGirl作为测试的一部分是很常见的。

  1. If blah blah is implemented as a step definition, then it's assumed that you'll reuse it when needed, that's partly what it's for
  2. Your col/dat table might be able to be replaced with a Factory (via FactoryGirl). It's pretty common to use FactoryGirl as part of your testing, alongside Cucumber.

这篇关于黄瓜:如何使用多个场景大纲与一个示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆