giorgiosironi/eris
Composer 安装命令:
composer require giorgiosironi/eris
包简介
PHP library for property-based testing. Integrates with PHPUnit.
README 文档
README
Eris is a porting of QuickCheck and property-based testing tools to the PHP and PHPUnit ecosystem.
In property-based testing, several properties that the System Under Test must respect are defined, and a large sample of generated inputs is sent to it in an attempt to break the properties.
Compatibility
- PHP 8.1, 8.2, 8.3, 8.4
- PHPUnit 10.x, 11.x, 12.x, 13.x
Installation
You can install Eris through Composer by running the following command in your terminal:
composer require --dev giorgiosironi/eris
You can run some of Eris example tests with vendor/bin/phpunit vendor/giorgiosironi/eris/examples.
Here is an empty sample project installing Eris.
Example usage within PHPUnit
This test tries to verify that natural numbers from 0 to 1000 are all smaller than 42. It's a failing test designed to show you an example of error message.
<?php use Eris\Generators; class ReadmeTest extends \PHPUnit\Framework\TestCase { use \Eris\TestTrait; public function testNaturalNumbersMagnitude() { $this->forAll( Generators::choose(0, 1000) ) ->then(function($number) { $this->assertTrue( $number < 42, "$number is not less than 42 apparently" ); }); } }
Eris generates a sample of elements from the required domain (here the integers from 0 to 1000) and verifies a property on each of them, stopping at the first failure.
[10:34:32][giorgio@Bipbip:~/code/eris]$ vendor/bin/phpunit examples/ReadmeTest.php PHPUnit 4.3.5 by Sebastian Bergmann. Configuration read from /home/giorgio/code/eris/phpunit.xml F Time: 234 ms, Memory: 3.25Mb There was 1 failure: 1) ReadmeTest::testNaturalNumbersMagnitude 42 is not less than 42 apparently Failed asserting that false is true. /home/giorgio/code/eris/examples/ReadmeTest.php:15 /home/giorgio/code/eris/src/Eris/Quantifier/Evaluation.php:48 /home/giorgio/code/eris/src/Eris/Quantifier/RoundRobinShrinking.php:45 /home/giorgio/code/eris/src/Eris/Quantifier/ForAll.php:69 /home/giorgio/code/eris/src/Eris/Quantifier/Evaluation.php:50 /home/giorgio/code/eris/src/Eris/Quantifier/ForAll.php:71 /home/giorgio/code/eris/src/Eris/Quantifier/ForAll.php:87 /home/giorgio/code/eris/examples/ReadmeTest.php:16 /home/giorgio/code/eris/examples/ReadmeTest.php:16 FAILURES! Tests: 1, Assertions: 826, Failures: 1.
Eris also tries to shrink the input after a failure, giving you the simplest input that still fails the test. In this example, the original input was probably something like 562, but Eris tries to make it smaller until the test became green again. The smallest value that still fails the test is the one presented to you.
Documentation
On ReadTheDocs you can find the reference documentation for the Eris project.
Changelog
Consult the Changelog file to know the latest new features.
Support and contributing
Feel free to open issues on the GitHub project for support and feature requests.
Pull requests are welcome. For anything longer than a few lines it's worth to open an issue first to get feedback on the intended solution and whether it will integrate well with the rest of the codebase.
If you contribute a commit to Eris, you will be credited in the contributors file (unless you don't want to.)
giorgiosironi/eris 适用场景与选型建议
giorgiosironi/eris 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.43M 次下载、GitHub Stars 达 438, 最近一次更新时间为 2014 年 12 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 giorgiosironi/eris 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 giorgiosironi/eris 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.43M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 440
- 点击次数: 18
- 依赖项目数: 78
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2014-12-07