支持自动化测试的主干JS应用程序的BDD
Which BDD for backbone JS applications that supports automated testing
我正在构建一个Backbone应用程序,需要进行自动化测试。我不喜欢在自动化测试中使用硒。
我正在研究Jasmine和Cucumber.js。我认为Jasmine可能更好,但在我工作的公司,他们使用黄瓜进行服务器端测试,我正在调查Cucumber.js是否可以用于生产。
有什么建议吗?
Cucumber.js非常稳定,可以在生产中使用。与Cucumber ruby相比,它缺少一些高级功能,比如场景轮廓和(现在可用)转换。有关开发状态表,请参阅自述文件。
它可以与Zombie.js、Phantom.js、Selenium一起使用,甚至可以在浏览器中使用。实际上,您可以在Cucumber步骤定义中使用任何断言/测试库。
正如Andreas所指出的,Jasmine是针对单元测试/规范的,而Cucumber是一个验收测试工具(涉及整个应用程序堆栈)。
如果您在开始使用Cucumber.js时需要帮助,请随时ping我(@jbpros在Twitter上,jbpro在Freenode/#Cucumber上)。
我没有足够的分数给@jbpros答案添加注释,但需要注意的是,场景大纲现在已经在cucumber.js中完成了,如下所述。
例如:
世界:
// features/support/world.js
var zombie = require('zombie');
var World = function World(callback) {
this.browser = new zombie(); // this.browser will be available in step definitions
this.visit = function(url, callback) {
this.browser.visit(url, callback);
};
callback(); // tell Cucumber we're finished and to use 'this' as the world instance
};
exports.World = World;
特点:
Scenario Outline: eating
Given there are <start> cucumbers
When I eat <eat> cucumbers
Then I should have <left> cucumbers
Examples:
| start | eat | left |
| 12 | 5 | 7 |
| 20 | 5 | 15 |
| 200 | 65 | 135 |
| 200 | 5 | 194 |
步骤定义:
var aTest = function () {
this.World = require("../support/world.js").World;
this.start = 0;
this.eat = 0;
this.Given(/^there are ('d+) cucumbers$/, function(number, next) {
this.start = parseInt(number);
callback();
});
this.When(/^I eat ('d+) cucumbers$/, function (number, next) {
this.eat = parseInt(number);
callback();
});
this.Then(/^I should have ('d+) cucumbers$/, function (number, next) {
var left = this.start - this.eat;
if ( left != number)
callback.fail(new Error("This test didn't pass, I started with: " + this.start
+ ", ate: " + this.eat
+ " and was left with: " + left
+ ". Expected: " + number));
callback();
});
};
module.exports = aTest;
busterjs和jstestdriver都可以在自己的服务器上启动测试页面。你所要做的就是自动启动浏览器并打开测试页面。测试将在浏览器中运行,并将结果报告回服务器,在那里say可以以maven可读的格式保存。请注意,Jasmine 还有一个maven插件
相关文章:
- Canvas Html5绘图应用程序,移动画布会导致重大问题
- Emberjs应用程序加载在除Index之外的所有路由上
- 使用电话间隙在Android应用程序中显示SQL Lite的数据
- 在AngularJS应用程序中使用封装指令和路由的推荐方式是什么
- Windows8应用程序(html&Javascript):从图片库(除了文件选择器)显示图像的另一种方式
- angular 1.5应用程序中的导航栏
- 在Web应用程序中使用Highcharts javascript
- angularjs+rails应用程序中未显示模板
- 使用acess代币登录Facebook,并通过网络应用程序离线发布
- 从HTTPGET返回一个自定义对象列表,以便在Angular 2应用程序中使用
- 科尔多瓦页面类应用程序中的多个谷歌地图
- 使用谷歌应用程序脚本将服务器端数据表返回到客户端
- Angularjs-utils高亮过滤器在搜索时破坏应用程序
- 在phonegap应用程序内部重定向不起作用
- 使用谷歌应用程序脚本从工作表中获取值并将其显示在文本框中
- MockJax没有在JavaScript应用程序中发送对我AJAX请求的响应
- Node.js正在更改应用程序以使用集群模块
- 在openshift node js应用程序中获取请求
- 如何在Facebook上的iframe应用程序中使后退按钮返回到上一页
- 支持自动化测试的主干JS应用程序的BDD