Phpunit 如何从Codeception单元测试中获得调试输出?

Phpunit 如何从Codeception单元测试中获得调试输出?,phpunit,codeception,Phpunit,Codeception,我可能有点糊涂,但我不知道如何获得一点关于测试失败原因的信息 我做这个测试是为了检查我们没有任何新的没有测试的方法 //TEST ALL METHODS TESTED public function testAllMethodsTested() { $temp = $this->class_namespace.substr(__CLASS__, 0, -5); $class_methods = get_class_methods($temp); $test_meth

我可能有点糊涂,但我不知道如何获得一点关于测试失败原因的信息

我做这个测试是为了检查我们没有任何新的没有测试的方法

//TEST ALL METHODS TESTED
public function testAllMethodsTested()
{
    $temp = $this->class_namespace.substr(__CLASS__, 0, -5);
    $class_methods = get_class_methods($temp);
    $test_methods = get_class_methods(__CLASS__);

    foreach($class_methods as $class_method) 
    {
        $this->assertEquals(true, in_array('test_'.$class_method, $test_methods));
    }
}
当这失败时,我会得到类似

1) c_functions_core_ext_Test::testAllMethodsTested
Failed asserting that false matches expected true.
1) c_functions_core_ext_Test::testAllMethodsTested
There is no test for Namespace\target_class::someMethodName
Failed asserting that false matches expected true.
为了更容易看到去哪里和修复一些代码,我想在console和report.html中获得一些有用的调试输出(就像您在验收测试中得到的一样),大致如下所示

1) some_class_Test::testAllMethodsTested
Checking test exists for some_class::someMethod
Failed asserting that false matches expected true.

单元测试可以这样做吗?

是的,我很胖。assert函数似乎允许指定您自己的消息

//TEST ALL METHODS TESTED
public function testAllMethodsTested()
{
    $target_class = $this->class_namespace.substr(__CLASS__, 0, -5);
    $class_methods = get_class_methods($target_class);
    $test_methods = get_class_methods(__CLASS__);

    $result = in_array('test_'.$class_method, $test_methods);

    //FAIL WITH A USEFUL ERROR
    $this->assertTrue($result, 'There is no test for '.$target_class.'::'.$class_method);
}
当这失败时,我现在得到的是

1) c_functions_core_ext_Test::testAllMethodsTested
Failed asserting that false matches expected true.
1) c_functions_core_ext_Test::testAllMethodsTested
There is no test for Namespace\target_class::someMethodName
Failed asserting that false matches expected true.