EcomDev_PHPUnit icon indicating copy to clipboard operation
EcomDev_PHPUnit copied to clipboard

Create new test scope for each test and not only once

Open fbrnc opened this issue 11 years ago • 0 comments

Currently applyTestScope is only called once for the top level suite (and discardTestScope is only called at the end of the top level suite).

It would be much better if ever test would run in complete isolation starting with a fresh testScope (included registry,...) in order to make sure that there are not side effects from left-overs from previous tests.

Currently this can be done without code changes in EcomDev_PHPUnit by adding adding following to the individual test class (or a shared common parent class)

protected function setUp() {
    EcomDev_PHPUnit_Model_App::applyTestScope();
    // ... do custom stuff if required
    parent::setUp();
}

protected function tearDown()
{
    parent::tearDown();
    // ... do custom stuff if required
    EcomDev_PHPUnit_Model_App::discardTestScope();
}

Please note that this relies on #178 being in place

fbrnc avatar Mar 05 '14 01:03 fbrnc