Skip to content

Commit

Permalink
Merge pull request #17 from marek629/skip-case
Browse files Browse the repository at this point in the history
Skip case documentation and small fix
  • Loading branch information
AStepaniuk authored Jan 14, 2017
2 parents ca286e1 + 37588af commit bd01c6a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 26 deletions.
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

0 comments on commit bd01c6a

Please sign in to comment.