public function testAddFailure() { $exception = new \PHPUnit_Framework_AssertionFailedError(EXCEPTION_MESSAGE); $time = $this->getTime(); $this->getAllureAdapter()->addFailure($this, $exception, $time); $events = $this->getMockedLifecycle()->getEvents(); $event = new TestCaseFailedEvent(); $event->withException($exception)->withMessage(EXCEPTION_MESSAGE); $this->assertEquals(1, sizeof($events)); $this->assertInstanceOf('\\Yandex\\Allure\\Adapter\\Event\\TestCaseFailedEvent', $events[0]); $this->assertEquals($event, $events[0]); }
/** * A failure occurred. * * @param PHPUnit_Framework_Test $test * @param PHPUnit_Framework_AssertionFailedError $e * @param float $time */ public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) { $event = new TestCaseFailedEvent(); $message = $e->getMessage(); // Append comparison diff for errors of type ExpectationFailedException (and is subclasses) if (($e instanceof PHPUnit_Framework_ExpectationFailedException || is_subclass_of($e, '\\PHPUnit_Framework_ExpectationFailedException')) && $e->getComparisonFailure()) { $message .= $e->getComparisonFailure()->getDiff(); } Allure::lifecycle()->fire($event->withException($e)->withMessage($message)); }
/** * @param FailEvent $failEvent */ public function testFail(FailEvent $failEvent) { $event = new TestCaseFailedEvent(); $e = $failEvent->getFail(); $message = $e->getMessage(); $this->getLifecycle()->fire($event->withException($e)->withMessage($message)); }