BDD-每个方案都应该独立吗? [英] BDD - should each scenario be self contained?

查看:57
本文介绍了BDD-每个方案都应该独立吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有包含多个方案的BDD功能.每个方案都应该完全独立并且可以单独运行吗?

I have a BDD feature containing multiple scenarios. Should each scenario be completely self contained and runnable individually?

推荐答案

应该是,是的.通常,在所有形式的TDD(包括BDD)中都是一种好的做法,以确保每个测试"都可以独立运行,并且不与先运行的另一个测试耦合或依赖.这将有助于避免创建脆弱的测试套件(即容易损坏的套件).

Should be, yes. It is generally good practise in all forms of TDD (BDD included) to make sure that each "test" can run independently, and isn't coupled with or have a dependency on another test having been run first. This will help avoid creating a brittle test suite (i.e. one that is prone to breaking).

这并不是说您不能将可读性链接在一起.一个非常便宜/快速的例子:

That's not to say that you cannot chain readability together. For a very cheap/quick example:

Feature: Users can register and log in


Scenario: Should be able to register
Given I am not registered
When I complete the registration form
Then I will be registered

Scenario: Should be able to log in
Given I am registered
When I correctly sign-in with my credentials
Then I will be logged in

Scenario: Should be able to log out
Given I am logged in
When I sign-out
Then I will be logged out

每种情况都表明可以自动进行测试-每项测试都应在后台进行设计以能够独立运行.但是作为该功能的读者(例如业务利益相关者),该过程是完整的,他们可以更轻松地了解整个情况.

Each scenario indicates a test that can be automated - and each should be designed behind the scenes to be able to run independently. But as a reader of the feature (say a business stakeholder) - the process is complete and they can understand the entire picture more easily.

这篇关于BDD-每个方案都应该独立吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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