我们如何处理BDD方案的次要排列? [英] How do we handle minor permutations of BDD scenarios?

查看:80
本文介绍了我们如何处理BDD方案的次要排列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很喜欢BDD的开发方法,但是我一直担心要走多远. ThoughtWorks的最新评论雷达让我停顿了:/p>

I'm loving the BDD approach to development, but I've bumped into a concern with how far to go. This comment from ThoughtWorks most recent Radar gives me pause:

行为驱动设计(BDD)测试框架(如Cucumber)的出现与诸如Selenium之类的浏览器自动化工具的结合,鼓励了在浏览器级别广泛使用验收测试.不幸的是,这鼓励了在成本较高的情况下进行大量测试.运行测试是最大的选择,相反,我们应该在尽可能接近代码的适当级别进行测试,以便可以以最高的效率运行测试,而浏览器级别的测试则应锦上添花,并得到以下方面的支持:在适当的层执行验收和单元测试."

"The advent of behavior-driven design (BDD) testing frameworks like Cucumber, combined with browser automation tools like Selenium, has encouraged widespread use of acceptance testing at the browser level. This unfortunately encouraged doing the bulk of testing where the cost to run the tests is the greatest. Instead, we should test at the appropriate level, as close to the code as possible, so that tests can be run with maximum efficiency. Browser-level tests should be the icing on the cake, supported by acceptance and unit tests executed at appropriate layers."

这是我的场景(双关语意):

So here's my scenario (pun intended):

我有一个基本的CRUD应用,该应用具有业务需求,可以根据允许最终用户选择的标准来过滤显示的数据.为了便于讨论,我们假设它是电力公司的应用程序,并且我正在显示每个客户当前每月的用电量.此应用的用户可以通过选择一个客户,多个客户,没有客户或所有客户"来缩小数据范围.显示的数据将根据选择的内容而改变.

I've got a basic CRUD app with a business requirement to filter the data displayed based on criteria the end user is permitted to select. For ease of discussion let's say it's an app for the power company, and I'm displaying current month-to-date power usage for each customer. The user of this app could narrow the data by selecting a single customer, multiple customers, no customers, or "All customers". The displayed data will change based on what they select.

对于产品利益相关者,这些确实代表了4个独立的场景.但是,从开发人员的角度来看,它们实际上是相同的,唯一的区别是传递给DB的参数.因此,问题就变成了:拼出每个排列的好处是否超过了运行和维护它们的成本?

For a product stakeholder, these really represent 4 separate scenarios. However from a developer perspective they are practially identical, with the only difference being a parameter passed to the DB. So the question becomes: does the benefit of having each permutation spelled out outweigh the cost of running and maintaining them?

我认为BDD原则可能会说是",因为预期行为的沟通更为明确,但我不确定.在我看来,它肯定带有过度杀伤力.场景可能是很多复制粘贴,并且有微小的更改.

I think BDD principles would probably say "yes" because the communication of the expected behavior is more explicit, but I'm not sure. It certainly has the feel to me of overkill. The scenarios would likely be a lot of copy-paste with minor changes.

我倾向于使用一种捕获核心业务价值的方案(当我选择一个客户时,我看到用电数据")来覆盖此功能,然后用一组非UI-来覆盖其他排列.验证服务/查询的基于集成的测试将返回正确的数据.这个想法错了吗?确保在不放弃BDD优势的情况下涵盖这些情况的最佳答案是什么?

My inclination is to cover this functionality with a single scenario that captures the core business value ("when I select a customer I see the power usage data"), and then cover the other permutations with a set of non-UI-based integration tests that validate the service/query returns the correct data. Is this thinking wrong? What's the best answer to making sure these scenarios are covered, without surrendering the benefits of BDD?

推荐答案

我对BDD的规则是,开发人员应该能够轻松地从所描述的任何行为中得出场景,如果不能,则用场景.

My rule for BDD is that the developers should easily be able to derive the scenarios from whatever behavior is described, and if they can't, illustrate the behavior with scenarios.

BDD在描述棘手的事物时最有用.在将专家知识传递给开发人员时,或者缩小行为范围,直到发现不确定性为止.在具有基本过滤器的CRUD应用程序中,行为确实很容易理解.

BDD is at its most useful when it's describing things that are tricky; either when passing expert knowledge to the developers, or narrowing down behavior until uncertainty is discovered. In a CRUD application with basic filters, behavior is really easy to understand.

您所描述的可能是最适合丹·诺斯(Dan North)的生姜蛋糕"模式的:采取其他方法的食谱,但行为的一个方面与另一方面不同(或者在这种情况下,其行为又一个易于理解的方面)行为方面).他还使用了复制粘贴功能,我特别怀疑这种行为.

What you're describing is probably best covered Dan North's "Ginger Cake" pattern: take the recipe for something else, but with one aspect of behavior different from another (or in this case with one additional, easy-to-understand aspect of behavior). He also uses copy-paste a bit, and I suspect particularly for this kind of behavior.

因此,您的倾向是完全正确的.如果要自动化,我可能只会自动化一个示例,让单元测试和集成测试涵盖其余部分.

So, your inclination is perfectly correct. If automating, I'd probably automate just one example and let unit and integration tests cover the rest.

我也想知道为什么要进行这个项目.必须有一些有趣的东西,否则它不会发生.发现这一点,这可能是开始讨论场景的好地方.

I'd also want to know why this project was being pursued. There has to be something interesting about it, or it wouldn't be happening. Find that, and it's probably a great place to start discussing scenarios.

这篇关于我们如何处理BDD方案的次要排列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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