Peter Test Framework
At it's core, Peter was designed with the following intention in mind:
Testing should be as simple as running the file by itself.
npm i peter
# Look in the tests/ directory for test files npx peter tests/
|2.2.0||June 2021||Add JUnit XML output|
A peter driver is a module which is responsible for handling files with a specific file extension. The following drivers are included with Peter by default:
|Driver Name||File Extension||Description|
||This driver will execute Bash scripts as tests, and assert that the exit code of the script is 0.|
Note that files with the
.js extension are ignored by Peter so that utility scripts can be written alongside the test scripts.
To run the example tests (Peter's self tests), run:
Debugging Simple Tests
If a .simple test fails, you can debug it using
This file will use niim by default, but
--debugger=<debugger> can be used to specify a debugger. A
debugger; call is also automatically added to the start of the
.simple file being debugged.
Peter is a Pragmatic, Extensible Test Environment / Runner. It was built based on the observation that developers tend to write a lot of little tests during
the course of development, but these little tests tend not to get captured into unit tests. The idea with Peter, in particular the simple tests, is to make
it possible for developers to simply take these tests -- often one or two lines of code -- and move them into their
peter directory, where they become simple
pass/fail unit tests.
./peter is a test runner, which executes tests in random order and in parallel by traversing directories. The test runner discovers the type of test based on the test's file
extension. This file extension is then used to select the appropriate test driver, and the test is run. Certain extensions, such as
.js, are reserved for library code which
could be used by multiple tests. If the test filename begins with the mathematical not symbol,
¬, the sense of the test is inverted (i.e. a pass becomes a fail and vice-versa).
Simple tests run in NodeJS. If the file throws an uncaught exception or exits with a non-zero exit code, it fails; otherwise it passes.
The Simple test driver plumbs in top-level await on Node to make async/await tests easy to run. Individual tests which run directly in NodeJS
will run as .simple tests with no changes. Tests written specifically for this test driver can be run individually via
A special shout-out to Peter DeMartini, who let us have the Peter npm name. Peter is awesome - the end!
Peter was written and is maintained by the team at Kings Distributed Systems. We use it internally to test the Distributed Computer.
- Wes Garland
- Ryan Rossitter
- Ryan Saweczko
- Andrew Fryer
- James McDonald
- Parker Rowe