Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: tweak testing notes for readability #113

Merged
merged 2 commits into from
Apr 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions packages/opentelemetry-node/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,32 +71,33 @@ npm run test-services:stop redis

## Requirements for writing test files

**All test files MUST match the `test/**/*.test.js` glob pattern.**
1. **All test files MUST match the `test/**/*.test.js` glob pattern.**

**A test file MUST be runnable independently.** I.e. one can execute
`node test/foo.test.js` independent of other test files.
2. **A test file MUST be runnable independently.**<br/>
I.e. one can execute `node test/foo.test.js` independent of other test files.

**A test file MUST exit with non-zero status to indicate failure.**
3. **A test file MUST exit with non-zero status to indicate failure.**

**A test file SHOULD generate TAP output.**
4. **A test file SHOULD generate TAP output.**

For test files that require a running test service:
In addition, for test files that require a running test service:

- **They MUST use an envvar to indicate whether to run and MUST skip testing if that envvar is not defined.**
That envvar name **SHOULD** match `${NAME_OF_SERVICE}_*`, e.g. `REDIS_HOST`,
and **the skip message MUST include "SKIP" and the envvar name.**
For example, running [the ioredis test](./test/instr-ioredis.test.js)
includes this output:
5. **They MUST use an envvar to indicate whether to run and MUST skip testing if that envvar is not defined.**<br/>
trentm marked this conversation as resolved.
Show resolved Hide resolved
That envvar name **SHOULD** match `${NAME_OF_SERVICE}_*`, e.g. `REDIS_HOST`,
and **the skip message MUST include "SKIP" and the envvar name.** The reason
for this requirement is so that `npm run test:without-test-services` works.
For example, running [the ioredis test](./test/instr-ioredis.test.js)
includes this output:

```
$ node test/instr-ioredis.test.js
# SKIP ioredis tests: REDIS_HOST is not set (try with `REDIS_HOST=localhost`)
...
```

- **They SHOULD fail quickly if the requisite test service is not up.**
For example, running the ioredis test with `REDIS_HOST` set but no running
Redis, fails within a couple seconds:
6. **They SHOULD fail quickly if the requisite test service is not up.**<br/>
For example, running the ioredis test with `REDIS_HOST` set but no running
Redis, fails within a couple seconds:

```
$ time REDIS_HOST=localhost node test/instr-ioredis.test.js
Expand Down