@dataProvider in Cest format in Codeception

How to 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)
        );
    }
}

      

+3


source to share


4 answers


Since Codeception 2.2 has a better alternative, use "examples": http://codeception.com/docs/07-AdvancedUsage#examples



This is a Cest-style implementation that you know as dataProviders in unit / functional tests. Currently it only allows you to feed datasets into annotations, but it is workable ...

+2


source


The @data p rovdier annotation works for me now in Codeception as docs on the website (or docs / 07-AdvancedUsage.md), but note that the annotation is case sensitive @data p rovdier not @dataProvdier.



http://codeception.com/docs/07-AdvancedUsage#Cest-Classes

+2


source


Could you explain a little to you what you need? The Cest format simply takes public functions and runs them as single tests. So you want to run two public functions like tests?

0


source


@dataProvider

is a PHPUnit annotation that is not evaluated in Cest or Cept execution.

If you want to write tests in TDD / BDD style, you can follow the Codeception guidelines . In addition, Specify supports examples , which can replace the use of php annotations.

0


source







All Articles