所以我使用 PHPUnit 进行测试。尝试在我的一项测试中使用 DataProvider。
/**
* Tests Events_Event->Events_Event()
* @dataProvider provider
*/
public function testEvents_Event($Name, $param, $time) {
//$this->assertInstanceOf("Events_Event", $this->Events_Event->Events_Event("test2", array()));
$this->assertTrue(true);
}
public static function provider()
{
return array(
array("test", array("Like a boss"), "Cheack the time"),
array("test2", array("Like a boss"), "9:00"),
array("test3", array("Time to go home"), "4:00"),
array("test3", array("Time to go home"), "4:00")
);
}
结果:
testEvents_Event with data set#0
testEvents_Event with data set#1
testEvents_Event with data set#2
testEvents_Event with data set#3: The test case was unexpectedly terminated
无论最后一个数据集有多少个,也无论最后一个数据集是否有效,都会发生这种情况。正如您所看到的,我们已将测试简化为简单的 $this->assertTrue(true)
,但它仍然给我们带来错误。
我们需要做什么才能让数据提供程序正常工作?
如果我在 Zend Studio 9.0.3 中使用 PHPUnit 很重要,我已经检查了更新,它告诉我所有内容都是最新的。
最佳答案
我正在经历
....
时间:0秒,内存:12.75Mb
好的(4 个测试,0 个断言)
/**
* Tests Events_Event->Events_Event()
* @dataProvider provider
*/
public function testEvents_Event($Name, $param, $time)
{
}
public static function provider()
{
return array(
array("test", array("Like a boss"), "Cheack the time"),
array("test2", array("Like a boss"), "9:00"),
array("test3", array("Time to go home"), "4:00"),
array("test3", array("Time to go home"), "4:00")
);
}
如何运行测试?还有没有其他依赖关系? 通过任何 IDE 运行测试?
关于php - 使用 PHPUnit,使用数据提供程序,最后一个数据集始终显示 "The test case was unexpectedly terminated",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10653313/