[英]phpunit no tests executed
我用phpunit进行了“未执行测试”。
这条线有效
$ phpunit install/InstallDbTest.php
...
<result expected>
...
$ cat suites/installtests.xml
<phpunit>
<testsuites>
<testsuite name="database">
<file>install/InstallDbTest.php</file>
</testsuite>
</testsuites>
</phpunit>
$ phpunit -c suites/installtests.xml
PHPUnit 4.7.4 by Sebastian Bergmann and contributors.
Time: 130 ms, Memory: 11.25Mb
No tests executed!
有人能告诉我我做错了吗?
提前致谢!
您需要在phpunit.xml中更正路径。
它正在尝试查找文件suites/install/InstallDbTest.php
。 由于该文件不存在,因此不会运行任何测试,并且您会收到消息。
将配置更改为以下内容:
<phpunit>
<testsuites>
<testsuite name="database">
<file>../install/InstallDbTest.php</file>
</testsuite>
</testsuites>
</phpunit>
phpunit.xml中的文件路径都相对于xml文件的位置。
也许在InstallDbTest.php文件中您丢失了:
<?php
...
对于那些使用与Composer的自动加载文件不同的引导文件的人,请确保您没有use
一种测试用例类。
确实,PHPUnit(在我的情况下为6.2版)将所有尚未加载任何类的 PHP文件添加到运行的TestSuite
(请参见代码中的操作 )。 从TestSuite::addTestFile($filename)
方法:
$classes = get_declared_classes();
$filename = Fileloader::checkAndLoad($filename);
$newClasses = \array_diff(\get_declared_classes(), $classes);
因此,如果您的类已经属于get_declared_classes
,它将被忽略。
总结一下:不要在;)之前use
测试类
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.