Generally speaking this is the task of the bootstrapping - see:
https://github.com/owncloud/core/blob/master/tests/phpunit-autotest.xml#L2
https://github.com/owncloud/core/blob/master/tests/bootstrap.php