有效的BDD场景步骤?给定->当->然后->什么时候 [英] Valid BDD Scenario Steps? Given -> When -> Then -> When

查看:83
本文介绍了有效的BDD场景步骤?给定->当->然后->什么时候的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果定义了以下步骤,那么此情况是否有效?我觉得这是某种气味.

If I have the following steps defined, is this valid scenario? I feel like it is some kind of smell.

Scenario: Change users status
   Given I have the following users exist:
        | code | status   |
        | u1   | active   |
        | u2   | inactive |
        | u3   | active   |
     And the status filter is "active"
    When I update "u1" to "inactive" 
    Then I should see the following users:
        | code |
        | u3   |
    When I change status filter to "inactive"
    Then I should see the following users:
        | code |
        | u1   |
        | u2   |

推荐答案

Liz关于描述系统功能是正确的.我还建议在场景中只有一个.因为每种情况(我认为)都应该验证系统在发生某些情况时从给定状态变为然后状态.

Liz is right about describing capabilities of system. I would also suggest to have only one When in scenario. Because each scenario (I think) should verify that system goes from Given state to Then state When something happens.

在这种情况下,我还建议具有两个不同的功能.关于您的应用程序可以更改用户状态(激活/停用)的一项功能:

In this case I also suggest to have two different features. One feature is about your application can change user status (activate/deactivate):

Feature: Changing user status

Scenario: Deactivating user
   Given following users exist:
        | code | status   |
        | u1   | active   |
        | u2   | inactive |
        | u3   | active   |
    When user u1 is deactivated
    Then following users exist:
        | code | status   |
        | u1   | inactive |
        | u2   | inactive |
        | u3   | active   |

另一个功能是关于您可以按状态过滤用户:

Another feature is about you can filter users by status:

Feature: Filtering users

Scenario: Filtering active users
   Given following users exist:
        | code | status   |
        | u1   | active   |
        | u2   | inactive |
        | u3   | active   |
    When I filter for active users
    Then I should see the following users:
        | code |
        | u1   |
        | u3   |

Scenario: Filtering inactive users
   Given following users exist:
        | code | status   |
        | u1   | active   |
        | u2   | inactive |
        | u3   | active   |
    When I filter for inactive users
    Then I should see the following users:
        | code |
        | u2   |

在这种情况下,如果其中一种情况被破坏,您将知道原因.它不是在更改用户状态,还是没有正确过滤用户.您知道您的应用程序中哪个功能已被破坏.

In this case when one of the scenarios is broken, you will know the reason. It's either not changing status of user, or not filtering them properly. You know which feature is broken in your application.

这篇关于有效的BDD场景步骤?给定->当->然后->什么时候的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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