【问题标题】:Run PHPUnit for plugins folders from root directory从根目录为插件文件夹运行 PHPUnit
【发布时间】:2018-10-03 04:01:37
【问题描述】:

我想在根目录的插件中运行我的 PHPUnits 测试。

问题是每个插件都来自他们自己的存储库,并且 PHPUnit 是通过 composer dev 依赖项在那里注册的。

主项目“Application”的构建过程使用composer提取插件。

这个结构有我当前的 PHP 项目:

/Application
  /Plugins
    /PluginFirst 
        /tests
    /PluginSecond
        /tests
    /PluginThird
        /tests

想法是创建 shell 或 ruby​​ 脚本来迭代插件文件夹并运行 PHPUnit。

【问题讨论】:

    标签: php phpunit


    【解决方案1】:

    您可以创建一个名为 phpunit.xml.dist 的配置文件,并使用以下配置将其保存在您的根项目文件夹中。假设您还有一个测试文件夹来在文件夹的同一级别运行您自己的单元测试:

    <?xml version="1.0" encoding="UTF-8"?>
    <phpunit>
         <testsuites>
            <testsuite name="Application API Test Suite">
                <directory>./tests/</directory>
                <directory>./Plugins/</directory>
            </testsuite>
         </testsuites>
    </phpunit>
    

    那么就可以这样运行phpunit了:

    phpunit --configuration phpunit.xml.dist
    

    如果你想排除例如 PluginThird 文件夹,你可以在标签内添加这一行

    <exclude>./Plugins/PluginThird/</exclude>
    

    【讨论】:

    • 感谢您的回答。问题是根项目“应用程序”没有 PHPUnit 依赖项。 (这是非常需要的)每个插件都有他的开发 PHPUnit 依赖。
    • “应用程序”已做好生产准备,将被部署。因此对“应用程序”没有 PHPUnit 依赖。
    • 您使用什么 PHP 框架来构建您的应用程序?
    • 我们使用WordPress和WPCLI,这个结构只是一个sn-p。
    猜你喜欢
    • 2014-06-04
    • 1970-01-01
    • 1970-01-01
    • 2012-08-20
    • 2016-07-06
    • 2021-12-05
    • 2015-11-11
    • 2018-08-18
    • 1970-01-01
    相关资源
    最近更新 更多