PHPUnit不会加载一些测试

时间:2014-01-30 17:49:37

标签: unit-testing magento phpunit

我的一个模块中有一个测试文件夹,有3个子文件夹:

Model
Helper
Integration

正在运行

phpunit --group My_Module 

仅执行Model和Helper目录中的测试,而Integration文件夹保持不变。在所有情况下,测试文件都直接驻留在文件夹中,所以我不确定是什么导致了这个问题。 这是我的phpunit.xml:

<?xml version="1.0"?>
<!-- initial phpunit configuration file, that you can modify for your project needs -->
<phpunit cacheTokens="true"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         stopOnError="false"
         stopOnFailure="false"
         stopOnIncomplete="false"
         stopOnSkipped="false"
         strict="false"
         verbose="false"
         bootstrap="app/code/community/EcomDev/PHPUnit/bootstrap.php">
    <listeners>
        <listener file="app/code/community/EcomDev/PHPUnit/Test/Listener.php" class="EcomDev_PHPUnit_Test_Listener" />
    </listeners>
    <testsuites>
        <testsuite name="MyApp">
            <directory suffix=".php">app/code/local/*/*/Test/*/</directory>
        </testsuite>
        <testsuite name="Magento Test Suite">
            <file>app/code/community/EcomDev/PHPUnit/Test/Suite.php</file>
        </testsuite>
    </testsuites>
    <filter>
        <blacklist>
            <!-- Exclude Magento Core files from code coverage -->
            <directory suffix=".php">app/code/core</directory>
            <!-- Exclude EcomDev_PHPUnit classes from code coverage -->
            <directory suffix=".php">app/code/community/EcomDev/PHPUnit</directory>
            <directory suffix=".php">lib/EcomDev/Utils</directory>
            <directory suffix=".php">lib/EcomDev/PHPUnit</directory>
            <directory suffix=".php">lib/Spyc</directory>
            <directory suffix=".php">lib/vfsStream</directory>
            <!-- Exclude Mage.php file from code coverage -->
            <file>app/Mage.php</file>
            <!-- Exclude template files -->
            <directory suffix=".phtml">app/design</directory>
            <!-- Exclude Varien & Zend libraries -->
            <directory suffix=".php">lib/Varien</directory>
            <directory suffix=".php">lib/Zend</directory>
        </blacklist>
    </filter>
    <logging>
        <!-- Uncomment this line if you want to have coverage report generated every test run
        <log type="coverage-html" target="var/phpunit/coverage" charset="UTF-8"
              yui="true" highlight="false"
              lowUpperBound="35" highLowerBound="70"/>
        <log type="coverage-clover" target="var/phpunit/coverage.xml"/>
        -->
        <log type="junit" target="../build/logs/junit.xml" logIncompleteSkipped="false"/>
    </logging>
</phpunit>

我在ubuntu VM上运行的PHPunit版本是3.7.28。我怎样才能运行所有测试?非常感谢帮助。

1 个答案:

答案 0 :(得分:2)

尝试致电

phpunit --list-groups

显示可用测试组的列表。你在列表中看到My_Module吗? 1)是 - 测试文件夹/结构中的问题 2)否 - 在xml配置中出现问题。