SpecFlow / BDD 与 ASP.NET MVC

发布于 2024-09-12 03:34:52 字数 625 浏览 0 评论 0原文

我是 BDD 的新手,我正在尝试使用 SpecFlow 制定出一种高效、有组织且可维护的方法(用于在 ASP.NET MVC 中使用)。我需要改进的主要领域是:

  • 步骤分组(到步骤文件中)

  • 重用测试对象(就像在单元测试中很容易通过继承测试基类等)

  • 文件夹结构

在分组时,让我们看一下典型的CRUD场景。例如:

  • 我的项目中每个“区域”的文件夹,例如公共、站点管理

  • 内部的功能文件夹和步骤文件夹其中每个

然后,在这些文件夹中,我有一个功能文件,涵盖特定实体(例如 NewsItem)的整个 CRUD 体验。我采用这种方式,以便可以在我的步骤中重用对象和 NewsController。

但这意味着步骤文件变得相当庞大,涵盖了所有类型的有效、无效输入可能性,并且很难从头到尾遵循一种场景。但如果不这样做,我就无法重用整个 CRUD 流程中可能适用于多种场景的步骤。

我知道这是非常主观的,我不怕被许多不同的想法和观点所淹没 - 这就是我想要的:P

以及你自己的意见和观点。偏好、博客和书籍的链接会很好。

谢谢尼克

I'm new to BDD, and using SpecFlow I'm trying to work out an efficient, organised, and maintainable methodology(for use within ASP.NET MVC). The main areas I need to improve on are:

  • Grouping of steps (into step files)

  • Reusing test objects (like it is so easy to in unit tests by inheriting test base classes etc)

  • Folder structure

when it comes to grouping, let's take a typical CRUD scenario. For example:

  • a folder for each "area" in my project eg public, site management

  • a feature folder and step folder inside each of those

And then, inside those folders I've got one Feature file covering the whole CRUD experience for a certain entity e.g NewsItem. I've gone this way so that I can reuse objects and the NewsController in my steps.

But this means the step files get pretty huge covering all types of valid, invalid input possibilites and it is very hard to follow one scenario through all the way through. But if I don't, I can't reuse the steps that may be applicable to multiple scenario in the whole CRUD process.

I understand this is very subjective, and I'm not afraid to be overwhelmed by a number of different ideas and perspectives - that's what I want :P

As well as your own opinions & preferences, links to blogs and books would be good.

Thanks

Nick

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷乱花海 2024-09-19 03:34:54

抱歉,很久没有人回答这个问题了。如果它对您仍然有用,这可能会有所帮助。

我将我的步骤保持在非常高的水平:请参阅这个问题 Rspec 中的命令式和声明式步骤< /a>

我按关注领域对步骤进行分组。想象一下登录并执行一些操作,然后再次注销。或者也许回家一天。我在一次会议中可能做的任何事情都会成为我关注的一个领域。例如,如果我是宠物店老板,我可能有步骤文件:处理库存宠物、处理配件和其他库存、销售商品、跟踪利润等。

我还有一个屏幕/页面范例,类似于 WebDriver。这意味着,如果一个步骤实际上在 UI 上执行多项操作,则有一个屏幕或页面可以处理所有这些操作。

我经常使用级联构造函数来允许我的 BDD 工具(在我的例子中是普通的旧式 NUnit)为我创建这些步骤和场景。我一直在编写一个小型自动化工具,您可以在其示例中看到其中一些技术:

http://code.google.com/p/wipflash/source/browse/Example.PetShop.Scenarios/PetRegistrationAndPurchase.cs

我没有搞砸太多SpecFlow 还没有,但我想这些可能对你有用。我在 JBehave 或 Fitnesse.NET 和 FitSharp 中也使用过相同的设计模式。

祝你好运!有一个 BDD 群组 http://groups.google.com/group/behaviordrivendevelopment 可能会有所帮助如果您需要更多信息,请联系您。

Sorry nobody has answered this for ages. If it's still useful to you, this might help.

I keep my steps at a very high level: see this question Imperative and declarative steps in Rspec

I group steps by areas of concern. Imagine logging in and performing some action, then logging out again. Or maybe going home for the day. Anything which I might do in one session becomes one area of concern. For instance, if I am a pet shop owner, I might have step files for: handling pets in stock, handling accessories and other stock, selling items, tracking profit, etc.

I also have a screen / page paradigm rather like WebDriver. This means that if a step actually does several things on the UI, there is one screen or page which handles all of those actions.

I often use cascading constructors to allow my BDD harness (in my case, plain old NUnit) to create these steps and scenarios for me. I've been writing a little automation tool and you can see some of these techniques in its examples:

http://code.google.com/p/wipflash/source/browse/Example.PetShop.Scenarios/PetRegistrationAndPurchase.cs

I haven't messed around much with SpecFlow yet, but I imagine these might be useful to you. It's the same design pattern that I've also used with JBehave or Fitnesse.NET and FitSharp.

Good luck! There's a BDD group http://groups.google.com/group/behaviordrivendevelopment which might help you if you need more info.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文