Skip to content

Commit 6298141

Browse files
author
Matheus Degiovani
committed
Printing cause of exception when present
1 parent 023b0fc commit 6298141

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

PHPUnit/TextUI/ResultPrinter.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,20 @@ protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect)
274274
$defect->thrownException()
275275
)
276276
);
277+
278+
$e = $defect->thrownException();
279+
if (method_exists($e, 'getPrevious')) {
280+
//php >= 5.3, exceptions may have a previous cause
281+
$e = $e->getPrevious();
282+
while ($e) {
283+
$this->write(
284+
"\nCaused by\n" .
285+
PHPUnit_Util_Filter::getFilteredStacktrace($e)
286+
);
287+
$e = $e->getPrevious();
288+
}
289+
}
290+
277291
}
278292

279293
/**

0 commit comments

Comments
 (0)