2012-04-23 25 views
13

मैं इकाई परीक्षण Zend Framework अनुप्रयोगों के साथ रस्सियों को सीख रहा हूं। अब तक Zend Framework के साथ काम करने के लिए मैंने PHPUnit सेट अप किया है और कुछ सरल टेस्ट केस लिखना शुरू कर दिया है।PHPUnit कोड कवरेज

मेरी समस्या यह है कि मैं सोच रहा हूं कि क्यों Code Coverage मेरे phpunit.xml में लॉगिंग टैग में सेट होने के बावजूद काम नहीं करता है।

मुझे कोई त्रुटि नहीं मिली है लेकिन कोई कवरेज रिपोर्ट नहीं बनाई गई है।

हालांकि यह काम करता है जब मैं phpunit --coverage <dir>

चलाने मेरी PHPUnit के प्रवेश खंड के रूप में नीचे है:

<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> 

किसी को भी करने से पहले इस मुठभेड़? तब संभावित समस्या क्या है?

+3

मेरे पास फ़िल्टर के अंदर घोंसला लॉगिंग नहीं है .... इससे थोड़ा अंतर हो सकता है –

उत्तर

23

यहां मेरी परियोजनाओं में से एक के लिए phpunit.xml है, यह ठीक काम करता है। जैसा कि आप देख सकते हैं, लॉगिंग अनुभाग फ़िल्टर सेक्शन के बाहर है, इसलिए शायद मार्क बेकर द्वारा टिप्पणी की गई आपकी समस्या है। मैंने इसे एक चुना क्योंकि यह एक छोटी परियोजना से है और यह बहुत आसान है।

<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

संबंधित मुद्दे