wmde/eris

Name: eris

Owner: Wikimedia Deutschland e.V.

Description: Eris is a porting of Quickcheck and property-based testing tools to the PHP and PHPUnit ecosystem.

Forked from: giorgiosironi/eris

Created: 2017-09-16 19:47:44.0

Updated: 2017-09-16 19:47:45.0

Pushed: 2017-09-18 12:22:33.0

Homepage:

Size: 1519

Language: PHP

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Eris

Build Status Documentation Status License: MIT

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
Installation

You can install Eris through Composer by running the following command in your terminal:

oser 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.

Please note the project is in alpha stage and the API may change at any time.

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.

p
Eris\Generator;

s ReadmeTest extends \PHPUnit_Framework_TestCase

use \Eris\TestTrait;

public function testNaturalNumbersMagnitude()
{
    $this->forAll(
        Generator\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.

34:32][giorgio@Bipbip:~/code/eris]$ vendor/bin/phpunit examples/ReadmeTest.php
nit 4.3.5 by Sebastian Bergmann.

iguration read from /home/giorgio/code/eris/phpunit.xml



: 234 ms, Memory: 3.25Mb

e was 1 failure:

eadmeTest::testNaturalNumbersMagnitude
s not less than 42 apparently
ed asserting that false is true.

e/giorgio/code/eris/examples/ReadmeTest.php:15
e/giorgio/code/eris/src/Eris/Quantifier/Evaluation.php:48
e/giorgio/code/eris/src/Eris/Quantifier/RoundRobinShrinking.php:45
e/giorgio/code/eris/src/Eris/Quantifier/ForAll.php:69
e/giorgio/code/eris/src/Eris/Quantifier/Evaluation.php:50
e/giorgio/code/eris/src/Eris/Quantifier/ForAll.php:71
e/giorgio/code/eris/src/Eris/Quantifier/ForAll.php:87
e/giorgio/code/eris/examples/ReadmeTest.php:16
e/giorgio/code/eris/examples/ReadmeTest.php:16

URES!
s: 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.)


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.