Skip to content

Commit 5584e7e

Browse files
authored
add processing of phpunit warnings as failures (via #48)
1 parent 4d95847 commit 5584e7e

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Yandex/Allure/PhpUnit/AllurePhpUnit.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ public function addError(Test $test, Throwable $t, float $time): void
134134
*/
135135
public function addWarning(Test $test, Warning $e, float $time): void
136136
{
137-
// TODO: Implement addWarning() method.
137+
$event = new TestCaseFailedEvent();
138+
Allure::lifecycle()->fire($event->withException($e)->withMessage($e->getMessage()));
138139
}
139140

140141
/**

test/Yandex/Allure/Adapter/AllureAdapterTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PHPUnit\Framework\AssertionFailedError;
66
use PHPUnit\Framework\TestCase;
77
use PHPUnit\Framework\TestSuite;
8+
use PHPUnit\Framework\Warning;
89
use Exception;
910
use org\bovigo\vfs\vfsStream;
1011
use Throwable;
@@ -64,6 +65,19 @@ public function testAddError(): void
6465
$this->assertEquals($event, $events[0]);
6566
}
6667

68+
public function testAddWarning(): void
69+
{
70+
$warning = new Warning(self::EXCEPTION_MESSAGE);
71+
$time = $this->getTime();
72+
$this->getAllureAdapter()->addWarning($this, $warning, $time);
73+
$events = $this->getMockedLifecycle()->getEvents();
74+
$event = new TestCaseFailedEvent();
75+
$event->withException($warning)->withMessage(self::EXCEPTION_MESSAGE);
76+
$this->assertEquals(1, sizeof($events));
77+
$this->assertInstanceOf('\Yandex\Allure\Adapter\Event\TestCaseFailedEvent', $events[0]);
78+
$this->assertEquals($event, $events[0]);
79+
}
80+
6781
public function testAddFailure(): void
6882
{
6983
$exception = new AssertionFailedError(self::EXCEPTION_MESSAGE);

0 commit comments

Comments
 (0)