PhpUnit无法定位测试文件


PhpUnit unable to locate test files

我目前正在开发一个相当大的web应用程序,该应用程序使用Silex作为后端。我在项目中添加了PHPUnit,创建了一个简单的测试用例:

class IndexControllerText extends BaseControllerTest
{
    public function testIndexPage()
    {
        $this->assertTrue(true);
    }
}

我的BaseControllerTest用于创建文档中描述的应用程序:

<?php
namespace VendorName'AppName'Tests;
use Silex'WebTestCase;
use Symfony'Component'HttpKernel'HttpKernel;
abstract class BaseControllerTest extends WebTestCase
{
    public function createApplication()
    {
        $app = require __DIR__ . '/../../../../app/bootstrap.php';
        $app['debug'] = true;
        $app['exception_handler']->disable();
        return $app;
    }
}

我的app/bootstrap.php加载composer自动加载器:

<?php
require_once __DIR__ . '/../vendor/autoload.php';
$app = new Silex'Application();
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/routing.php';
return $app;

最后,在我的项目根目录中有我的phpunit.xml。请参阅要点。

不幸的是,当我运行phpunit -c phpunit.xml时,结果显示:

未执行任何测试!

当我直接运行IndexControllerTest时:

phpunit -c phpunit.xml src/VendorName/AppName/Tests/IndexControllerText.php

它运行测试并按预期返回成功。我很确定这是我的phpunit.xml中的一个配置错误,但我似乎无法弄清楚。

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
     backupStaticAttributes="false"
     colors="true"
     convertErrorsToExceptions="true"
     convertNoticesToExceptions="true"
     convertWarningsToExceptions="true"
     processIsolation="false"
     stopOnFailure="false"
     syntaxCheck="false"
>
<testsuites>
    <testsuite name="YourApp Test Suite">
        <directory>./tests/</directory>
    </testsuite>
</testsuites>
</phpunit>

我感觉到一个打字错误:

IndexControllerText

这可能应该是用S进行的TEST,而不是用X进行的TEXT。