Skip to content

Commit

Permalink
Show valid exception message in TeamCity logger in case of ExceptionW…
Browse files Browse the repository at this point in the history
…rapper
  • Loading branch information
wbars authored and sebastianbergmann committed Nov 16, 2017
1 parent 10e957f commit 970458c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/Util/Log/TeamCity.php
Expand Up @@ -11,7 +11,6 @@
namespace PHPUnit\Util\Log;

use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Exception;
use PHPUnit\Framework\ExceptionWrapper;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\Test;
Expand Down Expand Up @@ -337,9 +336,9 @@ private static function getMessage(\Exception $e)
{
$message = '';

if (!$e instanceof Exception) {
if (\strlen(\get_class($e)) != 0) {
$message .= \get_class($e);
if ($e instanceof ExceptionWrapper) {
if (\strlen($e->getClassName()) != 0) {
$message .= $e->getClassName();
}

if (\strlen($message) != 0 && \strlen($e->getMessage()) != 0) {
Expand Down
2 changes: 1 addition & 1 deletion tests/TextUI/teamcity-inner-exceptions.phpt
Expand Up @@ -25,7 +25,7 @@ PHPUnit %s by Sebastian Bergmann and contributors.

##teamcity[testStarted name='testNestedExceptions' locationHint='php_qn://%s%etests%e_files%eExceptionStackTest.php::\ExceptionStackTest::testNestedExceptions' flowId='%d']

##teamcity[testFailed name='testNestedExceptions' message='One' details=' %s%etests%e_files%eExceptionStackTest.php:22|n |n Caused by|n InvalidArgumentException: Two|n |n %s%etests%e_files%eExceptionStackTest.php:21|n |n Caused by|n Exception: Three|n |n %s%etests%e_files%eExceptionStackTest.php:20|n ' flowId='%d']
##teamcity[testFailed name='testNestedExceptions' message='Exception : One' details=' %s%etests%e_files%eExceptionStackTest.php:22|n |n Caused by|n InvalidArgumentException: Two|n |n %s%etests%e_files%eExceptionStackTest.php:21|n |n Caused by|n Exception: Three|n |n %s%etests%e_files%eExceptionStackTest.php:20|n ' flowId='%d']

##teamcity[testFinished name='testNestedExceptions' duration='%d' flowId='%d']

Expand Down

0 comments on commit 970458c

Please sign in to comment.