-
Notifications
You must be signed in to change notification settings - Fork 781
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
Pendings tests #787
Comments
That sounds great to me. We'd use this! |
It could also be useful for tests that we expect to fail in all browsers, but which mark code that could be removed once browsers started implementing a feature. If we start to see the pending test "fail" in Saucelabs, it's time to investigate using the browser feature. |
That's an interesting idea. In both cases this would be considered a "temporary" test, so I still think some visual highlight makes sense. |
This was touched on in the conversation that led to Relevant excerpts:
EDIT: removed unrelated comment and wholesale endorsement. |
qunit-pending from @JamesMGreene works differently from this proposal, where a test without a function argument like This issue proposes a test that contains at least one failing assertion. Rather than skipping them, they'll run all the assertions and it will FAIL when all of them pass. This way will lead the developer to keep a progressive work on a big refactoring, changing the pending tests to actual tests when they are ready and working. |
Noted and updated. I also want to add more nuance to this:
A blind reversal like that is insufficient for general use, because it doesn't highlight what work still needs to happen. TODO failures are still failures, they're just expected. This could manifest in a few different ways, but I think minimal changes require at least something like On the other hand, converting unexpected successes to unexpected failures as you propose makes sense to me, but is against the spirit of TAP ("Should a todo test point begin succeeding, the harness should report it as a bonus")... if we follow those footsteps instead, it'll mean something like No matter what, though, this promotes "expectations" as a QUnit concept, which is worth keeping in mind. |
I'd say definitely don't call it It's also worth noting that no other JS unit testing framework we've talked to has this functionality. It's marked as "Status Type" of "Inconclusive" in the table here: qunitjs/js-reporters#4 Whether that is good or bad remains to be seen....
|
todo sounds better than pending. Regarding it as a new functionality, I believe the use case is the argument to sustain this new API feature. |
I've read this a few times, but still fail to grasp the essence. Could you or someone else provide a summary beyond "let's add |
I'll give it a shot. Recall that the QUnit callbacks provide "failed" and "passed" assertion counts, with an implicit assumption that every assertion is expected to pass. Introducing TODO means violating that assumption, because a run with failed assertions is still a success if they are all associated with TODO tests. We need to capture them in a new "failed as expected" count so consumers can behave correctly. We should also add a "passed unexpectedly" count so consumers can identify potentially-complete TODOs (e.g., Having done that, the HTML reporter will need to style expectedly failing and unexpectedly passing tests. |
That sounds like overkill. Adding a "todo" detail to the log and badge to the reporter (styled like the one for skip) and reversing the result of all assertions inside a |
How is a developer to identify a |
HTML reporter: "todo" badge, similar to "skip" badge As long as the details for the test indicate the "todo" state, both can be implemented to output whatever we need. |
I'm specifically thinking of Javascript reporters. The current callbacks arguments don't provide that information. Are you proposing a new property in the testDone details and requiring consumers to register at that level if they care about the distinction (e.g., for reporting at suite completion)? var failedAsExpected = 0,
toDoNoMore = [];
QUnit.testDone(function( details ) {
if ( details.todo ) {
failedAsExpected += details.failed;
if ( !details.failed ) {
toDoNoMore.push( details );
}
}
}); I think I can get on board with that. |
I'm not sure what you refer to as "Javascript reporters". I was talking about #790.
Yeah, that. |
A poor choice of words. What matters is the API provided by QUnit—data passed to callbacks should be complete enough to implement any reporter (hence the need for an additional property here). I was just blinded by the presence of failed/passed/total assertion counts in Also, note that there will be edge cases with the interaction between "todo reversal" and automatically-added assertions (uncaught exceptions, timeouts, globals pollution, expected count mismatch, etc.). |
@gibson042 @wycats I've updated the ticket above with a summary, can you verify that captures everything we discussed? |
Looks good except for this:
I expect "todo" tests to pass when at least one assertion fails, or "fail" when all assertions pass. |
Agreed. It might point some bad practice but some assertions might pass on todo tests by random changes, as a collateral effect. It's good to flag only with the entire test passing rather than single assertions. |
Makes sense. Updated the code block above, please take another look. |
LGTM 👍 |
LGTM as well. Let's do it. |
Is this feature still wanted? If so, I volunteer to do the work. I'd very much like to see this as my primary project at work would use it. |
yes, it would be great to have this feature. |
I began attempting to implement this and ran into some issues that I think need discussing. Adding Now, this is technically able to be worked around by reporters only caring about values at the That said, maybe the "details" we report in |
I don't think implementing TODO should require breaking changes to the module callback data, even though those breaking changes may be independently valuable. I still think framing this in the context of expectations is the way to go, and would imagine a module with two tests (one normal with two passing assertions and one TODO with a passing assertion and a failing assertion) to report something like {
"total": 4,
"passed": 3,
"failed": 1,
// new properties
// names and meaning subject to bikeshedding
// …but values should always be less than or equal to unqualified analogs
"passedUnexpectedly": 1,
"failedAsExpected": 1,
…
} As you can see, the new properties are adding context to the existing data (even though |
I think this approach makes sense. It solves the problems I mention above and maintains backwards compatibility across the board. One thought (largely bikeshedding though) would be to frame the numbers we report both as "unexpected". My thinking on this is two-fold: (1) it keeps the naming (and mental model) consistent across the two new variables, and, (2) {
"total": 4,
"passed": 3,
"failed": 1,
"unexpected": {
"passed": 2, // bonuses
"failed": 2 // problems
}
} |
I'm fine with both new fields being "unexpected", or even "expected" (e.g., under normal circumstances, and always until this is implemented, "expected failures" is zero/undefined). But I do think consumer code will be simpler if we don't wrap them in a sub-object. |
I had considered using "expected", but that actually doesn't provide enough contextual information. For example, if you have two expected failures from a {
"failed": 1,
"expectedFailures": 2
} Giving you no way of knowing whether that failure was one of the expected ones or not. Since we're primarily concerned with the "unexpected" events, reporting those doesn't have that issue.
That's fine with me, I'm particularly concerned with naming consistency over the exact shape. I'm going to pursue an implementation following like so: {
"total": 4,
"passed": 3,
"failed": 1,
"passedUnexpectedly": 1,
"failedUnexpectedly": 0
} |
Something that came out of a discussion with Yehuda: During a big refactoring they have hundreds of failing tests. They turned them off using
QUnit.skip
, but that doesn't tell them which of the skipped tests starting passing again at some point. To quickly test changes in passing tests, they ended up with this:There's probably a better way to deal with that situation. One idea is to have something like a
QUnit.pending
method, that has the same signature asQUnit.test()
, but will reverse the result. So if all assertions pass, the test fails, if at least one fails, the test passes.The HTML reporter could use a similar marker as
QUnit.skip
.Thoughts?
Update 2015-04-15:
After some discussion, we came up with this:
The text was updated successfully, but these errors were encountered: