1
我需要从PHAR运行PHPUNit而不是从Pear运行。 我得到的唯一输出是帮助文件。我没有看到我的测试运行。这里是我的代码: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));
}
}
而且我正在这样的:
$ php index.php
感谢
< < UPDATE >> 我跑在此之后:
$ php phpunit.phar index.php
我得到了这个e rror:
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);
}
}
谢谢。这工作来运行它。但我碰到另一个问题,给了我这个错误:“类'索引'无法找到'/home/ericp/public_html/dev/_test/phpunit/index.php'”。我想通了,并会修复我的问题。 – EricP 2013-02-15 15:36:14
sry,忘了提及。 PHPUnit也期望包含的类名与文件名匹配。尝试将'index.php'重命名为'ArrayTest.php'。 – 2013-02-15 19:54:21
@EricP,什么是修复? – Pacerier 2015-08-11 09:26:03