Atomic testing
$ composer require try/tapping
<?php
require_once '/path/to/autoload.php';
use function Tapping\test;
test('some description of the test', function ($t) {
// throw an Exception or exit(1) to fail a test
});
Function to run an atomic test and output it's status.
Argument | Type | Description |
---|---|---|
$description | string |
The description what the test case is supposed to do. Will be output on test run with an indication of success or failure. |
$test | callable |
The test case encapsulated in an callable. The test case will be forked as a child process, so anything in the callable is encapsulated from the parent process. Needs to exit(1) or a thrown Exception to indicate test as failed (throwing an exception will render an error block). exit(0) or just nothing will mark the test as passed. |
Since the runner of the tests is pure php, it is necessary for the usage in CI pipelines or other build systems that the main test process exists with an error code. Tapping has a build in feature for this.
By providing script flags on script call, e.g.
$ php test.php --build
The test run will exit the whole process with -1
, as soon as the first test fails.
Flag aliases which trigger such behaviour are --build
and -b
.
In addition to the build flag, it is also possible to provide an --quite
(short -q
) flag to suppress fail information (File, Line and error that occured).
Function to show a notation for a test case, not yet written. As reminder or note or whatever.
Argument | Type | Description |
---|---|---|
$description | string |
The description of the test to be written. |
The $t
argument, is a container for prediction and likewise functions.
GPL-2.0 © Willi Eßer, Felix Buchheim