-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding tests for JSON and HTML reporting
Fix the JSON parser issue by reading file from .json Adding assertions for JSON output for the test grunt test
- Loading branch information
Kushang Gajjar
committed
Jun 10, 2016
1 parent
3fe136a
commit 20afb9e
Showing
10 changed files
with
132 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,6 @@ node_modules | |
npm-debug.log | ||
tmp | ||
.DS_Store | ||
.idea/ | ||
.idea/ | ||
test/report/ | ||
test/report/screenshot/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
var fs = require('fs'); | ||
var chai = require('chai'); | ||
chai.use(require('chai-fs')); | ||
var expect = chai.expect; | ||
|
||
module.exports = { | ||
|
||
assert: function(htmlFile) { | ||
var jsonFile = htmlFile + '.json'; | ||
|
||
function assertJsonContents() { | ||
var jsonOutput = require('../../' + jsonFile); | ||
var jsonOutputStringify = JSON.stringify(jsonOutput); | ||
expect(jsonOutputStringify).to.contain('mime_type":"image/png"', 'screenshot was not attached to report'); | ||
expect(jsonOutputStringify).to.contain('mime_type":"text/plain"', 'test data was not attached to report'); | ||
} | ||
|
||
expect(jsonFile).to.be.a.file('expected a file to be Json').with.json; | ||
expect(htmlFile).to.be.a.path('HTML report was not created'); | ||
|
||
return assertJsonContents(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
var steps = function() { | ||
this.Before(function(scenario, callback) { | ||
this.scenario = scenario; | ||
callback(); | ||
}); | ||
|
||
this.Then(/^this feature runs with background$/, function(callback) { | ||
callback(); | ||
}); | ||
|
||
this.Then(/^Fred runs a passing cucumber scenario$/, function(callback) { | ||
callback(); | ||
}); | ||
|
||
this.Then(/^he choose "([^"]*)" output as one of the formatter$/, function(arg1, callback) { | ||
callback(); | ||
}); | ||
|
||
this.Then(/^the output should contain test results in HTML format$/, function(callback) { | ||
callback(); | ||
}); | ||
|
||
this.Then(/^Fred runs a failing cucumber scenario$/, function(callback) { | ||
callback(); | ||
}); | ||
|
||
this.Then(/^a failing scenario captures a screenshot$/, function(callback) { | ||
this.scenario.attach(new Buffer('').toString('base64'), 'image/png'); | ||
callback(); | ||
}); | ||
|
||
this.Then(/^the output should contain test results with screenshot in HTML format$/, function(callback) { | ||
callback(); | ||
}); | ||
|
||
this.Then(/^Fred attaches the "([^"]*)" to the Given step of passing cucumber scenario$/, function(testData, callback) { | ||
this.scenario.attach(testData); | ||
callback(); | ||
}); | ||
|
||
this.Then(/^the output should contain test data attached to the Given step in HTML format$/, function(callback) { | ||
callback(); | ||
}); | ||
}; | ||
|
||
|
||
module.exports = steps; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Feature: Grunt Cucumberjs Feature | ||
|
||
In order to review cucumber reports | ||
Fred, a cucumber user | ||
Wants to have cucumber reports in HTML | ||
|
||
Background: | ||
When this feature runs with background | ||
|
||
Scenario: Fred wants to have passing scenarios in the HTML reports | ||
Given Fred runs a passing cucumber scenario | ||
When he choose "html" output as one of the formatter | ||
Then the output should contain test results in HTML format | ||
|
||
Scenario: Fred wants to have failing scenarios in the HTML reports | ||
Given Fred runs a failing cucumber scenario | ||
When he choose "html" output as one of the formatter | ||
And a failing scenario captures a screenshot | ||
Then the output should contain test results with screenshot in HTML format | ||
|
||
Scenario: Fred wants to print test data in the HTML reports for debugging purpose | ||
Given Fred attaches the "test data to be printed" to the Given step of passing cucumber scenario | ||
When he choose "html" output as one of the formatter | ||
Then the output should contain test data attached to the Given step in HTML format | ||
|