javascript QUnit 对比 Jasmine 和 TDD 对比。开发板
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18155477/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
QUnit Vs. Jasmine and TDD Vs. BDD
提问by Mims H. Wright
I've been looking at two libraries for doing unit tests on the front-end.
我一直在寻找两个用于在前端进行单元测试的库。
QUnit- http://qunitjs.com/
Jasmine- http://jasmine.github.io/
Jasmineis clearly more BDDfocused than QUnitalthough I could see doing BDD with QUnitby describing the tests in a behavior-oriented way. Both of them are able to run assertions on units of code so I think they're both unit tests. Is BDD mutually exclusive from TDD or is it all in how you write it?
Is unit testing necessary if you're doing behavior testing?Seems like if you cover all user stories, you don't really need to know the details of the testable units.
Are there any other testing frameworks you like?Are there other tests besides unit tests that are good for devs to do on the front-end?
QUnit- http://qunitjs.com/
茉莉花- http://jasmine.github.io/
茉莉显然更BDD的重点不是QUnit虽然我可以看到做BDD QUnit通过描述一个行为导向的方式测试。它们都能够对代码单元运行断言,所以我认为它们都是单元测试。BDD 与 TDD 是互斥的还是完全取决于您的编写方式?
如果您进行行为测试,是否需要单元测试?好像如果你涵盖了所有的用户故事,你真的不需要知道可测试单元的细节。
还有其他你喜欢的测试框架吗?除了单元测试之外,还有其他适合开发人员在前端进行的测试吗?
采纳答案by Seb Rose
BDD and TDD are not mutually exclusive. See Liz Keogh's post
Behavior testing should be understandable by business stakeholders. Unit testing is typically intended to be understood by technical team members (developers, testers etc.). For examples of how to make unit tests more readable you should look at the GOOSbook (although the examples are Java not Javascript).
Also, if you try to cover all test paths using BDD, your business people will get bored and stop caring.
Have a look at Cucumber-JS(a port of Cucumber).
BDD 和 TDD 并不相互排斥。见Liz Keogh 的帖子
业务利益相关者应该可以理解行为测试。单元测试通常旨在让技术团队成员(开发人员、测试人员等)理解。有关如何使单元测试更具可读性的示例,您应该查看GOOS书(尽管示例是 Java 而非 Javascript)。
此外,如果您尝试使用 BDD 覆盖所有测试路径,您的业务人员会感到无聊并不再关心。
回答by IainJMitchell
If you are looking at writing tests that involve DOM interactions I'd have a look at pageboy.js. This is a new project that provides a Domain Specific Language (DSL) for Javascript DOM interactions (a bit like Capybara which is used within Cucumber in Ruby), which is intended to make test code more readable.
如果您正在编写涉及 DOM 交互的测试,我会查看pageboy.js。这是一个新项目,为 Javascript DOM 交互提供了域特定语言 (DSL)(有点像在 Ruby 中的 Cucumber 中使用的 Capybara),旨在使测试代码更具可读性。
There is more on the background of this DSL here.
还有更多关于这个DSL的背景在这里。