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

Skip case documentation and small fix #17

Merged
merged 5 commits into from
Jan 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,37 @@ QUnit.test("Sum test[5+0]", function() {
});
```


##Skipping test case
(available since v0.5)

Sometimes you need skip specific test case. You can use `_skip` boolean (false by default) parameter.

####Example

```js
QUnit
.cases([
{ title: "skip me", _skip: true, a: 2, b: 2, expectedSum: 4},
{ title : "5+0", a : 5, b : 0, expectedSum : 5 }
])
.test("Sum test", function(params) {
var actualSum = sum(params.a, params.b);
equal(actualSum, params.expectedSum);
});
```

First test case will be skipped so equivalent for above code is:

```js
QUnit.skip("Sum test[skip me]");
QUnit.test("Sum test[5+0]", function() {
var actualSum = sum(5, 0);
equal(actualSum, 5);
});
```


##Chaining
(available since v0.2)

Expand Down
9 changes: 5 additions & 4 deletions qunit-parameterize.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,19 @@ QUnit.extend(QUnit, {
}

for (var i = 0; i < currentCases.length; ++i) {
var methodNameString = methodName;
var parameters = currentCases[i];

var testCaseTitle = title;
if (parameters.title) {
testCaseTitle += "[" + parameters.title + "]";
}

if (parameters._skip === true) {
methodName = 'skip';
}
if (parameters._skip === true) {
methodNameString = 'skip';
}

createTest(methodName, testCaseTitle, expected, callback, parameters);
createTest(methodNameString, testCaseTitle, expected, callback, parameters);
}
}

Expand Down
26 changes: 4 additions & 22 deletions test/skip-case-test.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
var skipCaseArray = [
{
title: 'skip default value',
cases: [
{
title: 'skip default is false',
expected: false
},
{
title: 'skip is false',
skip: false,
expected: false
},
{
title: 'skip is true',
skip: true,
expected: true
},
]
}
];

QUnit.module('Skip case');
QUnit.skip('Check if QUnit.skip() function is available.');
QUnit.cases([
Expand All @@ -36,6 +14,10 @@ QUnit.cases([
title: '_skip is true',
_skip: true,
expected: true
},
{
title: '_skip default is false, call after true value',
expected: false
}
]).test('_skip default value',
function(params, assert)
Expand Down