如何在黄瓜特征中进行for循环?

时间:2022-07-18 00:13:25

I have a set of preferences I want to test the exact same tests for, and make sure they all behave appropriately. So, the for loop would iterate over each preference configuration, and run the same set of tests is the previous and next iteration. *With IF statements of course, so tests that don't apply to the current configuration don't need to be tested.

我有一组首选项,我想测试完全相同的测试,并确保它们都表现得恰当。因此,for循环将迭代每个首选项配置,并且运行相同的一组测试是上一次和下一次迭代。 *当然,使用IF语句时,不需要测试不适用于当前配置的测试。

Is there a way to do this / something similar?

有没有办法做到这一点/类似的东西?

I'm using rails 2.3.8

我正在使用rails 2.3.8

3 个解决方案

#1


3  

It sounds like you want cucumber example tables, where you can enumerate all your Preference values you want to test the same behavior of:

听起来你想要黄瓜示例表,在那里你可以枚举你想要测试相同行为的所有Preference值:

Given I have a preference defined
When I do some thing
Then I should see this behavior

Examples:
  | preference | label_name |
  | foo        | It's Foo!  |
  | bar        | So bar...  |

Here's a link to a tutorial using table based examples for testing like this:

这是一个教程的链接,使用基于表格的示例进行测试,如下所示:

http://asciicasts.com/episodes/159-more-on-cucumber

#2


3  

Cucumber has a concept called Scenario Outlines that is used to describe a scenario that needs to be run repeatedly with differing data.

Cucumber有一个名为Scenario Outlines的概念,用于描述需要使用不同数据重复运行的场景。

#3


2  

This sounds like something you use a scenario outline for:

这听起来像你使用场景大纲:

https://github.com/cucumber/cucumber/wiki/Scenario-outlines

#1


3  

It sounds like you want cucumber example tables, where you can enumerate all your Preference values you want to test the same behavior of:

听起来你想要黄瓜示例表,在那里你可以枚举你想要测试相同行为的所有Preference值:

Given I have a preference defined
When I do some thing
Then I should see this behavior

Examples:
  | preference | label_name |
  | foo        | It's Foo!  |
  | bar        | So bar...  |

Here's a link to a tutorial using table based examples for testing like this:

这是一个教程的链接,使用基于表格的示例进行测试,如下所示:

http://asciicasts.com/episodes/159-more-on-cucumber

#2


3  

Cucumber has a concept called Scenario Outlines that is used to describe a scenario that needs to be run repeatedly with differing data.

Cucumber有一个名为Scenario Outlines的概念,用于描述需要使用不同数据重复运行的场景。

#3


2  

This sounds like something you use a scenario outline for:

这听起来像你使用场景大纲:

https://github.com/cucumber/cucumber/wiki/Scenario-outlines