PHPUnit and Selenium: setUpBeforeClass () not called

I want to use setUpBeforeClass () to set up a db connection and do some logging, but it is not called before my tests run (or at all, for that matter). I have the following:

class TestSetup extends PHPUnit_Extensions_SeleniumTestCase {
    public static function setUpBeforeClass() {
        //do some setup stuff here for all my tests
    }
    protected function setUp() {
        $this->setBrowserUrl('http://' . $this->deviceIp);
    }
    protected function testOne() {
        //do a test here
    }
    protected function testTwo() {
        //do a test here
    }
}

I dug a little into PHPUnit / Frameworks / TestSuite.php and confirmed that on line 660 this $ this-> testCase is bool (false). But I could not understand if this should be true or where it should happen (except in __construct ()).

I am a little over my head, so any help would be greatly appreciated.

Let me know if I can provide any useful information.

Josh

+3
source share
1 answer

I could not find anything in the docs, but the code seems to agree with you.

PHPUnit/Extensions/SeleniumTestCase.php ( 289+) setUpBeforeClass ( , ).

, , phpunits issue tracker.

setUp :

protected function setUp() {
    static $db = null;
    if($db === null) {
        $db = whatevery_you_do_there();
    }
    $this->db = $db;
}

, , setUpBeforeClass()

+3

All Articles