如何使用 Cucumber 测试加载 javascript 的内容
我一直在开发 Rails 应用程序,并且决定混合实施测试驱动开发和行为驱动开发。
然而,我正在构建的应用程序使用名为 MochaUI 的 Web 应用程序用户界面框架,该框架构建在 Mootools 框架之上。
我刚刚完成了部分单元测试的编写,并开始测试用户界面;这就是我开始遇到问题的地方。
我想测试的很多东西是通过 javascript 加载的内容,一些数据加载到 iframe 中,一些数据加载到元素(ajax)中。
所以我写了一个测试
And I should see "Some text loaded into an iframe with javascript"
,正如你猜的那样,它失败了。我不知道从哪里开始解决这个问题,因为我对 TDD 和 BDD 很陌生,但我正在努力解决这个问题,任何人都可以给我一些指示或可能的解决方案,以便我晚上可以睡觉吗?
谢谢!
I've been developing a Rails application and I've decided to implement a mixture of Test Driven Development and Behavioral Driven Development.
However the application I am building uses a web application user interface framework known as MochaUI which is built on top of the Mootools framework.
I have just finished writing a portion of unit tests and have moved on to testing the user interface; which is where I start to run into problems.
A lot of the things I want to test is content that is loaded via javascript, some data is loaded into iframes, some data is loaded into elements (ajax).
So I wrote a test
And I should see "Some text loaded into an iframe with javascript"
And as you guessed, it failed. I don't know where to begin to fix this problem, as I am very new to TDD and BDD but I'm working my way there, can anyone give me some pointers or possibly a solution so I can sleep at night?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有用于 javascript 测试的 selenium...也许这会是一个提示?
请参阅http://github.com/aslakhellesoy/cucumber/wiki/Setting-up- Selenium
或
http://bddcasts.com /series/tools/episodes/using-selenium-with-webrat-and-cucumber
There is selenium for javascript-testing... Maybe this would be a tip?
see http://github.com/aslakhellesoy/cucumber/wiki/Setting-up-Selenium
or
http://bddcasts.com/series/tools/episodes/using-selenium-with-webrat-and-cucumber
使用capybara,用
@javascript
标记需要javascript的场景。Use capybara, tagging the scenarios that require javascript with
@javascript
.