Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

QUnit.begin should provide the total number of tests #350

Closed
jzaefferer opened this Issue · 16 comments

5 participants

@jzaefferer
Owner

For tools that show test progress its useful to have the total number of tests up front. Unlike number of assertions, we can actually provide the number of tests.

See karma-runner/karma#156 (comment)

@Krinkle
Collaborator

Provide it how? Depending on the configuration, afaik tests are executed while the test invocations happen. And even if start is delayed on until after, tests can be registered at any time. Make sure that whatever way is used to expose it allows it to be updated during the run.

If it is only for display, then updating is fine. If it is provided in callbacks for automated testing, then it can't be updated. But in that case it shouldn't be a problem to wait until the tests are done, right?

@jzaefferer
Owner

Its fine to do this only when for tests that were registered before QUnit.begin runs. In the browser that works, elsewhere QUnit.config.autostart should be disabled, to get proper QUnit.done results.

Providing this number up front helps to display progress in testacular, that's why having it just at the end doesn't help much.

@jzaefferer
Owner

Reviewed this, we should implement it.

@jzaefferer jzaefferer modified the milestone: v2.0, pre-2.0
@jimthedev

Hi @jzaefferer and @Krinkle I'm just checking in on this to see if this is being worked on. Currently there is a downstream issue in lazd/gulp-karma that is waiting on this feature. I am about to start a project and am considering qunit w/Karma but would appreciate an update, even if there's no change. Thanks.

@jzaefferer
Owner

As far as I know, there's no progress on this. It should be relatively simple to implement, but since we didn't have much of a need in our projects, it fell behind other issues.

@markelog

but since we didn't have much of a need in our projects

Now we do – jquery/sizzle#236, i could jump on this, if you're busy

@jzaefferer
Owner

I've looked at the PR you linked to, but didn't see any mention of this. Doesn't really matter though, a PR to implement this would be appreciated.

@markelog

Karma shows it like that:

Chrome 33.0.1750 (Mac OS X 10.9.0): Executed 35 of 0 SUCCESS (0 secs / 0.261 secs)

but it should be:

Chrome 33.0.1750 (Mac OS X 10.9.0): Executed 35 of 35 SUCCESS (0 secs / 0.261 secs)

plus a warning message, which is annoying

@jzaefferer
Owner

Ah, that makes sense.

Btw. I updated the link in the ticket description, though I don't see a mention of this issue...

@markelog markelog referenced this issue in jquery/sizzle
Closed

Use karma runner for test execution #236

@markelog

It could like this -

QUnit.begin(function( data ) {
    data.total; // Number;
});

Sounds good?

@markelog markelog referenced this issue from a commit in markelog/qunit
@markelog markelog Core: Pass total amount of tests to QUnit.begin cb
Fixes #350
3f1beb6
@jzaefferer
Owner

It should be consistent with other callbacks, e.g. QUnit.done: http://api.qunitjs.com/QUnit.done/

So yeah, that works, though total means "The total number of assertions" in done, so we should use a different name here, since we're referring to the number of tests, not assertions.

Once that is done, a PR for the docs would be appreciated as well. Thanks.

@markelog

So what name do you prefer?

@leobalter
Collaborator

IMHO, I would go with tests, following the callback current names.

Considering it's only an integer, it's easy to understand (and to explain in the docs) that it is a reference to the executed tests number.

@jzaefferer
Owner

How about totalTests on begin, then add passedTests, failedTests and totalTests (same as in begine) to QUnit.done?

@leobalter
Collaborator

If it's only one tests related variable containing only a numeric value, I prefer tests rather than totalTests, but this is fashion and both are good.

to QUnit.done, considering we could split the stats, I would nest them, like this:

tests: {
    passed: [Number],
    failed: [Number],
    total: [Number]
}

The main reason is to simplify the QUnit.done callback, making it easier to browse between returned values.

@markelog

@leobalter it would be weird to see an object within an object always with one attribute for QUnit.begin, for QUnit.done it's make sense though but these names probably should correlate with QUnit.begin names too.

I hate bikeshedding :-)

@markelog markelog referenced this issue from a commit in markelog/qunit
@markelog markelog Core: Pass total amount of tests to QUnit.begin cb
Fixes #350
0e4f4d0
@markelog markelog referenced this issue from a commit in markelog/qunit
@markelog markelog Core: Pass total amount of tests to QUnit.begin cb
Fixes #350
e2c9af5
@markelog markelog referenced this issue from a commit in markelog/api.qunitjs.com
@markelog markelog Begin: Update signature 0d4ded0
@markelog markelog referenced this issue from a commit in markelog/api.qunitjs.com
@markelog markelog Begin: Update signature 4708881
@markelog markelog referenced this issue from a commit in markelog/api.qunitjs.com
@markelog markelog Begin: Update signature 4ff1072
@markelog markelog referenced this issue from a commit in markelog/api.qunitjs.com
@markelog markelog Begin: Update signature 0f1d5ed
@markelog markelog referenced this issue from a commit in markelog/api.qunitjs.com
@markelog markelog Begin: Update signature 1c37da2
@jbmoelker jbmoelker referenced this issue in karma-runner/karma-junit-reporter
Open

fix for Fatal error: Missing attribute value with karma karma ~0.12 #14

@jzaefferer jzaefferer closed this in 26622e7
@Waxolunist Waxolunist referenced this issue in Voog/wysihtml
Merged

Qunit 1.14 #62

@jzaefferer jzaefferer referenced this issue from a commit in jquery/api.qunitjs.com
@markelog markelog Begin: Update signature and add example c72b03e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.