PHPUnit을 작동 시키려고합니다. 나는 전에 그것을 사용하지 않았다. CLI에서 phpunit을 실행하면 작동하지만 스크립트 (내가 찾고있는 것)를 통해 작동하지 않습니다.PHPUnit 클래스 이름을 잃어 버림 (ReflectionClass 클래스가 존재하지 않습니다. 오류)
Fatal error: Uncaught exception 'ReflectionException' with message 'Class does not exist' in /usr/local/share/pear/PHPUnit/Util/Test.php:295
Stack trace:
#0 /usr/local/share/pear/PHPUnit/Util/Test.php(295): ReflectionClass->__construct('')
#1 /usr/local/share/pear/PHPUnit/Util/Test.php(576): PHPUnit_Util_Test::parseTestMethodAnnotations(false, false)
#2 /usr/local/share/pear/PHPUnit/Util/Test.php(350): PHPUnit_Util_Test::getBooleanAnnotationSetting(false, false, 'backupGlobals')
#3 /usr/local/share/pear/PHPUnit/Framework/TestSuite.php(458): PHPUnit_Util_Test::getBackupSettings(false, false)
#4 /usr/local/share/pear/PHPUnit/Framework/TestSuite.php(834): PHPUnit_Framework_TestSuite::createTest(Object(ReflectionClass), false)
#5 /usr/local/share/pear/PHPUnit/Framework/TestSuite.php(212): PHPUnit_Framework_TestSuite->addTestMethod(Object(ReflectionClass), Object(ReflectionMethod))
#6 /usr/local/share/pear/PHPUnit/Framework/TestSuite.php(315): PHPUnit_Framework_TestSuite->__construct(Object(ReflectionClass))
#7 /var/www/www.s in /usr/local/share/pear/PHPUnit/Util/Test.php on line 295
클래스 이름이 addTestMethod
에서 손실되는 것 같습니다 : 이것은 내가 얻을 출력 (클래스 후 두 개의 공백 유의)입니다. 내 코드 :
<?php
require_once 'PHPUnit/Autoload.php';
class MyTestCase extends PHPUnit_Framework_TestCase {
public function testSubtraction() {
$this->assertEquals(2 - 2, 0);
}
public function testAddition() {
$this->assertEquals(2 + 2, 4);
}
}
$c = new MyTestCase();
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('MyTestCase');
PHPUnit_TextUI_TestRunner::run($suite);
설정이 잘못 되었습니까?
다음은 버전입니다 :
Installed packages, channel pear.phpunit.de:
============================================
Package Version State
File_Iterator 1.3.3 stable
PHPUnit 3.7.21 stable
PHPUnit_MockObject 1.2.3 stable
PHP_CodeCoverage 1.2.11 stable
PHP_Timer 1.0.4 stable
PHP_TokenStream 1.1.5 stable
Text_Template 1.1.4 stable
PHP 5.4
반사가 작업을 수행, 난 내 자신의 스크립트에서 것을 사용합니다. 다행히도 설치 과정에서 뭔가 달라지기 때문에 PHPUnit을 수정하고 싶지는 않습니다 ... 물론 다른 곳에서도 작동합니다.
어떻게 든 해결 했습니까? –