2012-07-24 35 views
2

在我的應用程序中,我在源代碼旁邊有phpunit測試。所以在所有的地圖旁邊,我們說DoSometing.class.php我有一個DoSomethingTest.class.php。Ant:設置phpunit.xml

我想配置phpunit.xml來測試所有這些* Test.class.php文件。

我該如何在phpunit.xml中做到這一點?

我有這樣的事情在此刻:

<?xml version="1.0" encoding="UTF-8"?> 
<phpunit 
    backupGlobals="false" 
    backupStaticAttributes="true" 
    colors="true" 
    convertErrorsToExceptions="true" 
    convertNoticesToExceptions="true" 
    convertWarningsToExceptions="true" 
    processIsolation="true" 
    stopOnFailure="true" 
    syntaxCheck="false"> 
    <testsuites> 
     <testsuite name="My Test Suite"> 
      <directory>./*Test.class.php</directory> 
     </testsuite> 
    </testsuites> 
    <groups /> 
    <filter /> 
    <logging /> 
    <listeners /> 
</phpunit> 

回答

2

我們使用了類似的結構,只有我們的測試文件結束與根據,因爲我們的測試框架的擴展.TEST,或.QTEST,.JTEST有JavaScript和其他嵌入式代碼以及需要測試的代碼。因此,我們在目錄節點上使用後綴選項,如下所示。

<phpunit> 
<testsuites> 
    <testsuite name="Your Test Suite Name"> 
      <directory suffix=".test">.</directory> 
    </testsuite> 
</testsuites> 
</phpunit> 

對於PHP單元測試(* .TEST)我們用下面的PHPUNIT.xml(這是編輯的大小)

<!-- PHPUnit Core Settings --> 
<phpunit backupStaticAttributes="false" 
    bootstrap="PeriScope-Bootstrap.php" 
      ... 

    <testsuites> 
     <testsuite name="ICAP User Interface Library"> 
      <directory suffix=".test">lib/.</directory> 
     </testsuite> 
     <testsuite name="Enterprise Scale Manager"> 
      <directory suffix=".test">ESM/.</directory> 
     </testsuite> 
     ... 
    </testsuites> 

<!-- Add files not covered with tests into Code Coverage Analysis --> 
    <filter> 
     <whitelist addUncoveredFilesFromWhitelist="true"> 
      <directory suffix=".class">lib/.</directory> 
      <directory suffix=".fn">lib/.</directory> 
      <directory suffix=".php">lib/.</directory> 
      ... 

      <exclude> 
       <directory>ExternalLibraries</directory> 
      </exclude> 
     </whitelist> 
    </filter> 

    <logging> 
     ... 
    </logging> 
</phpunit> 
+0

THX你的答案。這是否也掃描所有的子目錄? – eddy147 2012-07-25 06:54:46

+0

是的,我們在下面有更多的目錄進行處理。 – 2012-07-26 14:14:32