我如何随机化黄瓜的步骤顺序?

时间:2018-06-13 15:34:52

标签: testing random cucumber scenarios

如何随机化最快的方法/方式?:

 Scenario Outline: As an Piet i can delete users
    Given the user is logged in as 'Piet'
    Given the menu item 'user management' is selected
    When the user '<username>' is deleted
    Then the notification panel contains the message 'Deze gebruiker is 
  succesvol verwijderd.'
    And the notification panel contains no errors

#randomize order of delete

    Examples: User accounts to delete
      | username      |
      | hans          |
      | piet          |
      | kees          |
      | jan           |

我希望Cucumber支持这样的事情: (但显然它没有,至少还没有)

 Scenario Outline: As an Piet i can delete users
    Given the user is logged in as 'PIET'
    Given the menu item 'user management' is selected
    When the user '<username>' is deleted
    Then the notification panel contains the message 'Deze gebruiker is 
 verwijderd.'
    And the notification contains no errors

#randomize order of delete

    Examples: User accounts to delete
      | username [RANDOM] |
      | hans              |
      | piet              |
      | kees              |
      | jan               |

那么以随机顺序运行这些步骤的最佳方法是什么?

2 个答案:

答案 0 :(得分:0)

Scenario Outline: As an Piet i can delete users
  Given there are <users_left> users for deletion
  And the user is logged in as 'PIET'
  And the menu item 'user management' is selected
  When a user is deleted
  Then the notification panel contains the message 'Deze gebruiker is verwijderd.'
  And the notification contains no errors

 Examples: User accounts left to delete
  | users_left |
  | 4          |
  | 3          |
  | 2          |
  | 1          |

使用此方法,您可以确保有用户要删除,然后您只需在步骤a user is deleted

中删除随机用户

答案 1 :(得分:0)

你想在这里证明什么?如果你可以删除用户,你真的需要浪费宝贵的运行时删除其他用户吗?为什么不简化和简化,也许用

def station_stats(df):

frequent_stations = df.groupby(['Start Station'])['End Station'].value_counts().mode
print('Most frequent start and end station: ', frequent_stations)

黄瓜方案意味着简单并有助于发展行为。它们不是用于随机化或进行大量测试。如果你想这样写一个单元测试,它应该更便宜,更快。