Search code examples
phpyii2automated-testsintegration-testingcodeception

How to run tests from renamed or not default folder?


Yii2 has tests folder structure:

- tests
  - _data/
  - _output/
  - _support/
  - acceptance/
  - functional/
  - unit/
  - _bootstrap.php
  - acceptance.suite.yml.example
  - functional.suite.yml
  - unit.suite.yml

Я set up tests via PhpStorm and Codeception. It works fine. Test can be launched successfully. But I want to do integrational tests. I made a integrational folder, wrote test, clicked "Run" and this test didn't run. I mean, codeception didn't even go into the folder.

If I rename unit folder into unit2 or functional into functional2, then I get thr error:

Running with seed:

In Bootstrap.php line 31: Bootstrap file /var/www/myproject/tests/functional/_bootstrap.php can't be loaded

I thought that paths is hardcoded. But Bootstrap.php has the lines:

public function loadBootstrap(SuiteEvent $e)
{
    $settings = $e->getSettings();
    //....
    
    $bootstrap = $settings['path'] . $settings['bootstrap'];
    if (!is_file($bootstrap)) {
        throw new ConfigurationException("Bootstrap file $bootstrap can't be loaded");
    }

    require_once $bootstrap;
}

Anyway. How do I configure settings (and where) to be available to run tests from the custom named folder? How to run integrational tests from integrational folder for example?


Solution

  • The Answer wrote Dmitriy Eliseev from https://yiiframework.ru/forum/viewtopic.php?p=273945#p273945

    It's so simple.

    The suites are picked up from *.suite.yml files.

    So,in addition to unit.suite.yml and functional.suite.yml inside tests folder you should add an integrational.suite.yml file with settings. In this case tests from integrational folder will be work as well.