Currently we run code to setup the database in setUpBeforeClass. However this runs before every test class is tested. Is it possible to have code run once before any tests are run, and maybe run some code when all tests are complete too?
Currently we run code to setup the database in setUpBeforeClass. However this runs before
Share
This is precisely what the bootstrap file is designed to handle. By default PHPUnit will execute the code in
bootstrap.phpin the current directory. You can use thephpunit.xmlconfiguration file or the--bootstrapcommand-line switch to point to a different file.This file is executed exactly once before trying to locate the tests to be run. It allows you to set up an include path, autoloader, constants, etc. before instantiating or running any tests.