diff --git a/lib/base.php b/lib/base.php
index cc710fc7207e553b89da26b47980f07670caa2a3..2515b9657cbc8e5b5af626340ea238c83bbc42ac 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -98,7 +98,9 @@ class OC {
 			get_include_path()
 		);
 
-		if(defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) {
+		if(defined('PHPUNIT_CONFIG_DIR')) {
+			self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/';
+		} elseif(defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) {
 			self::$configDir = OC::$SERVERROOT . '/tests/config/';
 		} else {
 			self::$configDir = OC::$SERVERROOT . '/config/';
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 581cfcff9f304ffcc7704b0c3920157aa4859eac..70de7cd1c44a20112d5769f763f54251f97b8cb9 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -3,9 +3,14 @@
 
 define('PHPUNIT_RUN', 1);
 
-require_once __DIR__.'/../lib/base.php';
+$configDir = getenv('CONFIG_DIR');
+if ($configDir) {
+	define('PHPUNIT_CONFIG_DIR', $configDir);
+}
+
+require_once __DIR__ . '/../lib/base.php';
 
-if(!class_exists('PHPUnit_Framework_TestCase')) {
+if (!class_exists('PHPUnit_Framework_TestCase')) {
 	require_once('PHPUnit/Autoload.php');
 }