doc: clarify the exit code part of writing_tests

PR-URL: https://github.com/nodejs/node/pull/9502
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Jeremiah Senkpiel 2016-11-07 09:27:37 -05:00
parent 843770406b
commit 4affb8929f

View File

@ -3,11 +3,13 @@
## What is a test?
A test must be a node script that exercises a specific functionality provided
by node and checks that it behaves as expected. It should return 0 on success,
by node and checks that it behaves as expected. It should exit with code `0` on success,
otherwise it will fail. A test will fail if:
- It exits by calling `process.exit(code)` where `code != 0`
- It exits due to an uncaught exception.
- It exits by setting `process.exitCode` to a non-zero number.
- This is most often done by having an assertion throw an uncaught
Error.
- Occasionally, using `process.exit(code)` may be appropriate.
- It never exits. In this case, the test runner will terminate the test because
it sets a maximum time limit.