我目前正在开发一个相当大的web应用程序,它使用Silex作为后端。我已经加入PHPUnit的该项目创建了一个简单的测试案例:PhpUnit无法找到测试文件
class IndexControllerText extends BaseControllerTest
{
public function testIndexPage()
{
$this->assertTrue(true);
}
}
我BaseControllerTest
用于创建应用程序的described in the docs:
<?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
负荷作曲家自动加载磁带机:
<?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
。见this gist。
不幸的是,当我运行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>
您还没有显示文件你怀疑的错误是在文本: 'phpunit.xml'。 – Sven 2014-09-06 15:52:41
它在我提供的链接。这篇文章太长了。 – ferdynator 2014-09-06 15:54:56
我把那个文件计算得比其他代码少,我添加了我在你链接的页面上找到的内容。请确认这是您正在使用的文件。 – Sven 2014-09-06 20:28:54