2012-04-23 5 views
13

단위 테스트 Zend Framework 어플리케이션으로 로프를 배우고 있습니다. 지금까지 Zend Framework과 작동하도록 PHPUnit을 설정하고 간단한 테스트 사례를 작성하기 시작했습니다.PHPUnit 코드 커버리지

내 문제는 내 phpunit.xml의 로깅 태그에 설정되었지만 Code Coverage이 작동하지 않는 이유가 궁금합니다.

오류는 발생하지 않지만 적용 범위 보고서가 생성되지 않습니다.

<phpunit bootstrap="./application/bootstrap.php" colors="true"> 
     <testsuite name="CI Test Suite"> 
      <directory>./</directory> 
     </testsuite> 
     <testsuite name="Library Test Suite"> 
      <directory>./library</directory> 
     </testsuite> 

     <filter> 
      <whitelist> 
       <directory suffix=".php">../application/</directory> 
       <exclude> 
        <directory suffix=".phtml">../application</directory> 
        <file>../application/Bootstrap.php</file> 
        <file>../application/controllers/ErrorController.php</file> 
       </exclude> 
      </whitelist> 
      <logging> 
       <log type="coverage-html" target="./log/report" charset="UTF-8" yui="true" 
    highlight="true" lowUpperBound="50" highLowerBound="80" /> 
       <log type="testdox" target="./log/testdox.html" />  
      </logging> 
     </filter> 
    </phpunit> 

누구나 전에이 발생 : 나는 phpunit --coverage <dir>

을 실행 내 phpunit을의 로깅 섹션은 다음과 같습니다 때

그러나 그것은 작동? 그렇다면 무엇이 문제일까요?

+3

필자의 로깅이 필터 안에 중첩되어 있지 않습니다. 약간의 차이가있을 수 있습니다. –

답변

23

내 프로젝트 중 하나에 대한 phpunit.xml은 다음과 같습니다. 보시다시피 로깅 섹션은 필터 섹션 외부에 있으므로 Mark Baker가 논평 한 문제 일 수 있습니다. 저는 작은 프로젝트에서와 같이이 것을 선택했고 매우 간단합니다.

<phpunit bootstrap="./bootstrap.php" colors="false"> 
    <testsuite name="HSSTests"> 
     <directory>./</directory> 
    </testsuite> 

    <filter> 
     <whitelist> 
      <directory suffix=".php">d:/wamp/app_hss/</directory> 
      <exclude> 
       <directory suffix=".phtml">d:/wamp/app_hss/</directory> 
       <directory suffix=".php">d:/wamp/app_hss/tests/</directory> 
      </exclude> 
     </whitelist> 
    </filter> 

    <logging> 
     <log type="coverage-html" target="./log/codeCoverage" charset="UTF-8" 
      yui="true" highlight="true" 
      lowUpperBound="50" highLowerBound="80"/> 
     <log type="testdox-html" target="./log/testdox.html" /> 
    </logging> 
</phpunit> 

이 모든 정보는 PHPunit manual입니다.

+0

당신은 절대적으로 옳습니다! 로깅 섹션은 필터 섹션 내에 없어야합니다. – stevepop