[英]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.