【发布时间】:2016-05-05 21:57:48
【问题描述】:
当我尝试使用 phpunit 时,我在 phpStorm 的命令行中不断收到此错误。谁可以给我解释一下这个?我是phpunit的新手。
C:\xampp\php\phpunit.bat
警告:PHPUnit_TextUI_TestRunner::doRun() 缺少参数 3, 在第 176 行调用 C:\xampp\php\pear\PHPUnit\TextUI\Command.php 和 定义在 C:\xampp\htdocs\tutorials\php_unit_testing\vendor\phpunit\phpunit\src\TextUI\TestRunner.php 在第 148 行
Sebastian Bergmann 和贡献者的 PHPUnit 5.3-dev。
致命错误:在 'controllers\core\web\Pages' 中找不到类 C:\xampp\htdocs\tutorials\php_unit_testing\tests\app\controllers\core\web\PagesTest.php 在第 6 行
进程在 22:23:20 以退出代码 255 结束。执行时间:186 女士。
这是我的 xml 文件中的代码:
<?xml version='1.0' encoding='UTF-8' ?>
<phpunit bootstrap="./vendor/autoload.php"
color="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailures="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Tutorial Unit Tests">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
这是 pages.php 中的代码:
<?php
namespace controllers\core\web;
class Pages{
public function rendor(){
return 'Hello World';
}
public function return_true(){
return true;
}
public function return_array(){
return array('Hello', 'world', 'This', 'is', 'an', 'array');
}
}
?>
这是来自 PagesTest.php 的代码:
<?php
class PagesTest extends PHPUnit_Framework_TestCase
{
public function testRenderReturnsHelloWorld(){
$pages = new \controllers\core\web\Pages();
$expected = 'Hello Word';
$this->assertEquals($expected, $pages->rendor());
}
}
?>
【问题讨论】: