最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

What's the best way to do integration testing for a Javascript heavy UI in a rails app? - Stack Overflow

programmeradmin7浏览0评论

We have a web application that makes extensive use of AJAXy Javascript in the UI. We have nearly plete code coverage of our backend using Shoulda and Webrat, and would like to extend our test suite to include full integration testing through the Javascript UI.

We tried Selenium but found it brittle and temperamental. Are there more reliable options?

UPDATE

For those still checking this out, we ended up using Xvfb so we can run Firefox without a screen. Allows us to run the test on a headless Jenkins CI server. We still have to run tests "live" locally occasionally to debug, but it works pretty well.

We have a web application that makes extensive use of AJAXy Javascript in the UI. We have nearly plete code coverage of our backend using Shoulda and Webrat, and would like to extend our test suite to include full integration testing through the Javascript UI.

We tried Selenium but found it brittle and temperamental. Are there more reliable options?

UPDATE

For those still checking this out, we ended up using Xvfb so we can run Firefox without a screen. Allows us to run the test on a headless Jenkins CI server. We still have to run tests "live" locally occasionally to debug, but it works pretty well.

Share Improve this question edited Jan 19, 2012 at 2:03 Joshua asked Apr 5, 2011 at 23:53 JoshuaJoshua 5,5141 gold badge29 silver badges44 bronze badges
Add a ment  | 

5 Answers 5

Reset to default 3

One of the JavaScript gurus where I work recently pointed out PhantomJS as an interesting tool for testing our JavaScript-heavy web applications. We haven't tried it out yet but the idea of a headless WebKit for DOM testing sounds promising to me.

This is something I have been wrestling with for a while, as I am doing some work with ExtJS (a very powerful JavaScript UI builder for the browser) and Rails.

After having researched quite a few different options. I still haven't found a perfect solution for it. Ideally, I would be able to run them headless and just report on the output. Unfortunately, none of the emulators out there seem to be able to run JavaScript with full DOM support seamlessly (at least, none of the options I've found are). So that pretty much means that you have to run your full-powered JavaScript code in a real interpreter (such as a browser). Webrat with Selenium works acceptably well, assuming you're willing to deal with the pain of trying to path out your requests to the UI properly. If it's your own JavaScript that you're implementing it against, that may be easier. But when it es to a third party UI library that you don't have much control over, it can certainly get, shall we say, interesting.

Probably not the most helpful response, but that has been my findings up to now!

Hmm I would give Capybara a look, it can use selenium-webdriver (not to be confused with selenium-RC, they are different) for javascript testing. I haven't found it very brittle when pared with Webrat... it seems to be fairly consistent.

As Chris Rueber says, there aren't really any headless DOM interpreters that support JS as well - for now it's fire up a web browser for your automation or write unit tests in the javascript itself (Which isn't really integration testing either).

When you have a lot of selenium-webdriver-backed tests they can take awhile to run sometimes, but it's surely better than no tests at all.

check out the gem jasminerice to test your js logic.

https://github./bradphelan/jasminerice

for the integration test I would remend to use rspec with capybara as acceptance tests. distinguish request specs and acceptance specs! another possibility is to use turnip as an alternative to cucumber.

https://github./jnicklas/turnip

to speed up your tests test headless. You could use capybara-webkit (depends on qt) or poltergeist (which depends on phantomjs). both are easily to set up. I prefer poltergeist.

There are a couple of gems you could use if you didn't like Selenium.

The one I remend is Jasmine: https://github./pivotal/jasmine

You can also check out Culerity: https://github./langalex/culerity

发布评论

评论列表(0)

  1. 暂无评论