Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@dataProvider in Cest format in Codeception

How shall I use "@dataProvider" in Cest format? (http://codeception.com/docs/05-UnitTests#Cest) For example I have this code. How to write it in Cest format

class ExampleTest extends \Codeception\TestCase\Test
{
    /**
     * @dataProvider providerAdd
     */
    public function testAdd($a, $b, $c)
    {
        $this->assertEquals($c, ($a + $b));
    }

    public function providerAdd()
    {
        return array (
            array (2, 2, 4),
            array (2, 3, 5),
            array (3, 5, 8)
        );
    }
}
like image 958
Mykola Avatar asked Sep 12 '26 15:09

Mykola


1 Answers

Since Codeception 2.2 there is a better alternative, using 'examples': http://codeception.com/docs/07-AdvancedUsage#examples

This is a Cest-style implementation of what you know as dataProviders in unit/functional tests. It currently only allows to supply data sets in annotations, but it's workable...

like image 77
Bart Dens Avatar answered Sep 15 '26 04:09

Bart Dens



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!