From 3ace3e78f1e1402dcc44c3503c855e786ae586c6 Mon Sep 17 00:00:00 2001 From: just-boris Date: Sun, 18 Sep 2016 17:44:48 +0200 Subject: [PATCH 1/2] split pending and skipped tests --- lib/reporter.js | 5 ++- .../fixtures/steps-status-step-definitions.js | 13 ++++++ test/fixtures/steps-status.conf.js | 11 +++++ test/fixtures/steps-status.feature | 9 ++++ test/steps.spec.js | 44 +++++++++++++++++++ 5 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/steps-status-step-definitions.js create mode 100644 test/fixtures/steps-status.conf.js create mode 100644 test/fixtures/steps-status.feature create mode 100644 test/steps.spec.js diff --git a/lib/reporter.js b/lib/reporter.js index 02c156c..22d2fe3 100644 --- a/lib/reporter.js +++ b/lib/reporter.js @@ -82,9 +82,12 @@ class CucumberReporter { e = 'pass' break case Cucumber.Status.PENDING: + e = 'pending' + break case Cucumber.Status.SKIPPED: case Cucumber.Status.AMBIGUOUS: - e = 'pending' + e = 'skipped' + break } let error = {} let stepTitle = step.getName() || step.getKeyword() || 'Undefined Step' diff --git a/test/fixtures/steps-status-step-definitions.js b/test/fixtures/steps-status-step-definitions.js new file mode 100644 index 0000000..00cfcdd --- /dev/null +++ b/test/fixtures/steps-status-step-definitions.js @@ -0,0 +1,13 @@ +var assert = require('assert') + +module.exports = function () { + this.Given(/Test will fail/, (url) => { + return assert.ok(false, 'expected failure') + }) + + this.Given('Pending test', () => 'pending') + + this.Then(/this step will be skipped/, (selector) => { + throw new Error('unexpected error') + }) +} diff --git a/test/fixtures/steps-status.conf.js b/test/fixtures/steps-status.conf.js new file mode 100644 index 0000000..1d64845 --- /dev/null +++ b/test/fixtures/steps-status.conf.js @@ -0,0 +1,11 @@ +export default { + sync: false, + capabilities: { + browserName: 'chrome' + }, + + cucumberOpts: { + timeout: 5000, + require: [__dirname + '/steps-status-step-definitions.js'] + } +} diff --git a/test/fixtures/steps-status.feature b/test/fixtures/steps-status.feature new file mode 100644 index 0000000..5d7c1a9 --- /dev/null +++ b/test/fixtures/steps-status.feature @@ -0,0 +1,9 @@ +Feature: Steps status + + Scenario: Failing test + Given Test will fail + And this step will be skipped + Then this step will be skipped + + Scenario: Pending + Given Pending test diff --git a/test/steps.spec.js b/test/steps.spec.js new file mode 100644 index 0000000..c267289 --- /dev/null +++ b/test/steps.spec.js @@ -0,0 +1,44 @@ +import { CucumberAdapter } from '../lib/adapter' +import CucumberReporter from '../lib/reporter' +import config from './fixtures/steps-status.conf' + +const specs = ['./test/fixtures/steps-status.feature'] + +const WebdriverIO = class {} + +describe('steps', () => { + it('should report different status for steps', async () => { + const messages = [] + const send = CucumberReporter.prototype.send + CucumberReporter.prototype.send = message => messages.push(message) + global.browser = new WebdriverIO() + global.browser.options = config + const adapter = new CucumberAdapter(0, config, specs, {}) + + ;(await adapter.run()).should.be.equal(1) + + messages.map(msg => msg.event).should.be.deepEqual([ + 'suite:start', + + // failed + 'suite:start', + 'test:start', + 'test:fail', + 'test:start', + 'test:skipped', + 'test:start', + 'test:skipped', + 'suite:end', + + // pending + 'suite:start', + 'test:start', + 'test:pending', + 'suite:end', + + 'suite:end' + ]) + + CucumberReporter.prototype.send = send + }) +}) From ba76ad16b42dc9a791dd2b237c5546e38d951c9f Mon Sep 17 00:00:00 2001 From: Boris Serdiuk Date: Wed, 21 Sep 2016 09:58:05 +0200 Subject: [PATCH 2/2] report pending tests as skipped as well --- lib/reporter.js | 2 -- test/steps.spec.js | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/reporter.js b/lib/reporter.js index 22d2fe3..79d1508 100644 --- a/lib/reporter.js +++ b/lib/reporter.js @@ -82,8 +82,6 @@ class CucumberReporter { e = 'pass' break case Cucumber.Status.PENDING: - e = 'pending' - break case Cucumber.Status.SKIPPED: case Cucumber.Status.AMBIGUOUS: e = 'skipped' diff --git a/test/steps.spec.js b/test/steps.spec.js index c267289..f75d5d3 100644 --- a/test/steps.spec.js +++ b/test/steps.spec.js @@ -33,7 +33,7 @@ describe('steps', () => { // pending 'suite:start', 'test:start', - 'test:pending', + 'test:skipped', 'suite:end', 'suite:end'