Permalink
Browse files

Add pretty formatter.

  • Loading branch information...
1 parent 7b88395 commit 7dbb915c8fd7df3a786e54e4437c6efc03f951c1 @renier committed Apr 4, 2012
@@ -40,6 +40,10 @@ var Feature = function(keyword, name, description, line) {
scenarios.add(scenario);
},
+ getScenarios: function getScenarios() {
+ return scenarios;
+ },
+
getLastScenario: function getLastScenario() {
return scenarios.getLast();
},
@@ -40,6 +40,10 @@ var Scenario = function(keyword, name, description, line) {
return steps.getLast();
},
+ getSteps: function getSteps() {
+ return steps;
+ },
+
addTags: function setTags(newTags) {
tags = tags.concat(newTags);
},
View
@@ -1,6 +1,6 @@
var Step = function(keyword, name, line) {
var Cucumber = require('../../cucumber');
- var docString, dataTable, previousStep;
+ var docString, dataTable, previousStep, stepResult;
var self = {
setPreviousStep: function setPreviousStep(newPreviousStep) {
@@ -67,6 +67,14 @@ var Step = function(keyword, name, line) {
}
},
+ getResult: function getResult() {
+ return stepResult;
+ },
+
+ setResult: function setResult(result) {
+ stepResult = result;
+ },
+
isOutcomeStep: function isOutcomeStep() {
var isOutcomeStep =
self.hasOutcomeStepKeyword() || self.isRepeatingOutcomeStep();
@@ -131,7 +139,7 @@ var Step = function(keyword, name, line) {
acceptVisitor: function acceptVisitor(visitor, callback) {
self.execute(visitor, function(stepResult) {
- visitor.visitStepResult(stepResult, callback);
+ visitor.visitStepResult(self, stepResult, callback);
});
},
View
@@ -13,9 +13,9 @@ var Cli = function(argv) {
},
runSuiteWithConfiguration: function runSuiteWithConfiguration(configuration, callback) {
- var runtime = Cucumber.Runtime(configuration);
- var progressFormatter = Cucumber.Listener.ProgressFormatter();
- runtime.attachListener(progressFormatter);
+ var runtime = Cucumber.Runtime(configuration);
+ var formatter = configuration.getFormatter();
+ runtime.attachListener(formatter);
runtime.start(callback);
},
@@ -59,17 +59,22 @@ var ArgumentParser = function(argv) {
getKnownOptionDefinitions: function getKnownOptionDefinitions() {
var definitions = {};
- definitions[ArgumentParser.REQUIRE_OPTION_NAME] = [path, Array];
- definitions[ArgumentParser.TAGS_OPTION_NAME] = [String, Array];
- definitions[ArgumentParser.HELP_FLAG_NAME] = Boolean;
- definitions[ArgumentParser.VERSION_FLAG_NAME] = Boolean;
+ definitions[ArgumentParser.REQUIRE_OPTION_NAME] = [path, Array];
+ definitions[ArgumentParser.TAGS_OPTION_NAME] = [String, Array];
+ definitions[ArgumentParser.FORMATTER_OPTION_NAME] = String;
+ definitions[ArgumentParser.HELP_FLAG_NAME] = Boolean;
+ definitions[ArgumentParser.VERSION_FLAG_NAME] = Boolean;
return definitions;
},
getShortenedOptionDefinitions: function getShortenedOptionDefinitions() {
var definitions = {};
- definitions[ArgumentParser.REQUIRE_OPTION_SHORT_NAME] = [ArgumentParser.LONG_OPTION_PREFIX + ArgumentParser.REQUIRE_OPTION_NAME];
- definitions[ArgumentParser.HELP_FLAG_SHORT_NAME] = [ArgumentParser.LONG_OPTION_PREFIX + ArgumentParser.HELP_FLAG_NAME];
+ definitions[ArgumentParser.REQUIRE_OPTION_SHORT_NAME] =
+ [ArgumentParser.LONG_OPTION_PREFIX + ArgumentParser.REQUIRE_OPTION_NAME];
+ definitions[ArgumentParser.FORMATTER_OPTION_SHORT_NAME] =
+ [ArgumentParser.LONG_OPTION_PREFIX + ArgumentParser.FORMATTER_OPTION_NAME];
+ definitions[ArgumentParser.HELP_FLAG_SHORT_NAME] =
+ [ArgumentParser.LONG_OPTION_PREFIX + ArgumentParser.HELP_FLAG_NAME];
return definitions;
},
@@ -107,6 +112,8 @@ ArgumentParser.REQUIRE_OPTION_NAME = "require";
ArgumentParser.REQUIRE_OPTION_SHORT_NAME = "r";
ArgumentParser.TAGS_OPTION_NAME = "tags";
ArgumentParser.TAGS_OPTION_SHORT_NAME = "t";
+ArgumentParser.FORMATTER_OPTION_NAME = "formattter";
+ArgumentParser.FORMATTER_OPTION_SHORT_NAME = "f";
ArgumentParser.HELP_FLAG_NAME = "help";
ArgumentParser.HELP_FLAG_SHORT_NAME = "h";
ArgumentParser.DEFAULT_HELP_FLAG_VALUE = false;
@@ -35,6 +35,20 @@ var Configuration = function(argv) {
return rules;
},
+ getFormatter: function getFormatter() {
+ var formatter,
+ formatterOption = argumentParser.getOptionOrDefault("formatter", "progress");
+ switch(formatterOption) {
+ case "pretty":
+ formatter = new Cucumber.Listener.PrettyFormatter();
+ break;
+ case "progress":
+ default:
+ formatter = new Cucumber.Listener.ProgressFormatter();
+ }
+ return formatter;
+ },
+
isHelpRequested: function isHelpRequested() {
var isHelpRequested = argumentParser.isHelpRequested();
return isHelpRequested;
View
@@ -1,3 +1,4 @@
var Listener = {};
Listener.ProgressFormatter = require('./listener/progress_formatter');
+Listener.PrettyFormatter = require('./listener/pretty_formatter');
module.exports = Listener;
Oops, something went wrong.

0 comments on commit 7dbb915

Please sign in to comment.