Search code examples
phpcodeception

Codeception run before all tests inside a CEST


I want to run something before all the tests inside a particular Cest, and then clean it up after all tests have run, similar to the setUpBeforeClass and tearDownAfterClass method in PHPUnit.

Is there a method to do something like this in Codeception?


Solution

  • From Codeception point of view, Cest class is just a bunch of Cept scenarios. There is no object scope and no before/after class hooks.

    My advice is to use Test format instead and use PhpUnit hooks.

    Test format extends PHPUnit_Framework_TestCase so setUpBeforeClass should work.