Cucumber.js
Feature source
Feature: Simple maths In order to do maths As a developer I want to increment variables Scenario: Increment variable once Given a variable set to 1 When I increment the variable by 1 Then the variable should contain 2
Step definitions
var Given = When = Then = this.defineStep; var variable; Given(/^a variable set to (\d+)$/, function(number, callback) { variable = parseInt(number); callback(); }); When(/^I increment the variable by (\d+)$/, function(number, callback) { variable += parseInt(number); callback(); }); Then(/^the variable should contain (\d+)$/, function(number, callback) { if (variable != parseInt(number)) throw(new Error('Variable should contain '+number+' but it contains '+variable+'.')); callback(); });
Output
Run feature
Errors