Codeception: test data in annotation - codeception reports undefined variable



  • I've tried to use this style: https://codeception.com/docs/07-AdvancedUsage#Example-Annotation

    My example test case is this:

    /**
     * @example { "groupid": "16789507", "partnerccdid": "31003704" }
    */
    public function getPartnerCcdIdWithGroupId(ApiTester $I)
    {
        $I->see($example["groupid"]);
    }  
    

    When I run this using this command: php codecept.phar run -vvv I only get the following error:

    [PHPUnit\Framework\Exception] Undefined variable: example
    

    According to https://jsonformatter.curiousconcept.com/, it's a valid JSON. I'm using it the way they explain in the official documentation, all my strings are enclosed in double quotes.

    What am I missing here?

    Thank you

    EDIT: I'm actually trying to use SOAP module and test an API. Just a thought crossed my mind... is this annotation style allowed with the module and ApiTester? Because I can't figure out what else could possibly be wrong.



  • You do not pass in the $example as described in the documentation:

    public function getPartnerCcdIdWithGroupId(ApiTester $I, \Codeception\Example $example)
    


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 3
  • 2