Good day.

We are talking about acceptance tests. In the description of the test is the condition, for example, the time of the test is not more than 15 seconds.

Is there any method by which you can get the test time (just one) to continue to write it somewhere in the log for further analysis?

    1 answer 1

    To monitor the test execution process, Codeception provides a powerful Extensions mechanism. You can define your own extension, which gets the test time after its execution and saves this value where you need it.

    For example, I will give an extension code that displays in the console the path of the executed test script and the time of its execution.

    tests / _support / TimingExtension.php :

    <?php class TimingExtension extends \Codeception\Extension { public static $events = array( 'test.after' => 'afterTest', ); public function afterTest(\Codeception\Event\TestEvent $e) { echo(sprintf( "%s: %s\n", $e->getTest()->getMetadata()->getFilename(), $e->getTime() )); } } 

    In order for this extension to work, you need to connect it in the extensions section of the main Codeception configuration file ( codeception.yml ).

    tests / codeception.yml :

     # ... extensions: enabled: - TimingExtension # Прочие расширения, которые уже были здесь - Codeception\Extension\RunFailed # ... 

    More information about connecting your own extensions can be found in the documentation .

    • Thanks Dmitry! - DmitryJS