所以我通过从PEAR . PHPUnit .de下载文件并将它们解压缩到C:PHPPEAR文件夹来手动安装PHPUnit。我有PEAR文件夹在包含路径。我如何运行这个测试?
class StackTest extends PHPUnit_Framework_TestCase
{
public function testEmpty()
{
$stack = array();
$this->assertEmpty($stack);
return $stack;
}
/**
* @depends testEmpty
*/
public function testPush(array $stack)
{
array_push($stack, 'foo');
$this->assertEquals('foo', $stack[count($stack)-1]);
$this->assertNotEmpty($stack);
return $stack;
}
/**
* @depends testPush
*/
public function testPop(array $stack)
{
$this->assertEquals('foo', array_pop($stack));
$this->assertEmpty($stack);
}
}
PHPUnit目录下没有可执行的命令行工具
在我的机器上,phpunit.bat
被添加到我的php主安装目录中。我通过调用
phpunit NameOfMyTestWithoutPhpExtension
中包含测试的目录。
批处理文件只是调用主php解释器,传递phpunit
作为源文件,并在其调用中附加其他参数。如果没有批处理文件,请尝试运行
php "c:PHPPEARphpunit.php" NameOfMyTestWithoutPhpExtension