具有递归目录表达式的PHPUnit负载测试套件

问题描述:

我正在尝试使用自定义测试套件来定义我的phpunit.xml配置,该套件以递归方式在所需文件夹中加载所有单元测试。具有递归目录表达式的PHPUnit负载测试套件

文件夹路径的例子:

tests/path/Unit/MyTest.php 
tests/path/path/Unit/MyTest.php 
tests/path/path/path/Unit/MyTest.php 
tests/path/path/path/path/Unit/MyTest.php 
... 
tests/{.../}/Unit/MyTest.php 

我可以定义我的套房是这样的:

<testsuites> 
    <testsuite name="Project Unit Test Suite"> 
     <directory>tests/*/Unit</directory> 
     <directory>tests/*/*/Unit</directory> 
     <directory>tests/*/*/*/Unit</directory> 
     <directory>tests/*/*/*/*/Unit</directory> 
     ... 
    </testsuite> 
</testsuites> 

有遍历所有子文件夹,我的表达是只有一行的方式?

+0

据我所知,你不需要提及的所有子目录。你只需要'测试' – akond

+0

@akond有一些测试我想排除(功能):) – Aistis

+0

为什么不使用''呢? – akond

在这种情况下,我应该使用**。我试图命名目录在不同的子目录内,因此**可以在任何地方工作。

<?xml version="1.0"?> 
<phpunit colors="true" backupGlobals="false"> 
    <testsuites> 
    <testsuite name="Test Suite"> 
     <directory>tests</directory> 
     <exclude>**/Functional</exclude> 
    </testsuite> 
    </testsuites> 
</phpunit> 

,或者如果你宁愿有事情:

<?xml version="1.0"?> 
<phpunit colors="true" backupGlobals="false"> 
    <testsuites> 
    <testsuite name="Test Suite"> 
     <directory>**/Unit</directory> 
     <exclude>*</exclude> 
    </testsuite> 
    </testsuites> 
</phpunit>