【发布时间】:2014-09-15 18:52:28
【问题描述】:
我想将我的测试分解到他们的 M、V、C 文件夹中。所以我有:
/tests
/models
/views
/controllers
TestCase.php
例如,我在/controllers 内有一个UsersControllerTest.php:
class UsersControllerTest extends TestCase {
public function testSimple()
{
$this->assertTrue(true);
}
}
当我运行phpunit 时,我得到的只是Configuration read from PATH_TO_phpunit.xml。当我在文件夹中添加测试文件时出现问题。如果我将该测试文件移动到根 /tests 文件夹,那么一切正常。
我尝试编辑 phpunit.xml 文件以包含:
<testsuites>
<testsuite name="Application Test Suite">
<directory>./app/tests</directory>
<directory>./app/tests/controllers</directory>
</testsuite>
</testsuites>
但是还是不行
【问题讨论】:
-
读取 phpunit.xml 文件,PHPUnit 在运行测试时会考虑路径,您似乎不在该路径之外。
-
是的,我意识到这一点。那么我应该怎么做?如何添加其他路径?
-
类似于已经存在的。如果您的
有一个路径,请添加另一个路径。 -
所以我尝试添加更多
<director>,但还是同样的问题。 -
也许更好地阅读 PHPUnit 的主题文档。如果已经添加了目录,则不需要添加子目录。我认为您对自动加载器有问题-检查是否完全加载了该测试类。与其他更适合的框架相比,Laravel 的自动加载器非常简单,也许它只在主目录中搜索。
标签: php laravel laravel-4 phpunit