代码之家  ›  专栏  ›  技术社区  ›  Alex C

PHPUnit:多个引导还是XML文件?

  •  7
  • Alex C  · 技术社区  · 16 年前

    我有一个phpmvc框架,在这个系统下有多个应用程序

    \project\apps\app1\
    \project\apps\app2\
    \project\apps\shared\
    

    \project\apps\app1\controllers\FooContoller.php
    \project\apps\app2\controllers\FooContoller.php
    \project\apps\shared\controllers\BarContoller.php
    

    我想设置我的PHPUnit测试空间,以便能够测试每个应用程序目录,但我希望以“最佳”的方式进行。

    \project\PHPUnit
    \project\PHPUnit\phpunit.xml
    \project\PHPUnit\apps\app1\bootstrap.php
    \project\PHPUnit\apps\app1\controllers
    \project\PHPUnit\apps\app1\controllers\FooControllerTest.php
    \project\PHPUnit\apps\app2\bootstrap.php
    \project\PHPUnit\apps\app2\controllers
    \project\PHPUnit\apps\app2\controllers\FooControllerTest.php
    

    现在的问题是:什么是配置我的phpunit.xml 文件夹?

    在我看来,最理想的情况是配置XML,以便所有测试都可以运行 然后内存被“清除”,所有的测试都被运行了 附录2 .

    然而,就最佳实践而言,最好有多个XML文件,每个应用程序一个(然后可能是一个批处理/shell脚本文件来运行“test all”或test X)

    如果我们看一个“典型”PHPUnit XML配置文件:

    <phpunit bootstrap="./apps/app1/bootstrap.php" colors="true">
        <testsuite name="App1TestSuite">
            <directory>./</directory>
        </testsuite>
        <filter>
            <whitelist>
            <directory suffix=".php">./apps/app1/controllers/</directory>        
        <directory suffix=".php">./apps/shared/</directory>
            </whitelist>
        </filter>
        <logging>
            <log type="coverage-html" target="./log/report.html" charset="UTF-8"
                yui="true" highlight="true"
                lowUpperBound="50" highLowerBound="80"/>
            <log type="testdox-html" target="./log/testdox.html" />
        </logging>
     </phpunit>
    

    我应该多吃这些吗?或者我应该加上

    我有兴趣从一开始就为测试构建“最佳”系统,但显然我的知识中有一些漏洞。

    1 回复  |  直到 16 年前
        1
  •  5
  •   Anti Veeranna    16 年前

    就最佳实践而言 有多个XML文件,每个文件一个 文件以运行“test all”或test X