PHPUnit什么都不做,没有输出
我已经编写了一些测试用例,并希望使用PHPUnit进行测试。但是,它不起作用。 如果我运行PHPUnit什么都不做,没有输出,php,unit-testing,phpunit,Php,Unit Testing,Phpunit,我已经编写了一些测试用例,并希望使用PHPUnit进行测试。但是,它不起作用。 如果我运行phpunit CategoryTest它会输出: PHPUnit 3.7.14 by Sebastian Bergmann. 如果我执行phpunit--log json error.log CategoryTest,error.log文件将显示: {"event":"suiteStart","suite":"CategoryTest","tests":5} {"event":"testStart"
phpunit CategoryTest
它会输出:
PHPUnit 3.7.14 by Sebastian Bergmann.
如果我执行phpunit--log json error.log CategoryTest,error.log文件将显示:
{"event":"suiteStart","suite":"CategoryTest","tests":5}
{"event":"testStart","suite":"CategoryTest","test":"CategoryTest::test__construct"}
因此,它发现文件中有5个测试,开始执行第一个测试,然后无缘无故地停止。有没有日志可以让我找到它无法继续执行的原因?
另外,如果我在其他文件上运行test,比如phpunit--log json error.log UserTest
,shell不会显示任何输出,error.log文件也不会显示
我试着重新安装它,正如在另一个类似的问题中所建议的那样,但它没有做任何事情
你知道我该怎么修吗
require_once '../Category.class.php';
require_once '../../db_connect.php';
require_once 'PHPUnit/Framework/TestCase.php';
class CategoryTest extends PHPUnit_Framework_TestCase {
private $Category;
protected function setUp() {
parent::setUp ();
$this->Category = new Category(0, $mdb2);
}
protected function tearDown() {
$this->Category = null;
parent::tearDown ();
}
public function __construct() {
}
public function test__construct() {
$this->markTestIncomplete ( "__construct test not implemented" );
$cat = $this->Category->__construct(0, $mdb2);
$this->assertInstanceOf('Category', $cat);
}
public function testReturnID() {
$this->markTestIncomplete ( "returnID test not implemented" );
$id = $this->Category->returnID();
$this->assertEquals(0, $id);
}
...
}
变量$mdb2
来自db_connect.php文件
我想出来了。问题是我包含了一个类外的变量。您不应该在测试用例中覆盖_construct()方法。构造器为测试设置了模拟生成器和其他一些必需的东西,因此如果覆盖构造器,您将获得许多奇怪的行为和不必要的副作用。setUp()方法是您应该用来初始化测试的特殊方法。您不应该在测试用例中覆盖_construct()方法。构造器为测试设置了模拟生成器和其他一些必需的东西,因此如果覆盖构造器,您将获得许多奇怪的行为和不必要的副作用。setUp()方法是您应该用来初始化测试的特殊方法。您能给我们看一些代码吗?就像您的php测试类或测试的类一样,因此我们可以在/var/log文件中帮助并查看error.log的errorCheck类型
tail-f/var/log/error.log
在系统上或在另一个站点的规则中。只是添加了一些代码。我运行了tail-f/var/log/error.log
,但是没有这样的文件,您不应该在测试用例中覆盖\u construct()
方法。构造器设置了模拟生成器,因此如果覆盖构造器,会出现许多奇怪的行为和不必要的副作用。setUp()
方法是您应该用来初始化测试的特殊方法。谢谢您的建议,它的行为很奇怪。您能给我们看一些代码吗?就像您的php测试类或测试的类一样,因此我们可以在/var/log文件中帮助并查看error.log的errorCheck类型tail-f/var/log/error.log
在系统上或在另一个站点的规则中。只是添加了一些代码。我运行了tail-f/var/log/error.log
,但是没有这样的文件,您不应该在测试用例中覆盖\u construct()
方法。构造器设置了模拟生成器,因此如果覆盖构造器,会出现许多奇怪的行为和不必要的副作用。setUp()
方法是您应该用来初始化测试的特殊方法。感谢您的建议,它的行为异常。