2014-09-06 140 views
1

我目前正在开发一个相当大的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> 
+0

您还没有显示文件你怀疑的错误是在文本: 'phpunit.xml'。 – Sven 2014-09-06 15:52:41

+0

它在我提供的链接。这篇文章太长了。 – ferdynator 2014-09-06 15:54:56

+1

我把那个文件计算得比其他代码少,我添加了我在你链接的页面上找到的内容。请确认这是您正在使用的文件。 – Sven 2014-09-06 20:28:54

回答

1

我感觉到一个错字:

IndexControllerText 

这大概应该是测试用S,不是有X.

+0

有时候可以很简单!谢谢! – ferdynator 2014-09-07 10:52:24

相关问题