我需要从 PHAR 而不是 Pear 运行 PHPUNIt。我得到的唯一输出是帮助文件。我根本看不到我的测试运行。这是我的代码:
<?php
include 'phpunit.phar';
include 'phar://phpunit.phar/phpunit.php';
class ArrayTest extends PHPUnit_Framework_TestCase
{
public function setUp(){ }
public function tearDown(){ }
public function testNewArrayIsEmpty()
{
// Create the Array fixture.
$fixture = array();
// Assert that the size of the Array fixture is 0.
$this->assertEquals(0, sizeof($fixture));
}
}
我正在这样运行它:
$ php index.php
谢谢
<< UPDATE >> 在我运行这个之后:
$ php phpunit.phar index.php
我收到了这个错误:
Class 'index' could not be found in '/home/ericp/public_html/dev/_test/phpunit/index.php'.
我通过添加“../”更改路径来意外修复它。我不知道为什么会修复它,但它确实有效。我的 index.php 文件与我的 phpunit.phar 文件位于同一目录中。工作示例如下所示:
<?php
include '../phpunit.phar';
include '../phar://phpunit.phar/phpunit.php';
class ArrayTest extends PHPUnit_Framework_TestCase
{
public function setUp(){ }
public function tearDown(){ }
public function testNewArrayIsEmpty()
{
// Create the Array fixture.
$fixture = array();
// Assert that the size of the Array fixture is 0.
$this->assertEquals(0, sizeof($fixture));
$this->assertEmpty($fixture);
}
}