Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an inconclusive assertion #326

Closed
NoelAbrahams opened this issue Sep 24, 2012 · 5 comments
Closed

Create an inconclusive assertion #326

NoelAbrahams opened this issue Sep 24, 2012 · 5 comments

Comments

@NoelAbrahams
Copy link

The inconclusive assert would be used as follows:

test("My test", function () {
          inconclusive();
          // or with message        
         inconclusive("The submit click handler needs a test case");
});

When run the, the test would display in (say) orange (compared to red for fail and green for pass) , with the provided message or the default "Test pending" message.

We've hacked this together to work for us, here is a snippet that adds a class for the styling.

li.className = assertion.result === null ? "inconclusive" : (assertion.result ? "pass" : "fail");

It would be great if this can be included in the API.

It has proven very useful for creating place-holders for pending tests, and also for frameworks on top of QUnit that iterate an object and flag untested methods.

Thanks.
Noel

@jzaefferer
Copy link
Member

I think QUnit had this at some point. There were more arguments against it, the common response probably being "just add a failing test for something that isn't yet tested". Warnings are too easy to ignore, so why bother?

@jzaefferer
Copy link
Member

While I appreciate the input, I don't think this feature belongs in QUnit. I'm open to other opinions, until then I'll close this issue.

@Irrelon
Copy link

Irrelon commented Sep 29, 2014

I think this could be quite useful, or at least something of a custom output might be worth considering. My use case is that we have a bunch of tests against a modular framework and before a test is run we ask the framework if the module is loaded or not. If not then the tests for that module are excluded, however it could also be that the tester expects to see that module so there would be some use in allowing either inconsistent OR something like:

test('My module test', function () {
    if (module is loaded) {
        ok(module did something properly, 'Checked module function xyz is working');
    } else {
        other('Module is not loaded: ' + module name);
    }
});

Alternatively (how we currently do it) with the module loaded test outside the test method:

if (module is loaded) {
    test('Module tests', function () {
        ok(some method test, 'Test complete');
    });
} else {
    console.log('Didn't test ' + module name + ' because it's not loaded');
}

This is not as nice output-wise as the user needs console open. We could create a div on the page to log this sort of thing manually so console is not needed but it would be much nicer in the library itself. Just my two cents.

I've been deliberately pseudo-codey up there but you get the picture.

@JamesMGreene
Copy link
Member

See Issue #637 and PR #652 for the implementation of the forthcoming QUnit.skip.

@Irrelon
Copy link

Irrelon commented Sep 29, 2014

Great stuff. Thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants