BDD
行为驱动开发是关于开发团队和业务之间的对话。其中的功能文件和场景应始终与特定的业务需求、功能或能力相关,这意味着业务和开发团队在他们之间完全清楚所概述的内容。
举个例子:
Feature: Rewards for frequent flyers
As a frequent flyer
I should receive points to my account
So that I am more likely to book with BDD Airlines again in the future
Scenario: I get flyer miles
Given I book a flight
And this flight earns 100 miles
When I land
Then my account should have 100 miles added to it
问题是,这是否概述了整个问题,还是需要更多信息?开发团队是否能够使用这个对话来构建一些东西(正如你关于 SBE 的那样)?
这会更好吗?:
Feature: Rewards for frequent flyers
As a frequent flyer
I should receive points to my account
So that I am more likely to book with BDD Airlines again in the future
Scenario: Passenger gets flyer miles
Given the account number 12341234 has a ticket for the "LGW-MAN" flight
And this route earns 100 miles
And the ticket is scanned at "LGW"
When the flight lands at "MAN"
Then the account 12341234 is rewarded 100 miles
Scenario: Passenger missed their flight
Given the account number 12341234 has a ticket for the "LGW-MAN" flight
And this route earns 100 miles
And the ticket is not scanned at "LGW"
When the flight lands at "MAN"
Then the account 12341234 is not rewarded any miles
Scenario: Passenger gets kicked off the plane
Given the account number 12341234 has a ticket for the "LGW-MAN" flight
And this route earns 100 miles
And the ticket is scanned at "LGW"
But the ticket is removed from the flight
When the flight lands at "MAN"
Then the account 12341234 is not rewarded any miles
一切都是为了清晰,通常更多的是关于如何描述与业务相关的系统行为。
你的例子
我个人不会为了测试进度条而编写场景,因为业务不应该对所使用的任何组件的实现感兴趣(他们不关心加载栏,他们只关心实际的信息负载)。
在我看来,这作为一个单元测试会更好。