Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added support for running single specific tests using their fully qua…

…lified name, built as : 'outerGroup - .. - innerGroup - testName
  • Loading branch information...
commit 3bfe5b78d24c0e8017ad70e7ee6d2e94c558555a 1 parent 92d7bd1
@urigolani urigolani authored
View
8 bin/nodeunit
@@ -22,6 +22,7 @@ var testrunner,
reporter_file = 'default',
reporter_param_found = false,
testspec_param_found = false;
+ testFullSpec_param_found = false;
var usage = "Usage: nodeunit [options] testmodule1.js testfolder [...] \n" +
"Options:\n\n" +
@@ -29,8 +30,10 @@ var usage = "Usage: nodeunit [options] testmodule1.js testfolder [...] \n" +
" --reporter FILE optional path to a reporter file to customize the output\n" +
" --list-reporters list available build-in reporters\n" +
" -t name, specify a test to run\n" +
+ " -f fullname, specify a specific test to run. fullname is built so: \"outerGroup - .. - innerGroup - testName\"\n" +
" -h, --help display this help and exit\n" +
" -v, --version output version information and exit";
+
// load default options
@@ -65,6 +68,11 @@ args.forEach(function (arg) {
} else if (testspec_param_found) {
options.testspec = arg;
testspec_param_found = false;
+ } else if (arg === '-f') {
+ testFullSpec_param_found = true;
+ } else if (testFullSpec_param_found) {
+ options.testFullSpec= arg;
+ testFullSpec_param_found = false;
} else if (arg === '--list-reporters') {
var reporters = fs.readdirSync(__dirname + '/../lib/reporters');
reporters = reporters.filter(function (reporter_file) {
View
6 lib/core.js
@@ -102,13 +102,15 @@ exports.runSuite = function (name, suite, opt, callback) {
};
if (typeof prop === 'function') {
- var in_name = false;
+ var in_name = false,
+ in_specific_test = (_name.toString() === opt.testFullSpec) ? true : false;
for (var i = 0; i < _name.length; i += 1) {
if (_name[i] === opt.testspec) {
in_name = true;
}
}
- if (!opt.testspec || in_name) {
+
+ if ((!opt.testFullSpec || in_specific_test) && (!opt.testspec || in_name)) {
if (opt.moduleStart) {
opt.moduleStart();
}
View
3  lib/reporters/default.js
@@ -70,7 +70,8 @@ exports.run = function (files, options, callback) {
});
var opts = {
- testspec: options.testspec,
+ testspec: options.testspec,
+ testFullSpec: options.testFullSpec,
moduleStart: function (name) {
console.log('\n' + bold(name));
},
View
1  lib/reporters/html.js
@@ -55,6 +55,7 @@ exports.run = function (files, options, callback) {
console.log('<body>');
nodeunit.runFiles(paths, {
testspec: options.testspec,
+ testFullSpec: options.testFullSpec,
moduleStart: function (name) {
console.log('<h2>' + name + '</h2>');
console.log('<ol>');
View
1  lib/reporters/junit.js
@@ -102,6 +102,7 @@ exports.run = function (files, opts, callback) {
nodeunit.runFiles(paths, {
testspec: opts.testspec,
+ testFullSpec: options.testFullSpec,
moduleStart: function (name) {
curModule = {
errorCount: 0,
View
1  lib/reporters/machineout.js
@@ -85,6 +85,7 @@ exports.run = function (files, options, callback) {
nodeunit.runFiles(paths, {
testspec: options.testspec,
+ testFullSpec: options.testFullSpec,
moduleStart: function (name) {},
testDone: function (name, assertions) {
tracker.remove(name);
View
3  lib/reporters/minimal.js
@@ -53,7 +53,8 @@ exports.run = function (files, options, callback) {
var start = new Date().getTime();
var opts = {
- testspec: options.testspec,
+ testspec: options.testspec,
+ testFullSpec: options.testFullSpec,
moduleStart: function (name) {
process.stdout.write(bold(name) + ': ');
},
View
1  lib/reporters/nested.js
@@ -166,6 +166,7 @@ exports.run = function (files, options) {
nodeunit.runFiles(paths, {
testspec: options.testspec,
+ testFullSpec: options.testFullSpec,
moduleStart: function (name) {
console.log('\n' + bold(name));
},
View
1  lib/reporters/skip_passed.js
@@ -57,6 +57,7 @@ exports.run = function (files, options, callback) {
nodeunit.runFiles(paths, {
testspec: options.testspec,
+ testFullSpec: options.testFullSpec,
moduleStart: function (name) {
console.log('\n' + bold(name));
},
View
1  lib/reporters/verbose.js
@@ -74,6 +74,7 @@ exports.run = function (files, options) {
nodeunit.runFiles(paths, {
testspec: options.testspec,
+ testFullSpec: options.testFullSpec,
moduleStart: function (name) {
console.log('\n' + bold(name));
},
Please sign in to comment.
Something went wrong with that request. Please try again.