[英]Global PHPunit no tests executed
我有以下phpunit.xml文件:
<phpunit bootstrap="Bootstrap.php" backupGlobals="false">
<testsuites>
<testsuite name="mentor">
<directory>../module/Api</directory>
<directory>../module/Application</directory>
<exclude>../vendor</exclude>
<exclude>vendor</exclude>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">../module</directory>
</whitelist>
</filter>
</phpunit>
文件结构如下所示:
module
vendor
tests
-- phpunit.xml
-- Bootstrap.php
现在是棘手的部分。 当我运行../vendor/bin/php时,虽然我运行了全局phpunit(/ usr / local / bin / phpunit),但一切正常,但结果为“未执行测试”。 有什么建议么?
我发现了phpunit省略所有类的原因-这是由于我试图扩展的 TestCase所致。 我所有的测试都是通过Phpunit 5.7软件包(在供应商中)在\\ PHPUnit_Framework_TestCase上进行的。 phpunit 6.1.4使用名称空间代替,因此我应该扩展PHPUnit \\ Framework \\ TestCase 。 通过更改测试中的扩展类,一切正常。
我认为您需要像这样在作曲家内部使用psr-4:
"autoload": {
"psr-4": {
"": "module/"
}
}
在需要使用以下命令更改phpunit.xml之后:
<phpunit bootstrap="Bootstrap.php" backupGlobals="false">
<testsuites>
<testsuite name="mentor">
<directory>module/Api</directory>
<directory>module/Application</directory>
<exclude>../vendor</exclude>
<exclude>vendor</exclude>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">module</directory>
</whitelist>
</filter>
</phpunit>
我认为您需要将phpunit点更改为文件夹测试而不是模块! 像这样:
<phpunit bootstrap="Bootstrap.php" backupGlobals="false">
<testsuites>
<testsuite name="mentor">
<directory>tests/</directory>
<exclude>../vendor</exclude>
<exclude>vendor</exclude>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">tests</directory>
</whitelist>
</filter>
</phpunit>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.