定制 innmind/black-box 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

innmind/black-box

最新稳定版本:7.0.0

Composer 安装命令:

composer require innmind/black-box

包简介

Test library

README 文档

README

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.

统计信息

  • 总下载量: 187.77k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 44
  • 点击次数: 3
  • 依赖项目数: 79
  • 推荐数: 8

GitHub 信息

  • Stars: 44
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固