Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make onTestDone match onSuiteDone with a status argument

  • Loading branch information...
commit 2b2066116a1b94394da622caeb5322595cceffa6 1 parent 1b14586
Benjamin Thomas authored
View
39 docs/running-tests.html
@@ -403,17 +403,19 @@
<dd>Called when a test is started.
</dd>
- <dt><code>onTestDone(testResult)</code></dt>
+ <dt><code>onTestDone(status, testResult)</code></dt>
<dd>
Called when a test finishes. See <a href="#test-result">Test result</a>
below.
+ <code>status</code> is one of the following:<br> <b>failure</b> or <b>success</b>.
</dd>
<dt><code>onSuiteDone(status, suiteResult)</code></dt>
<dd>
Called when a suite finishes. See <a href="#suite-result">Suite result</a>
- below. <code>status</code> is one of the following: complete, error,
- loadError and exit.
+ below.
+ <code>status</code> is one of the following:<br> <b>complete</b>, <b>error</b>,
+ <b>loadError</b> or <b>exit</b>.
</dd>
</dl>
@@ -424,7 +426,7 @@ <h2 id="suite-result">Suite Result</h2>
</p>
<dl>
- <dt>complete</dt>
+ <dt><b>complete</b></dt>
<dd>
<p>
occures when all tests finished running, and <b>node-async-testing</b>
@@ -437,7 +439,7 @@ <h2 id="suite-result">Suite Result</h2>
}</pre></div>
</dd>
- <dt>error</dt>
+ <dt><b>error</b></dt>
<dd>
<p>
occures when an uncaught error is thrown from a test and <b>node-async-testing</b>
@@ -450,7 +452,7 @@ <h2 id="suite-result">Suite Result</h2>
}</pre></div>
</dd>
- <dt>exit</dt>
+ <dt><b>exit</b></dt>
<dd>
<p>
occures when the process running the suite exits and there are still tests that
@@ -462,7 +464,7 @@ <h2 id="suite-result">Suite Result</h2>
}</pre></div>
</dd>
- <dt>loadError</dt>
+ <dt><b>loadError</b></dt>
<dd>
<p>
this type of result is only produced from <code>runFile</code>, and
@@ -472,22 +474,33 @@ <h2 id="suite-result">Suite Result</h2>
{ stderr: what was written to &lt;stderr&gt; before the child process exited
}</pre></div>
</dd>
+ </dl>
<h2 id="test-result">Test Result</h2>
- <p> A test result is an object that looks like one of the following:</p>
-
- <p>Success: the test completed successfully</p>
+ <p>
+ A test result is an object that looks like one of the following, depending on
+ what the finish status of the test was:
+ </p>
- <div class="highlight"><pre>
+ <dl>
+ <dt><b>success</b></dt>
+ <dd>
+ <p>the test completed successfully</p>
+ <div class="highlight"><pre>
{ name: test name
, numAssertions: number of assertions completed successfully
}</pre></div>
+ </dd>
- <p>Failure: the test failed in some way</p>
- <div class="highlight"><pre>
+ <dt><b>failure</b></dt>
+ <dd>
+ <p>the test failed in some way</p>
+ <div class="highlight"><pre>
{ name: test name
, failure: the assertion failure
}</pre></div>
+ </dd>
+ </dl>
</section>
</div>
</body>
View
4 lib/child.js
@@ -6,12 +6,12 @@ var opts =
, onTestStart: function testStart(name) {
postMessage('onTestStart', name);
}
- , onTestDone: function testDone(result) {
+ , onTestDone: function testDone(status, result) {
if (result.failure) {
result.failure = makeErrorJsonable(result.failure);
}
- postMessage('onTestDone', result);
+ postMessage('onTestDone', status, result);
}
, onSuiteDone: function suiteDone(status, results) {
postMessage('onSuiteDone', status, results);
View
6 lib/console-runner.js
@@ -105,8 +105,8 @@ exports.run = function(list, options, callback) {
var opts =
{ parallel: options.testsParallel
, testName: options.testName
- , onTestDone: function(result) {
- testFinished(suite, result);
+ , onTestDone: function(status, result) {
+ testFinished(suite, status, result);
}
, onSuiteDone: function(status, results) {
suiteFinished(suite, status, results);
@@ -153,7 +153,7 @@ exports.run = function(list, options, callback) {
startNextSuite();
}
- function testFinished(suite, result) {
+ function testFinished(suite, status, result) {
suite.queuedTestResults.push(result);
if (suite.index == finishedIndex) {
while(suite.queuedTestResults.length) {
View
5 lib/testing.js
@@ -16,10 +16,11 @@ var assert = require('assert')
* + name: string, the name of the suite being ran
*
* Plus, there are options for the following events. These should be functions.
- * See API.md for a description of these events.
+ * See docs/running-tests.html for a description of these events.
*
* + onTestStart
* + onTestDone
+ * + onSuiteDone
*/
exports.runSuite = function(obj, options) {
// make sure options exists
@@ -206,7 +207,7 @@ exports.runSuite = function(obj, options) {
suite.results.push(test);
- if (options.onTestDone) { options.onTestDone(test); }
+ if (options.onTestDone) { options.onTestDone(test.failure ? 'failure' : 'success', test); }
process.nextTick(function() {
// if we have no more tests to start and none still running, we're done
View
6 lib/web-runner.js
@@ -184,8 +184,8 @@ exports.run = function(list, options) {
, onTestStart: function(name) {
workerHandlers.onTestStart(suite, name);
}
- , onTestDone: function(result) {
- workerHandlers.onTestDone(suite, result);
+ , onTestDone: function(status, result) {
+ workerHandlers.onTestDone(suite, status, result);
}
, onSuiteDone: function(status, results) {
workerHandlers['onSuite'+status.substr(0,1).toUpperCase()+status.substr(1)](suite, results);
@@ -297,7 +297,7 @@ exports.run = function(list, options) {
var msg = {cmd: 'testStart', suite: suite.index, name: name};
socket.broadcast(JSON.stringify(msg));
}
- , onTestDone: function(suite, result) {
+ , onTestDone: function(suite, status, result) {
suite.testsDone.push(result);
var msg = {cmd: 'testDone', suite: suite.index, result: result};
Please sign in to comment.
Something went wrong with that request. Please try again.