【问题标题】:calling two assert functions inside simpletest testcase在 simpletest 测试用例中调用两个断言函数
【发布时间】:2012-06-20 07:14:33
【问题描述】:

我的模型(codeigniter 框架)中有一个函数,它在 cookie 中设置两个值。

我需要为此编写单元测试。所以在这种情况下,我需要调用两个 assertEqual() 函数以确保设置了两个 cookie。

有人知道在同一个测试用例中调用两个断言函数吗?

【问题讨论】:

  • 您可以在每个测试用例中使用任意数量的断言函数,并且在单个测试用例中使用 2+ 是很常见的。但我想你可能会问更复杂的问题?您能否更详细地解释您的问题/问题,或使用(小)代码示例来演示它?

标签: phpunit


【解决方案1】:
// For example
public function testMyTest()
{
    $foo = 'test';
    $this->assertTrue(is_string($foo));
    $this->assertEquals('test', $foo);
    $this->assertEquals(4, strlen($foo));
}

参见文档:: http://www.phpunit.de/manual/3.7/en/writing-tests-for-phpunit.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-02
    • 1970-01-01
    • 1970-01-01
    • 2013-05-02
    • 1970-01-01
    • 2020-10-08
    • 1970-01-01
    相关资源
    最近更新 更多