2013-05-18 6 views
12

किसी भी टिप्पणी के लिए अग्रिम धन्यवाद। मैंने ज़ेन फ्रेमवर्क 1 से ज़ेडएफ 2 में स्विच करना शुरू कर दिया है और त्वरित शुरुआत और कई अन्य ट्यूटोरियल्स के माध्यम से चलने के बाद मैंने देखा कि phpunit का उपयोग करने के लिए 'डिफ़ॉल्ट' तरीके से एक छोटा सा आ रहा है। या तो वह या मैं अभी खो गया हूं और उलझन में हूं।ज़ेंड फ्रेमवर्क 2 + phpunit + एकाधिक मॉड्यूल + निरंतर एकीकरण

एक डिफ़ॉल्ट परियोजना के लिए फ़ोल्डर संरचना

Project 
| - config 
| | - autoload 
| | | - global.php 
| | | - local.php.dist 
| | - application.config.php 
| - data 
| - module 
| | - Application 
| | | - config 
| | | - src 
| | | - test 
| | | | - ApplicationTest 
| | | | - Bootstrap.php 
| | | | - phpunit.xml 
| | | | - TestConfig.php.dist 
| | | - view 
| | | - Module.php 
| | - Album 
| | | - config 
| | | - src 
| | | - test 
| | | | - AlbumTest 
| | | | - Bootstrap.php 
| | | | - phpunit.xml 
| | | | - TestConfig.php.dist 
| | | - view 
| | | - Module.php 
| - public 
| - vendor 

है मेरा प्रश्न यह है कि कैसे मैं चींटी के साथ जेनकींस का उपयोग करते हैं PHPUnit परीक्षण स्वीट के सभी परीक्षण करने के लिए है। मैं व्यक्तिगत रूप से प्रत्येक मॉड्यूल का परीक्षण करने के पीछे कारण समझता हूं लेकिन एक रिपोर्ट प्राप्त करने के लिए मैं इसे स्वचालित रूप से कैसे स्वचालित कर सकता हूं। Xml वापस। और यह बेहतर होगा अगर मुझे प्रत्येक मॉड्यूल को phpunit config में निर्दिष्ट करने की आवश्यकता नहीं थी। या build.xml।

किसी भी टिप्पणी के लिए फिर से धन्यवाद।

उत्तर

4

जब मैंने इसे समझ लिया तो मैं अपने प्रश्न का उत्तर देना भूल गया, मैं उस समुदाय से माफ़ी मांगता हूं जिसे मैं भूल गया था ... लेकिन हर किसी के लिए लाभ यह है कि मैं इसे कैसे काम करता हूं।

build.xml

<target name="phpunit" description="Run unit tests with PHPUnit"> 
    <apply executable="../vendor/bin/phpunit" parallel="false"> 
     <fileset dir="${env.WORKSPACE}/module" > 
      <include name="**/test/phpunit.xml"/> 
     </fileset> 
     <arg value="--configuration" /> 
     <srcfile/> 
    </apply> 
</target> 

और प्रत्येक मॉड्यूल

<phpunit bootstrap="Bootstrap.php"> 
    <testsuites> 
     <testsuite name="Application"> 
      <directory>./</directory> 
     </testsuite> 
    </testsuites> 

<!-- Filters only matter for code coverage reporting --> 
    <filter> 
     <blacklist> 
      <directory>../../../vendor/</directory> 
      <directory>./</directory> 
      <file>../Module.php</file> 
     </blacklist> 
    </filter> 
    <logging> 
     <log type="coverage-html" target="../../../build/coverage" title="Application Module" charset="UTF-8" yui="true" highlight="true" lowUpperBound="35" highLowerBound="70"/> 
     <log type="coverage-clover" target="../../../build/logs/clover-Application.xml"/> 
     <log type="junit" target="../../../build/logs/junit-Application.xml" logIncompleteSkipped="false"/> 
    </logging> 
</phpunit> 
2

ठीक है, मैं निम्नलिखित संरचना का उपयोग करता हूं। मैं परीक्षण फ़ोल्डर के अंदर सभी परीक्षणों है और के रूप में मॉड्यूल संरचित कर रहे मैं उसी तरह से परीक्षण संरचना:

Project 
| - config 
| | - autoload 
| | | - global.php 
| | | - local.php.dist 
| | - application.config.php 
| - data 
| - module 
| | - Application 
| | | - config 
| | | - src 
| | | | - Application 
| | | | | - Controller 
| | | | | | - IndexController.php 
| | | | | - Model 
| | | | | | - Foo.php 
| | | | | - Form 
| | | - view 
| | | - Module.php 
| | - Album 
| | | - config 
| | | - src 
| | | | - Album 
| | | | | - Controller 
| | | | | | - IndexController.php 
| | | | | - Model 
| | | | | | - Bar.php 
| | | | | - Form 
| | | - view 
| | | - Module.php 
| - public 
| - vendor 
| - tests 
| | - unit 
| | | - module 
| | | | - Application 
| | | | | - src 
| | | | | | - Application 
| | | | | | | - Controller 
| | | | | | | | - IndexControllerTest.php 
| | | | | | | - Model 
| | | | | | | | - FooTest.php 
| | | | - Album 
| | | | | - src 
| | | | | | - Album 
| | | | | | | - Controller 
| | | | | | | | - IndexControllerTest.php 
| | | | | | | - Model 
| | | | | | | | - BarTest.php 
| | - functional 
| | | - features 
| - phpunit.xml 
| - phpunit-ci.xml 
| - behat.yml 

PHPUnit कॉन्फ़िगरेशन को अपनी आवश्यकताओं के अनुसार श्वेत सूची, फिल्टर, कवरेज आदि जोड़ने के लिए, कुछ इस तरह (सरलीकृत उदाहरण देख सकते हैं):

<?xml version="1.0" encoding="UTF-8"?> 
<phpunit bootstrap="tests/unit/Bootstrap.php" colors="true" backupGlobals="false" backupStaticAttributes="false" syntaxCheck="false"> 
    <testsuites> 
     <testsuite name="sites"> 
      <directory suffix="Test.php">tests/unit</directory> 
     </testsuite> 
    </testsuites> 
</phpunit> 

PHPUnit-ci.xml का उदाहरण:

<?xml version="1.0" encoding="UTF-8"?> 
<phpunit bootstrap="tests/unit/Bootstrap.php" colors="true" backupGlobals="false" backupStaticAttributes="false" syntaxCheck="false"> 
    <testsuites> 
     <testsuite name="sites"> 
      <directory suffix="Test.php">tests/unit</directory> 
     </testsuite> 
    </testsuites> 
    <filter> 
     <whitelist>  
      <!-- Album module --> 
      <directory suffix=".php">module/Album/src/Album/Model</directory> 
      <directory suffix=".php">module/Album/src/Album/Controller</directory> 

      <!-- Application module --> 
      <directory suffix=".php">module/Application/src/Application/Model</directory> 
      <directory suffix=".php">module/Application/src/Application/Controller</directory> 
     </whitelist> 
    </filter> 
    <logging> 
     <log type="coverage-html" target="build/coverage" charset="UTF-8" 
      yui="true" highlight="true" lowUpperBound="40" highLowerBound="80" /> 
     <log type="coverage-clover" target="build/logs/clover.xml" /> 
     <log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false" /> 
    </logging> 
</phpunit> 

build.xml में यह आसान है:

<target name="phpunit-ci" description="Run unit tests with config file for CI"> 
    <sequential> 

     <exec executable="${basedir}/vendor/bin/phpunit" failonerror="true"> 
      <arg value="--version" /> 
     </exec> 

     <exec executable="${basedir}/vendor/bin/phpunit" failonerror="true"> 
      <arg value="-c" /> 
      <arg path="${basedir}/phpunit-ci.xml" /> 
     </exec> 

    </sequential> 
</target> 
+0

PHPUnit-ci.xml का उपयोग क्या है के लिए phpunit.xml? – anasaitali

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