• Stars
    star
    411
  • Rank 105,247 (Top 3 %)
  • Language
    PHP
  • License
    MIT License
  • Created about 10 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

Eris

CI Static analysis 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 7.4, 8.0, 8.1, 8.2
  • PHPUnit 8.x, 9.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\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.)

More Repositories

1

phpunit-selenium

Selenium RC integration for PHPUnit
PHP
600
star
2

game-of-life-modern-java

Game Of Life implemented in Java with modern tools and language constructs
Java
57
star
3

pug

PHP UML Generator
PHP
38
star
4

practical-php-testing-patterns

Code from the Practical PHP Testing Patterns series
PHP
36
star
5

ddd-talk

Code for my talk Pursuing Domain-Driven Design practices in PHP
PHP
23
star
6

python-tdd-tutorial

Python
13
star
7

Practical-Php-Testing

Ebook
7
star
8

erlang-series

Erlang
7
star
9

NakedPhp

Direct manipulation interface for PHP objects (Naked Objects pattern)
PHP
6
star
10

offline-web-application-example

Code for the article
PHP
5
star
11

game-of-life-javascript

A MEAN stack implementation of the Game of Life
JavaScript
5
star
12

practical-php-refactoring

PHP
5
star
13

jenkins-cd-workshop

Continuous Delivery with Jenkins 2 workshop
Shell
4
star
14

behat-examples

Behat usage example
PHP
4
star
15

doctrine2-phar

Scripts for packaging Doctrine 2 as a Phar
PHP
4
star
16

gameoflife-oo

My first full implementation of the Game of Life
PHP
4
star
17

getters-setters-php

Removal of PHP getters and setters
PHP
4
star
18

extreme-oop

PHP
4
star
19

javascript-classical-inheritance

Examples of inheritance in JS
3
star
20

password-strength-checker

Exercise on TDD
PHP
3
star
21

coffeescript-tdd

A TDD example with jsTestDriver and CoffeeScript
CoffeeScript
3
star
22

sicp-exercises

Scheme
2
star
23

jquery.maxHeight

JavaScript
2
star
24

erlang-2pc

Naive implementation of 2 Phase Commit in Erlang
Erlang
2
star
25

prime-factors-kata

Kata where the prime factors for a given integer must be generated
PHP
2
star
26

clojure-midje-example

Showing how to install midje (or any other library) and run code with Leiningen
Clojure
2
star
27

roman-numerals-kata

PHP
2
star
28

r-bayes-classifier

R
2
star
29

Chansonnier

Search application that indexes songs imported from the web
Java
2
star
30

totally-distributed-game-of-life

Implementing Game of Life on the Erlang VM
Elixir
2
star
31

doctrine-odm-orm-integration

PHP
1
star
32

dzone-csslayouts

CSS layouts article's code
1
star
33

dotfiles

Vim Script
1
star
34

roman-numerals-reuse

The Roman numerals kata, with the twist of supporting both additional-subtractive and pure additional notation. Refactoring towards composable rules
PHP
1
star
35

behat-tables-kata

Exercising with tabular data in Behat to avoid Given/When/Then duplication
PHP
1
star
36

decorator-javascript

A pattern similar to Decorator implemented in JavaScript
JavaScript
1
star
37

Refactoring-breakthrough

Example of TDD and continuos refactoring in PHP
PHP
1
star
38

fizzbuzz-nodejs

FizzBuzz implementation as a Node.js module
JavaScript
1
star
39

euler-17

Solution to Euler Project, problem 17
PHP
1
star
40

julia-hello-world

Testing the capabilities of the Julia programming language
Julia
1
star
41

testing-in-isolation

All the code from my tutorial Testing in isolation at the Dutch PHP Conference 2011
PHP
1
star
42

clojure-web-hello-world-ring

Sample code for an Hello World web app in Clojure
Clojure
1
star
43

composer-book-club

PHP
1
star
44

urban-priority-infraction-detector

Project for detecting failure to give priority in road intersections not regulated by traffic lights (urban environment)
MATLAB
1
star
45

order-amount-calculation

PHP
1
star
46

sign-manipulations-detector

Matlab implementation of text manipulation detection algorithm
Objective-C
1
star
47

fizzbuzz-js

FizzBuzz kata in JavaScript with jsTestDriver (TDD in JavaScript)
JavaScript
1
star
48

gameoflife-haskell

Haskell
1
star
49

fizzbuzz-clojure

My first Clojure kata
Clojure
1
star
50

docker-tutorial

Small Docker tutorial introducing containers, images, volumes and such.
PHP
1
star
51

polimi-database2-couchdb

A small CouchDB project for the Database Systems 2 course.
JavaScript
1
star