Coder Social home page Coder Social logo

jeroendedauw / eris Goto Github PK

View Code? Open in Web Editor NEW

This project forked from giorgiosironi/eris

0.0 1.0 0.0 1.48 MB

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

License: MIT License

PHP 98.96% Python 1.04%

eris's Introduction

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

  • PHP 5.5, 5.6, 7.0, 7.1
  • HHVM (without purePhpMtRand)
  • PHPUnit 5.x, 6.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.

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.

<?php
use Eris\Generator;

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

[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.)

eris's People

Contributors

davedevelopment avatar dbellettini avatar gabrielelana avatar garak avatar giorgiosironi avatar jdreesen avatar jeroendedauw avatar localheinz avatar mirkobonadei avatar montealegreluis avatar nicolopignarocket avatar silvadanilo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.