2011-03-12 172 views
2

我有2个目录:project1和project2。当我在project1/tests中运行PHPUnit时,它工作正常。当我在project2/tests中运行它时,它工作正常,但不会生成任何代码覆盖率报告。 phpunit.xml配置文件实际上是相同的。每个调用的bootstraps都有一些不同,但我不认为这些是重要的。 (我检查了路径,他们很好)。PHPUnit不会创建代码覆盖率报告ZendFW

任何想法?我该如何去诊断这个问题?

下面是从项目2 /测试phpunit.xml:

<phpunit bootstrap="./TestBootstrap.php"> 
<testsuite name="OpenCompany"> 
    <directory>./</directory> 
</testsuite> 
<filter> 
    <whitelist> 
     <directory suffix=".php">..\library\</directory> 
     <directory suffix=".php">..\application\</directory> 
     <exclude> 
      <directory suffix=".phtml">..\application\</directory> 
     </exclude> 
    </whitelist> 
</filter> 
<logging> 
    <log type="coverage-html" target="./output/report" charset="UTF-8" yui="true" highlight="false" lowUpperBound="35" highLowerBound="70"/> 
    <log type="coverage-clover" target="./output/coverage.xml"/> 
    <log type="json" target="./output/logfile.json"/> 
    <log type="tap" target="./output/logfile.tap"/> 
    <log type="junit" target="./output/logfile.xml" logIncompleteSkipped="false"/> 
    <log type="testdox-html" target="./output/testdox.html"/> 
    <log type="testdox-text" target="./output/testdox.txt"/> 
</logging> 

而这里的TestBootstrap.php:

<?php 

// Adapted from tutorial by Matthew Weier O'Phinney 
// Tutorial is dated 11/09/2008 

// Set location 
date_default_timezone_set('Australia/Sydney'); 

// Set Error Reporting to All, Strict 
error_reporting(E_ALL | E_STRICT); 

// Sets include paths relative to location of TestBootstrap.php 
$root   = realpath(dirname(__FILE__).'/../'); // resolves to project directory 
$library  = $root.'/library'; 
$tests   = $root.'/tests'; 
$models   = $root.'/application/models'; 
$dbtables  = $root.'/application/models/DbTable'; 
$controllers = $root.'/application/controllers'; 

$path = array($models, $library, $dbtables, $tests, get_include_path()); 
set_include_path(implode(PATH_SEPARATOR, $path)); 

// Set Application Constants 
if (!defined('APPLICATION_PATH')) {define('APPLICATION_PATH', $root.'/application');} 
if (!defined('APPLICATION_ENV')) {define('APPLICATION_ENV', 'testing');} 

// Get Autoloading happening 
require_once 'Zend/Loader/Autoloader.php'; 
Zend_Loader_Autoloader::getInstance(); 

// Setup a default DB connection 
$db = Zend_Db::factory('Pdo_Mysql', array(
     'host'  => 'localhost', 
     'username' => 'root', 
     'password' => '', 
     'dbname' => 'openco_v1_0' 
     ) 
    ); 
Zend_Db_Table_Abstract::setDefaultAdapter($db); 

// Store some stuff in the registry 
// Zend_Registry::set('testRoot', $root); 
// Zend_Registry::set('testBootstrap', $root.'/application/bootstrap.php'); 

// Unset global variables that are no longer required 
unset($root, $library, $models, $dbtables, $controllers, $tests, $path); 

任何援助表示赞赏!

+0

是否安装和/或启用了xdebug扩展? – Marcin 2011-03-12 04:59:24

回答

2

好的,整理一下。模型中存在错误(可能是解析错误),所以PHPUnit无法理解代码以确定测试覆盖了多少。

我排除了白名单中的/ applications/models测试,现在工作正常。一旦我完成了模型并修复了错误,我将删除排除。

相关问题