从根目录为插件文件夹运行 PHPUnit



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

问题是各个插件都来自自己的存储库,并且 PHPUnit 通过作曲家开发依赖项在那里注册。

主项目"应用程序"的构建过程使用作曲家拉出插件。

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

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

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

您可以创建一个名为 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>

最新更新