Skip to content

Commit

Permalink
[Issue #5] Fix skipped cases effect to total count
Browse files Browse the repository at this point in the history
  • Loading branch information
M.Halit Karakis committed Jan 6, 2017
1 parent 6afe3c4 commit 366dbc6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ function success(testCase) {
}

function skip(testOrCase) {
totalCount++;
skipCount++;
skipNextEnabled = false;
/**
Expand Down
11 changes: 6 additions & 5 deletions test/eventtest.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** globals salep */
var testResult = true;

require("../src/index.js");
Expand Down Expand Up @@ -82,11 +83,11 @@ shouldTestStartEventCount++;

var result = salep.stop();

if (caseStartEventCount !== shouldCaseStartEventCount ||
failEventCount !== shouldFailEventCount ||
skipEventCount !== shouldSkipEventCount ||
successEventCount !== shouldSuccessEventCount ||
testStartEventCount !== shouldTestStartEventCount ||
if (caseStartEventCount !== shouldCaseStartEventCount ||
failEventCount !== shouldFailEventCount ||
skipEventCount !== shouldSkipEventCount ||
successEventCount !== shouldSuccessEventCount ||
testStartEventCount !== shouldTestStartEventCount ||
disabledCallbackCount !== shouldDisabledCallbackCount) {
testResult = false;
}
Expand Down
14 changes: 11 additions & 3 deletions test/failtest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/** globals salep */
require("../src/index.js");

var shouldFailCount = 0;
var shouldSkipCount = 0;
var shouldSuccessCount = 0;
var shouldTotalCount = 0;

salep.test("A test without any case", function() {

Expand All @@ -13,33 +15,39 @@ salep.test("A test with failing cases", function() {
throw "Fail 1";
});
shouldFailCount++;
shouldTotalCount++;

this.case("Fail case 2", function() {
throw "Fail 2";
});
shouldFailCount++;
shouldTotalCount++;

this.case("Success cases shouldn't increment fail count", function() {
// empty means success
});
shouldSuccessCount++;
shouldTotalCount++;
});

salep.case("A salep case to fail", function() {
throw "Fail 3";
});
shouldFailCount++;
shouldTotalCount++;

salep.case("A successful salep case", function() {
// empty
});
shouldSuccessCount++;
shouldTotalCount++;

var result = salep.stop();

if (result.skip === 0 &&
result.fail === shouldFailCount &&
result.success === shouldSuccessCount) {
if (result.skip === shouldSkipCount &&
result.fail === shouldFailCount &&
result.success === shouldSuccessCount &&
result.total === shouldTotalCount) {
exports.success = true;
} else {
exports.success = false;
Expand Down
13 changes: 9 additions & 4 deletions test/skiptest.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/** globals salep */
require("../src/index.js");

var shouldSkipCount = 0;
var shouldFailCount = 0;
var shouldSuccessCount = 0;
var totalCount = 0;
var shouldTotalCount = 0;

// Skipping salep
salep.skipNext();
Expand All @@ -21,24 +22,28 @@ salep.test("should skip this test", function() {
});
});
shouldSkipCount++;
shouldTotalCount++

// Skipping salep cases
salep.skipNext();
salep.case("should skip this case and count it as skipped", function() {
throw "This exception shouldn't affect skip status";
});
shouldSkipCount++;
shouldTotalCount++;

salep.case("this shouldn't skip", function() {
// empty
});
shouldSuccessCount++;
shouldTotalCount++;

var result = salep.getResults();

if (result.skip === shouldSkipCount &&
result.fail === shouldFailCount &&
result.success === shouldSuccessCount) {
if (result.skip === shouldSkipCount &&
result.fail === shouldFailCount &&
result.success === shouldSuccessCount &&
result.total === shouldTotalCount) {
exports.success = true;
} else {
exports.success = false;
Expand Down

0 comments on commit 366dbc6

Please sign in to comment.