Tôi không có đủ điểm để thêm nhận xét vào câu trả lời @jbpros, nhưng cần lưu ý rằng Scenario Outlines hiện đã hoàn tất trong cucumber.js như đã nêu here.
Ví dụ:
thế giới:
// 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;
Tính năng:
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 |
bước Definition:
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;
Nguồn
2014-05-08 03:28:24
bạn ấy có ý gì bằng cách kiểm tra tự động. Tôi hỏi nguyên nhân bạn đề cập đến Selenium, đó là để thử nghiệm tích hợp và Jasmine đó là để thử nghiệm đơn vị. –
Điều tôi muốn nói là tôi muốn thử nghiệm của mình chạy tự động mà không phải kiểm tra từng tính năng trong trình duyệt theo cách thủ công. Tôi nghĩ Jasmine là một công cụ BDD. – chchrist