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

Core: Implements QUnit.skip #652

Closed
wants to merge 7 commits into from
Closed

Conversation

leobalter
Copy link
Member

Fixes #637
Fixes #434

API issue: qunitjs/api.qunitjs.com#75

@JamesMGreene
Copy link
Member

LGTM.

I would also like to see the HTML Reporter be updated to give skipped tests a different visual treatment.

Once we get the core HTML Reporter markup/CSS taken care of, we should also file new issues with all of the various QUnit HTML Reporter theme repos as well:

@leobalter
Copy link
Member Author

I can pass a value on the testDone callback

@gibson042
Copy link
Member

Agreed on the reporter changes. I'd also like a test covering the QUnit.skip("no function") case.

this.testName = "SKIPPED - " + this.testName;
for ( method in Assert.prototype ) {
this.assert[ method ] = skippedAssertion;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? And if yes, would the code make more sense elsewhere with something like this.assert = new Assert( settings.skip ? null : this ) here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is necessary to prevent assertions inside the module hooks (beforeEach/afterEach), on the skipped tests.

I'm stubbing every method defined on Assert's prototype and I believe it's the Test's responsibility to handle if it's a skipped one or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that properly reacting to settings.skip is the Test's responsibility, but manually faking a dummy object similar to an Assert but not instanceof Assert rather than delegating the implementation seems kludgy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One alternative may be to instead short-circuit the Test#hooks call to not retrieve any hooks if the test is marked as skip. This seems reasonable to me but that reasonability really depends on consumer usage.

@leobalter
Copy link
Member Author

@JamesMGreene @gibson042: Implemented the reporter logging and also the suggested test.

@@ -139,6 +152,7 @@ Test.prototype = {
runLoggingCallbacks( "testDone", {
name: this.testName,
module: this.module,
skipped: !!this.skip,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to qunitjs/js-reporters#4: I'm thinking we'll probably end up standardizing this to be a more generic property like status: "skipped". Not sure if we want to pursue that presumed direction yet in this PR or just leave this QUnit-specific for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just proceed by leaving this as a QUnit-specific thing for now and we can update in QUnit v2.0 if we decide on a more standard format going forward in collaboration with the other testing frameworks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I've preferred to keep it as it is before it's definition on the js-reporter.

skippedAssertion = function() {};

if ( settings.skip ) {
this.testName = "SKIPPED - " + this.testName;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as skipped tests blocks - and respective hooks - aren't called anymore, there's no more need to fake the Assert object.

cc @gibson042 @JamesMGreene

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

follow back to #652 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent! skippedAssertion can now be dropped as well.

@leobalter leobalter force-pushed the 637-skip branch 2 times, most recently from 8189558 to 9dd6a77 Compare September 5, 2014 15:20
@leobalter
Copy link
Member Author

Thanks @gibson042 and @JamesMGreene. Fixed the code and rebased with master.

@JamesMGreene
Copy link
Member

LGTM! 👍

@JamesMGreene
Copy link
Member

@jzaefferer @Krinkle @scottgonzalez: Any desire to review this PR further before we merge it?

throw "Error";
});

QUnit.skip ( "no function" );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jscs doesn't detect the extra space here. Let's fix this and report the missing check.

@jzaefferer
Copy link
Member

Reviewed this in detail, found a few issues. Apart from that it would be good to outline what API docs need to be written or updated. Let's put that in the description of the PR.

testName: testName,
expected: 0,
async: false,
callback: function() {},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This deserves a line comment, I missed it on first review.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though if we can move the default properties inside the constructor, the differences to the call in QUnit.test should be much more obvious.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also missed it the first time through, took a second pass to find it.

@Krinkle
Copy link
Member

Krinkle commented Sep 7, 2014

Design idea for html reporter:

Not sure about the <em>.

@Krinkle
Copy link
Member

Krinkle commented Sep 7, 2014

We should also include the number of skipped tests in the summary atop the html reporter.

Tests completed in 1782 milliseconds.
331 assertions of 331 passed, 0 failed.

Maybe add something like

2 skipped tests.

That way they're discoverable without having to scan the page manually.

PHPUnit, for example, reports:

OK (but with incomplete or skipped tests)
Tests: 8693, Assertions: 574690, Skipped: 8.

@JamesMGreene
Copy link
Member

I think the background color of the cell should still be different for skipped tests but adding the yellow bubble is a nice additional visual treatment.

I also agree about including the number of skipped tests in the summary.

@jzaefferer
Copy link
Member

Adding the bubble along with a different background color, while not modifying the test name sounds good.

Since skipped tests don't run assertions, we can't actually tell how many assertions were skipped. Mixing assertions and tests in the summary sounds like a bad idea. I'm okay with landing this without changes to the summary.

@leobalter
Copy link
Member Author

About the bubble label: I prefer to change only the background color instead of inserting a bubble. As we are using the colors to indicate the test status and skipped is a new one.

@leobalter
Copy link
Member Author

I like the idea to include the number of skipped tests on the summary, as long as they are not on the sum of the passed tests.

Also logs skipped tests on testDone callback that are handled on
the html reporter

Fixes qunitjs#637
Fixes qunitjs#434
@leobalter
Copy link
Member Author

After talking with @jzaefferer, I'm trying a new suggestion: grey background for the skipped line with the yellow bubble. Runtime is also not inserted (there's not test to run there). Rerun link was intentionally kept.

screen shot 2014-09-08 at 12 49 22

@leobalter
Copy link
Member Author

As we summarize only the passed and failed assertions on the reporter, I prefer to address it on another issue/PR.

addClass( testItem, "skipped" );
skipped = document.createElement( "em" );
skipped.className = "qunit-skipped-label";
skipped.innerHTML = "SKIPPED";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this "Skipped", add a CSS rule to show it uppercase. Allows themes to override that.

assert.expect( 3 );

assert.ok( testDoneContext.runtime >= 0, "logs runtime" );
assert.ok( testDoneContext.duration >= 0, "logs deprecated duration" );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove these two assertions. We don't care about the runtime of skipped tests. Its okay to have them there, but we don't need to test for that.

@@ -102,6 +114,11 @@ Test.prototype = {
hooks: function( handler ) {
var hooks = [];

// hooks are also ignored on skipped tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uppcase first char in line comments

@jzaefferer
Copy link
Member

Reviewed everything once more, looks great to me. Would be nice to get a nod-off from @JamesMGreene or @Krinkle as well.

@Krinkle
Copy link
Member

Krinkle commented Sep 10, 2014

Good call on applying a change to the background of the row as well. The grey and yellow look good to me:

(RE: 0122c75) The ALL CAPS label text is a bit excessive though. Title Case doesn't seem appropriate either. Perhaps lowercase will fit in nicely with the overall friendly interface?

@JamesMGreene
Copy link
Member

I'd say definitely not TitleCase for the "SKIPPED" bubble. I'm fine with either all uppercase or lowercase.

@leobalter
Copy link
Member Author

Done, lowercase "skipped" is now the default.

Also other reporter can change it through CSS's text-transform

@leobalter leobalter closed this in 3f08a1a Sep 11, 2014
leobalter added a commit to leobalter/api.qunitjs.com that referenced this pull request Sep 12, 2014
leobalter added a commit to qunitjs/api.qunitjs.com that referenced this pull request Dec 3, 2014
@leobalter leobalter deleted the 637-skip branch October 27, 2015 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to mark a Test as skipped or incomplete
5 participants