【发布时间】:2015-04-02 10:08:05
【问题描述】:
我想用 phpunit 命令运行 AllModelTest。
但是当我尝试运行时,结果没有任何东西可以测试。
当然还有很多测试代码。
$vendors/bin/phpunit --configuration app/Test/phpunit.xml
PHPUnit 3.7.38 by Sebastian Bergmann.
Configuration read from /Develop/web/app/Test/phpunit.xml
Time: 30 ms, Memory: 3.75Mb
No tests executed!
此外,当我使用“控制台/蛋糕”命令时,它看起来还不错。
$ app/Console/cake test app AllModel --stderr
Welcome to CakePHP v2.5.8 Console
---------------------------------------------------------------
App : app
Path: /Develop/web/app/
---------------------------------------------------------------
CakePHP Test Shell
---------------------------------------------------------------
PHPUnit 3.7.38 by Sebastian Bergmann.
...
/app/Test/Case/Model/JanTest.php
我是这样写phpunit.xml的。
<?xml version="1.0" encoding="utf-8" ?>
<phpunit bootstrap="phpunit-bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false">
<testsuites>
<testsuite name="Project Test Suite">
<directory suffix="Test.php">Test/Case/</directory>
</testsuite>
</testsuites>
</phpunit>
而phpunit-bootstrap.php是这样的。
<?php
$file = __DIR__.'/../../vendors/autoload.php';
if (!file_exists($file)) {
throw new RuntimeException('Install dependencies to run test suite.');
}
$autoload = require_once $file;
而目标测试文件“AllModelTest.php”是这样的。
<?php
class AllModelTest extends CakeTestSuite {
public static function suite() {
$suite = new CakeTestSuite('All model tests');
$suite->addTestDirectory(TESTS . 'Case/Model');
return $suite;
}
}
我应该怎么做才能从 phpunit 命令运行测试?
谢谢!
【问题讨论】: