Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
feat(plugins): add postResults hook for plugins
Browse files Browse the repository at this point in the history
Allows plugins to include a postResults function, which will be called
after webdriver has been quit and the environment has been torn down.
This step may not modify the contents of the test results object.
  • Loading branch information
juliemr committed Jan 6, 2015
1 parent 056a54b commit a9d83f7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
25 changes: 18 additions & 7 deletions lib/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function pluginFunFactory(funName) {
}

// Output test results
if(pluginResult.specResults) {
if (pluginResult.specResults) {
console.log('Plugin: ' + names[i] + ' (' + funName + ')');
for (var j = 0; j < pluginResult.specResults.length; j++) {
var specResult = pluginResult.specResults[j];
Expand Down Expand Up @@ -102,17 +102,28 @@ function pluginFunFactory(funName) {
}

/**
* Sets up plugins before tests are run.
* @return {q.Promise} A promise which resolves when the plugins have all been
* set up.
* Sets up plugins before tests are run.
*
* @return {q.Promise} A promise which resolves when the plugins have all been
* set up.
*/
Plugins.prototype.setup = pluginFunFactory('setup');

/**
* Tears down plugins after tests are run.
* @return {q.Promise} A promise which resolves when the plugins have all been
* torn down.
* Tears down plugins after tests are run.
*
* @return {q.Promise} A promise which resolves when the plugins have all been
* torn down.
*/
Plugins.prototype.teardown = pluginFunFactory('teardown');

/**
* Run after the test results have been processed (any values returned will
* be ignored), but before the process exits. Final chance for cleanup.
*
* @return {q.Promise} A promise which resolves when the plugins have all been
* torn down.
*/
Plugins.prototype.postResults = pluginFunFactory('postResults');

module.exports = Plugins;
5 changes: 4 additions & 1 deletion lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,10 @@ Runner.prototype.run = function() {
} else {
return self.driverprovider_.teardownEnv();
}
// 7) Exit process
// 7) Let plugins do final cleanup
}).then(function() {
return plugins.postResults();
// 8) Exit process
}).then(function() {
var exitCode = testPassed ? 0 : 1;
return self.exit_(exitCode);
Expand Down

0 comments on commit a9d83f7

Please sign in to comment.