Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added a config for backward compat #13

Merged
merged 3 commits into from

3 participants

@davglass
Owner

This is for @nzakas.

I added a config to YUITest.TestRunner to allow it to not throw on tests with no Assertions.

There are several test suites inside YUI that do not use Asserts since they use the "_should" assertions to tell if something throws or errors.

This just removes that extra assert when the config option is set.

@nzakas nzakas was assigned
@nzakas

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.

Owner

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.

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.

Owner

That works! On it..

@davglass
Owner

Pushed up the change, and as an FYI, I added a ton of tests to the YUI source tree for YUITest:

https://github.com/yui/yui3/tree/master/src/test/tests

We might be able to make them reusable for both projects.

@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
@davglass
Owner

@nzakas Can you merge these in? The flush fix I just added makes using YUITest in a CI environment impossible with the latest stable Node.

@nzakas
@davglass
Owner

Can you merge it into yours and publish a new npm package with the fix?

Once it's merged with yours, then i can merge it and push it to the yui account.

@nzakas
@davglass
Owner

Understood, take your time. Get to it when you can man..

@nzakas
@yuibuild yuibuild merged commit 1d06aa5 into from
@davglass
Owner

You Rock!

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.