Given <a context>
When <an event happens>
Then <an outcome occurs>
您可以使用任意数量的给定、何时和那么。
Given <a context>
And <another context>
When <an event happens>
Then <an outcome occurs>
And <another outcome occurs>
When <another event happens>
Then <yet another outcome>.
We use BDD scenarios, which describe the system's capabilities from a user point of view. We phrase them as:
Given <a context>
When <an event happens>
Then <an outcome occurs>
You can use any number of givens, whens and thens.
Given <a context>
And <another context>
When <an event happens>
Then <an outcome occurs>
And <another outcome occurs>
When <another event happens>
Then <yet another outcome>.
The BA usually writes these for us, but I've seen devs or testers write them in collaboration with analysts or business stakeholders.
You can either use a BDD framework like Cucumber, SpecFlow or JBehave to automate them, or the devs can implement them with a little DSL. Here's an example. This is a real scenario which runs against the GUI of a little C# pet shop.
The thing I love most about scenarios is that you can have conversations about different things that the system should do, asking if different contexts change the outcomes, whether there are any other important outcomes which have been missed, etc. Those conversations then generate new examples.
We don't automate everything, but we automate enough to show how the system behaves and give us a good chance of catching something breaking. For instance, we might show one or two pieces of validation but not check that everything is validated; that can then be done at a unit test level.
The scenarios are then also readable enough for a tester to follow them, and because we generate them before we implement the code, we get better estimates and higher quality code too. Off-shore teams have really benefited from having clear scenarios and the freedom to ask questions about them.
发布评论
评论(1)
我们使用BDD场景,它从用户的角度描述系统的能力。我们将它们表述为:
您可以使用任意数量的给定、何时和那么。
BA 通常为我们编写这些内容,但我见过开发人员或测试人员与分析师或业务利益相关者合作编写它们。
您可以使用 Cucumber、SpecFlow 或 JBehave 等 BDD 框架来自动化它们,或者开发人员可以使用一点 DSL 来实现它们。 以下是示例。这是一个针对 小型 C# 宠物店 GUI 运行的真实场景。
我最喜欢场景的一点是,你可以就系统应该做的不同事情进行对话,询问不同的环境是否会改变结果,是否有任何其他重要的结果被遗漏,等等。然后这些对话会生成新的示例。
我们不会把所有事情都自动化,但我们的自动化程度足以显示系统的行为方式,并让我们有很好的机会发现有问题的东西。例如,我们可能会显示一两个验证部分,但不会检查所有内容是否都经过验证;然后可以在单元测试级别完成。
这些场景对于测试人员来说也具有足够的可读性,可以遵循它们,并且因为我们在实现代码之前生成它们,所以我们也获得了更好的估计和更高质量的代码。离岸团队确实受益于清晰的场景和提出相关问题的自由。
We use BDD scenarios, which describe the system's capabilities from a user point of view. We phrase them as:
You can use any number of givens, whens and thens.
The BA usually writes these for us, but I've seen devs or testers write them in collaboration with analysts or business stakeholders.
You can either use a BDD framework like Cucumber, SpecFlow or JBehave to automate them, or the devs can implement them with a little DSL. Here's an example. This is a real scenario which runs against the GUI of a little C# pet shop.
The thing I love most about scenarios is that you can have conversations about different things that the system should do, asking if different contexts change the outcomes, whether there are any other important outcomes which have been missed, etc. Those conversations then generate new examples.
We don't automate everything, but we automate enough to show how the system behaves and give us a good chance of catching something breaking. For instance, we might show one or two pieces of validation but not check that everything is validated; that can then be done at a unit test level.
The scenarios are then also readable enough for a tester to follow them, and because we generate them before we implement the code, we get better estimates and higher quality code too. Off-shore teams have really benefited from having clear scenarios and the freedom to ask questions about them.