我应该在单元测试级别使用 Specflow 吗?
可能的重复:
用于单元测试的 SpecFlow/BDD?
在过去的几年里,我一直在使用 TDD 进行工作NUnit/Moq,在过去的几个月里,我一直在使用 mSpec 来掌握 BDD。
到目前为止一切顺利,但我们现在希望更多地进行基于验收标准的测试,其中业务分析师参与其中,并且我们在开发过程中获得了外部机会。
现在我们已经预定义了 Gherkin 语法文件,并且使用 Specflow 感觉这是正确的工作方式。
然而,在单元测试级别上预定义 Gherkin 文件将违背我对 TDD 的理解。换句话说,你的设计是随着你的行为而长期发展你的设计的。
由于我们正在使用由外向内的方法,现在在单元测试级别,我们现在是否拥有可用于驱动我的单元测试的规范/行为(只是感觉这与我一直在进行 TDD 的方式相悖) )?
早些时候,这些文件对于验收测试很重要,但作为一名开发人员,我将单独工作,因此除非我使用 SpecFlow,否则它们不是必需的。
另外,当我们使用 mspec 时,维护 GWT 文件在单元测试级别会有什么好处?开发人员应该能够直接跳入代码并阅读测试,或者只是运行测试运行程序来查看它在做什么。
TIA 京东
Possible Duplicate:
SpecFlow/BDD for Unit Tests?
Over the last few years I have worked in TDD using NUnit/Moq and over the last few months I have been getting to grips with BDD using mSpec.
So far so good but we now want to move more into acceptance criteria based tests where the business analysts are involved and we get an outside in development process.
So now we have predefined Gherkin syntax files and with specflow it feels the right way to work.
However, at a unit test level having predefined Gherkin files would go against what I understand about TDD. In other words, you design as you go a long evolving your design with behaviour.
As we are working using the outside in approach, now at unit test level could it be that we now have the specifications/behaviors that can now be used to drive my unit tests (just feels like it is against the way I have been doing TDD)?
Earlier these files were important for acceptance tests but as a developer I will work alone so they are not necessary unless I use SpecFlow.
Also what benefit would we have at a unit test level having GWT files maintained when we are using mspec? Developers should be able to just jump into the code and read the tests or just run the test runner to see what it is doing.
TIA
JD
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的自然回答是否定的。BDD
以及 Specflow 和 Cucumber 等工具的主要好处是与项目的利益相关者进行沟通,并对要构建的内容达成共识。
TDD 的主要好处是通过解决方案实施采取小步骤,确保您构建可维护且出色的代码。
或者如果你愿意的话; BDD 是为了确保我们构建正确的东西,TDD 是为了确保我们构建正确的东西。
前几天我在我的博客上回答了这样的问题,如果你想了解更多细节; http://www.marcusoft.net/2011/11/bdd -and-technical-scenarios.html
My spontaneous answer is No.
Tha main benefit of BDD and tools like specflow and Cucumber is communication with the stakeholders of the project and creating a shared understanding of what is to be built.
The main benefit of TDD is to take small steps through a solutions implementation, ensuring that you build maintainable and great code.
Or if you want; BDD is about ensuring that we're building the right thing, TDD is about ensuring that we're building it right.
I answered a question like this the other day on my blog, if you want more details; http://www.marcusoft.net/2011/11/bdd-and-technical-scenarios.html