Skip to content

Commit

Permalink
Add TestSuite class name to user message
Browse files Browse the repository at this point in the history
  • Loading branch information
epdenouden authored and sebastianbergmann committed Jan 21, 2019
1 parent 96c1264 commit 6a7bd25
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Framework/TestSuite.php
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,9 @@ public function run(TestResult $result = null): TestResult
}
}
} catch (Throwable $t) {
$error = new SyntheticError($t->getMessage(), 0, $t->getFile(), $t->getLine(), $t->getTrace());
$test = new \Failure('tearDownAfterClass');
$message = "Exception in {$this->name}::$afterClassMethod" . \PHP_EOL . $t->getMessage();
$error = new SyntheticError($message, 0, $t->getFile(), $t->getLine(), $t->getTrace());
$test = new \Failure($afterClassMethod);

$result->startTest($test);
$result->addFailure($test, $error, 0);
Expand Down
9 changes: 8 additions & 1 deletion tests/unit/Framework/TestSuiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ public function testCreateTestForConstructorlessTestClass(): void
TestSuite::createTest($reflection, 'TestForConstructorlessTestClass');
}

/**
* @testdox Handles exceptions in tearDownAfterClass()
*/
public function testTearDownAfterClassInTestSuite(): void
{
$suite = new TestSuite(\ExceptionInTearDownAfterClassTest::class);
Expand All @@ -238,6 +241,10 @@ public function testTearDownAfterClassInTestSuite(): void

/** @var TestFailure $failure */
$failure = $this->result->failures()[0];
$this->assertSame('throw Exception in tearDownAfterClass()', $failure->thrownException()->getMessage());
$this->assertSame(
'Exception in ExceptionInTearDownAfterClassTest::tearDownAfterClass' . \PHP_EOL .
'throw Exception in tearDownAfterClass()',
$failure->thrownException()->getMessage()
);
}
}

0 comments on commit 6a7bd25

Please sign in to comment.