Permalink
Browse files

Improved runtime error handling of cucumber runner

- Features now continue on error so you can run multiple files
- timeout feature to step running
Improved logging output for cucumber runner
- Print error and pending step information
- Can now accept directory names for running features
Added bin to package.json
  • Loading branch information...
1 parent 527b9c0 commit 9cdc4037fc803be4b1186a2a973b1cb8c0ea1391 @pacovell pacovell committed Oct 4, 2011
Showing with 260 additions and 57 deletions.
  1. +31 −11 bin/kyuri
  2. +1 −1 examples/complex.feature
  3. +224 −44 lib/kyuri/runners/cucumber.js
  4. +4 −1 package.json
View
@@ -48,7 +48,6 @@ var _loadJavascripts = function (directory, steps) {
if (!fullPath.match(/^\//)) {
fullPath = path.join(root, fullPath);
}
- console.log('Loaded ' + fullPath);
exported = require(fullPath);
if (exported && exported.forEach && steps) {
exported.forEach(function (obj) {
@@ -72,13 +71,28 @@ var steps = [];
var directories = [];
argv.forEach(function (file) {
- if (file.match(featureFileExt)) {
- // Load envDirs first and without steps
- if (directories.indexOf(path.dirname(file)) === (-1)) {
- directories.push(path.dirname(file));
+ var stat = fs.statSync(file),
+ files;
+
+ if (stat.isDirectory()) {
+ files = fs.readdirSync(file);
+ for (var i = 0; i < files.length; i++) {
+ // Add the path
+ files[i] = path.join(file, files[i]);
}
- features.push(kyuri.parse(fs.readFileSync(file).toString()));
+ } else {
+ files = [file];
}
+
+ files.forEach(function (file) {
+ if (file.match(featureFileExt)) {
+ // Load envDirs first and without steps
+ if (directories.indexOf(path.dirname(file)) === (-1)) {
+ directories.push(path.dirname(file));
+ }
+ features.push(kyuri.parse(fs.readFileSync(file).toString()));
+ }
+ });
});
directories.forEach(function (top) {
@@ -96,13 +110,19 @@ directories.forEach(function (top) {
var complete = false;
-kyuri.runners.cucumber.run(features, steps, function (err) {
- if (err) {
- console.log('Errors');
+try {
+ kyuri.runners.cucumber.run(features, steps, function () {
+ complete = true;
+ });
+} catch (err) {
+ console.log('Errors');
+ if (err.stack) {
+ console.log(err.stack);
+ } else {
console.log(err);
- }
+ }
complete = true;
-});
+}
var _waitComplete = function () {
if (!complete) {
@@ -7,7 +7,7 @@ Feature: Complex Addition
Given I have a calculator
Scenario: Add two numbers
- Given I have entered 50 into the calculator
+ Given I have entered "50" and "75" into the calculator
And I have entered 70 into the calculator
When I press add
Then the result should be 120 on the screen
Oops, something went wrong. Retry.

0 comments on commit 9cdc403

Please sign in to comment.