functional test for JavaScript
I really need your assistance.
I a开发者_如何学Pythonm developing a project and most of the code is written on JS (backbone.js and jquery). Could you please recommend me a tool/framework for functional testing?
I don't think that qunit or Jasmine meet the requirements of functional testing. I would like something like cucumber for Rails but which could handle a lot of JavaScript.
You could use http://casperjs.org/ a nice little library created for headless browser PhantomJS. It's a full webkit, so you have almost 100% real browser interaction.
If you prefer running it on Selenium, with multiple real browser instances, check geb : http://www.gebish.org/
Note that most of the JS test frameworks have problems with alert() and confirm() windows (some really dirty hacks are used to handle them), so you may need to resort to pure Selenium http://seleniumhq.org/. I'm still testing it, but SeleniumIDE handles alerts very well, so I think this will also be true for Selenium WebDriver. Selenium has bindings in many popular languages (no JS though), so I guess you'll find something that suits you.
If you consider using a framework for it, try JavascriptMVC:
http://javascriptmvc.com/
It does:
- Unit testing
- Functional testing
- Code cleaning
- Code generating
- Dependency management
And uses jQuery as a backbone. It's typically useful for middle to large JavaScript projects.
精彩评论