dongyuqi3808 2014-12-11 11:55
浏览 47

PHPUnit - 在tearDown()中获取测试通过状态+名称

In PHPUnit, how can I get info in tearDown() if my test passed or not, and what its name? I've tried looking into $this->getTestResultObject()->topTestSuite(), but not luck - tests seem like they are fresh with no ok/failure in them.

As output I want my custom tearDown() to have something like:

TESTCLASSNAME::TESTMETHOD - ok
TESTCLASSNAME::TESTMETHOD2 - failed
  • 写回答

1条回答 默认 最新

  • dtlh12053 2014-12-11 13:07
    关注

    Class name = explode('::',$this->toString())[0]

    Test name = $this->getName()

    Status = $this->hasFailed()

    评论

报告相同问题?