Running custom code after completing the Codeception suite

I know the _bootstrap.php file that was used to set up the testing environment, etc., but I'm looking for a way to run some code after the completion of the entire test suite.

Please note that I am not looking for a way to run the code after one class, i.e. something like _after, but after all the classes.

Is there any way to achieve this?

+4
source share
2 answers

In fact, I managed to solve this myself, here's how, if someone is interested.

I created a new helper class inside _support.

<?php

class DataHelper extends \Codeception\Module
{
    public function _beforeSuite()
    {
        // Set up before test suite
    }

    public function _afterSuite()
    {
        // Tear down after test suite
    }
}

You can then enable this as a module in any set configuration (.yml files), for example:

modules:
    enabled:
        - DataHelper
+4
source

@ Sacha , .

( ), Helper .

, _afterSuite Acceptance Suite, support/AcceptanceHelper.php . :

<?php
namespace Codeception\Module;

// here you can define custom actions
// all public methods declared in helper class will be available in $I

class AcceptanceHelper extends \Codeception\Module
{
    public function _afterSuite() {
        die('everything done');
    }
}
+3

All Articles