Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Black Box Laravel Package

innmind/black-box

View on GitHub
Deep Wiki
Context7

BlackBox

CI codecov Type Coverage

BlackBox is a Property Based Testing framework and test runner.

Property Based Testing is a way to verify a piece of code always behave the same way (aka a Property) by testing it with multiple values of a given type.

The common introduction to this approach is the add function that has 3 properties:

  • it is commutative
  • it is associative
  • it is an identity function

To prove this via BlackBox you can do it this way:

use Innmind\BlackBox\{
    Application,
    Set,
    Runner\Assert,
    Prove,
};

Application::new([])
    ->tryToProve(static function(Prove $prove) {
        yield $prove
            ->proof('add is commutative')
            ->given(
                Set::integers(),
                Set::integers(),
            )
            ->test(static fn(Assert $assert, int $a, int $b) => $assert->same(
                add($a, $b),
                add($b, $a),
            ));

        yield $prove
            ->proof('add is associative')
            ->given(
                Set::integers(),
                Set::integers(),
                Set::integers(),
            )
            ->test(static fn(Assert $assert, int $a, int $b, int $c) => $assert->same(
                add(add($a, $b), $c),
                add($a, add($b, $c)),
            ));

        yield $prove
            ->proof('add is an identity function')
            ->given(Set::integers())
            ->test(static fn(Assert $assert, int $a) => $assert->same(
                $a,
                add($a, 0),
            ));
    })
    ->exit();

By default BlackBox will generate 100 scenarii for each proof.

[!NOTE] BlackBox use the term proof to emphasize that you are testing behaviours not specific scenarii, but these are NOT formal proofs

Installation

composer require --dev innmind/black-box

Documentation

Full documentation can be found in the here.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky