2012-07-24 37 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