sharedFixture

Discussion of testing theory and practice, including methodologies (such as TDD, BDD, DDD, Agile, XP) and software - anything to do with testing goes here. (Formerly "The Testing Side of Development")

Moderator: General Moderators

sharedFixture

Postby koen.h » Mon Nov 03, 2008 12:54 pm

I'm having a hard time finding out how to share my db connection. The phpunit manual addresses this topic but I don't know enough about phpunit to know how to implement it. Or I'm just not getting it.

Let's take this code:

Syntax: [ Download ] [ Hide ]
 
class Lib_AllTests extends PHPUnit_Framework_TestSuite {
    protected function setUp() {
        $this->sharedFixture = *mydatabaseconnection*;
    }
    public static function main() {
        PHPUnit_TextUI_TestRunner::run(self::suite());
    }
    public static function suite() {
        $suite = new PHPUnit_Framework_TestSuite('My Library');
        $suite->addTest(Lib_Package_AllTests::main());
        return $suite;
    }
}
 


The manual says this should be enough to have the sharedFixture available in the other tests (Lib_Package_AllTests). But it doesn't work.

What am I missing here?
koen.h
Forum Contributor
 
Posts: 268
Joined: Sat May 03, 2008 8:43 am

Return to Testing

Who is online

Users browsing this forum: No registered users and 0 guests

cron