Welcome to BlackBox¶
BlackBox is a Property Based Testing framework.
It leverages randomness to prove the correctness of your code.
It's the main testing framework for the Innmind ecosystem.
It allows to:
- write tests (1)
- write proofs
- write properties
- generate random data
- Like any other PHP testing framework
Its Functional1 design also allows you to use it for your own scenarii.
Sneak peek
tests.php
use Innmind\BlackBox\{
Application
Set,
Runner\Assert,
};
Application::new([])
->scenariiPerProof(1_000)
->tryToProve(static function() {
yield proof(
'Add is commutative',
given(
Set\Integers::any(),
Set\Integers::any(),
),
static function(Assert $assert, int $a, int $b) {
$assert->same(
add($a, $b),
add($b, $a),
);
},
);
})
->exit();
-
As in Functional Programming ↩