问题描述
我有此配置:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals = "false"
backupStaticAttributes = "false"
colors = "false"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false"
stopOnError = "false"
stopOnIncomplete = "false"
syntaxCheck = "false"
bootstrap = "test_bootstrap.php"
>
<testsuites>
<testsuite name="UnitTests">
<file>unit/api/2/ApiControllerTest.php</file>
<file>unit/api/2/RoutesTest.php</file>
</testsuite>
它运行测试文件.如果我将文件替换为
it runs the Test files. If I replace the files with
<directory>unit</directory>
// or
<directory>unit/api/2</directory>
// or
<directory>unit/api/2/*</directory>
// or
<directory>unit/api/2/*Test.php</directory>
// or
<directory suffix="Test.php">unit/api/2</directory>
它只是说:没有执行任何测试!
It simply says: No tests executed!
拜托,怎么可能出问题了?
Please, what could be wrong?
Ubuntu 12.04 LTS,php 5.3.10,phpunit 3.7.16
Ubuntu 12.04 LTS, php 5.3.10, phpunit 3.7.16
推荐答案
相对于unit
目录的路径中有phpunit.xml文件吗?
Where in you path relative to the unit
directory is the phpunit.xml file?
如果您的路径看起来像这样:
if your path looks anything like this:
projectroot
|- phpunit.xml
|- unit/
|- api/
您可以尝试在phpunit.xml
中将目录设置为以下内容:
You could try setting the directory to the following in phpunit.xml
:
<directory>./unit</directory>
然后从根目录运行phpunit,如下所示:phpunit -c phpunit.xml
And then run phpunit from root like this: phpunit -c phpunit.xml
如果这不起作用,则说明有其他问题.如果运行此命令会发生什么:
If that doesn't work, something else is wrong. What happens if you run this:
phpunit ./unit/api/2
如果没有测试在运行,请回答以下问题:
If no tests are being run then, please answer the following questions:
- 也许您在测试用例中的方法不是以"test"开头的?
- 所有测试用例文件都以Test.php结尾吗?
- 所有测试用例类都扩展PHPUnit_Framework_TestCase吗?
- 所有测试用例类名都以'Test'结尾吗?
这篇关于phpunit找不到带有director xml标记的任何测试,但是带有(某些)文件标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!