Search code examples
phptestingcodeception

CodeCeption - passing options to a helper


Is it possible to pass a config parameter to helper class which extends the \Codeception\Module class. I have the following case, I want in my api.suite.yml config file in the module enabled section to set for example Helper\Api and to set its on cofig property.

My idea is to has different environment with different config properties. Is that possible?

class_name: ApiTester
modules:
    enabled:
      - \Helper\Api:      # This is my module
        my_path: C://ssss # This is my custom option I want to pass.

My module class.

class Api extends \Codeception\Module
{
    protected $requiredFields = ['my_path'];
    ...
}

When I ran the suite it fails with:

  [Codeception\Exception\ModuleConfigException]
  Helper\Api module is not configured!

  Options: my_path are required
  Please, update the configuration and set all the required fields

Solution

  • You had to indent parameter more: class_name: ApiTester modules: enabled: - \Helper\Api: # This is my module my_path: C://ssss # This is my custom option I want to pass.