mercredi 21 juin 2017

PHPUnit Append to testdox title

This is just an example test.

I'm trying to use testdox to show confirmation on the tests I've written.

<?php namespace Tests\Unit;

class Foo {
    const MINIMUM = 10;

    public function doSomething($number){
        if ($number < self::MINIMUM) {
            throw new \Exception();
        }
    }
}

class SampleTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @test
     *
     * @expectedException \Exception
     */
    public function can_not_go_below_minimum()
    {            
        (new Foo)->doSomething(9);
    }
}

Testdox Output

s\Unit\Sample
 [x] Can not go below minimum

Ideally, the doc would display the actual current minimum.

Is it possible to append Foo::MINIMUM to the testdox output? Something similar to the way a dataprovider does. That would mean If Foo::MINIMUM were to change in the future, the test wouldn't need to be modified.

Aucun commentaire:

Enregistrer un commentaire