php - 使用 PHPUnit,使用数据提供程序,最后一个数据集始终显示 "The test case was unexpectedly terminated"

标签 php testing phpunit zend-studio

所以我使用 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/

相关文章:

javascript - 传递 extJs 网格值来存储 PHP 脚本

testing - 将需求与功能测试联系起来

c# - SQL 数据库的 "developer/test"模式

php - 在 PHPUNIT 中测试 API 且不泄露私有(private)凭证的最佳方法

php - 在测试中模拟 Laravel 环境

php - 在功能测试中使用 ajax 提交表单

php - 有没有不需要javascript的博客网站评论系统?

php - 清除搜索表单时返回原始状态

php - bind_param 不工作(在非对象上)mysqli 准备语句

c# - 以编程方式创建测试