diff --git a/src/Framework/TestFailure.php b/src/Framework/TestFailure.php index 835ea91cad5..4ea38415545 100644 --- a/src/Framework/TestFailure.php +++ b/src/Framework/TestFailure.php @@ -61,6 +61,11 @@ class PHPUnit_Framework_TestFailure */ private $testName; + /** + * @var PHPUnit_Framework_Test|null + */ + protected $failedTest; + /** * @var Exception */ @@ -79,6 +84,9 @@ public function __construct(PHPUnit_Framework_Test $failedTest, Exception $throw } else { $this->testName = get_class($failedTest); } + if (!$failedTest instanceof PHPUnit_Framework_TestCase || !$failedTest->isInIsolation()) { + $this->failedTest = $failedTest; + } $this->thrownException = $thrownException; } @@ -147,6 +155,21 @@ public function getTestName() return $this->testName; } + /** + * Returns the failing test. + * + * Note: The test object is not set when the test is executed in process + * isolation. + * + * @see PHPUnit_Framework_Exception + * + * @return PHPUnit_Framework_Test|null + */ + public function failedTest() + { + return $this->failedTest; + } + /** * Gets the thrown exception. *