Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Submitting here.. #3

Merged
merged 3 commits into from

2 participants

@davglass

Submitting this request to the Almighty Zakas :)

@nzakas
Owner

The run() method accepts an options object that defines how the tests should be run. I think this would be better as an option on that object.

I didn't add it there because I wanted all tests to abide by this out of the box. With our large system, I didn't want to have to modify every single test module to add this parameter for backward compatibility. This gives a "one stop" place to set this and have it "just work" as it did before that assert was added.

Owner

I understand the intent, the problem is that this would create two places to specify options instead of one. I don't like the idea of having a global configuration for the TestRunner because your tests may have different results depending on the TestRunner being used...that should never happen. Also, having tests without asserts is a horrible practice, and I don't want to encourage that.

That being said, I'm willing to compromise with you. If you want this property, mark it as private and deprecated, and prefix it with an underscore. That way, at least it will be hidden or flagged in docs as something people shouldn't use. It can be a YUI-only thing.

That works! On it..

davglass added some commits
@davglass davglass Making ignoreEmpty property private 6a603fd
@davglass davglass Added version check to "flush" work around
    In 0.6.x the drain event does not fire, which means
    the process.exit(code) is never executed.
    This prohibits automated scripts from failing on a failed
    test.
1d06aa5
@nzakas nzakas merged commit b722daf into nzakas:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 22, 2012
  1. @davglass
  2. @davglass
Commits on Apr 12, 2012
  1. @davglass

    Added version check to "flush" work around

    davglass authored
        In 0.6.x the drain event does not fire, which means
        the process.exit(code) is never executed.
        This prohibits automated scripts from failing on a failed
        test.
This page is out of date. Refresh to see the latest.
View
2  javascript/src/cli/CLI-node.js
@@ -44,7 +44,7 @@ YUITest.CLI = {
//Workaround for https://github.com/joyent/node/issues/1669
var flushed = process.stdout.flush && process.stdout.flush();
- if (!flushed) {
+ if (!flushed && (parseFloat(process.versions.node) < 0.5)) {
process.once("drain", function () {
process.exit(code || 0);
});
View
14 javascript/src/core/TestRunner.js
@@ -210,10 +210,20 @@
* @static
*/
this._groups = "";
+
}
TestRunner.prototype = YUITest.Util.mix(new YUITest.EventTarget(), {
-
+
+ /**
+ * If true, YUITest will not fire an error for tests with no Asserts.
+ * @prop _ignoreEmpty
+ * @private
+ * @type Boolean
+ * @static
+ */
+ _ignoreEmpty: false,
+
//restore prototype
constructor: YUITest.TestRunner,
@@ -596,7 +606,7 @@
segment.call(testCase, this._context);
//if the test hasn't already failed and doesn't have any asserts...
- if(YUITest.Assert._getCount() == 0){
+ if(YUITest.Assert._getCount() == 0 && !this._ignoreEmpty){
throw new YUITest.AssertionError("Test has no asserts.");
}
//if it should fail, and it got here, then it's a fail because it didn't
Something went wrong with that request. Please try again.