New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$this->getStatus() returns STATUS_PASSED in tearDown() after unexpected Exception #3031
Comments
I did not run the testcases for phpunit itself yet, but this seems to fix it: // phpunit/src/Framework/TestCase.php
750 } catch (Throwable $_e) {
751 $e = $_e;
752 $this->status = BaseTestRunner::STATUS_ERROR;
753 $this->statusMessage = $e->getMessage();
754 } |
I can reproduce the error in dev-master as well. I noticed there is a test called testExceptionInTest() in TestCaseTest.php. It tests exactly what this issue is about and pass. If I add the line: The status is set after tearDown() is executed. If I add the same line in |
I created a new file in _files/ to isolate this case and created a new test in TestCaseTest for it. Then, I solved the issue by adding the lines from lines 750 to 754 as I commented before. I'll create a pull request soon. |
…on inside tearDown()
… thrown Exception inside tearDown()
Hi, i'm almost sure, that problem is connected with this change - #2940 I suggest to leave setting of $this->status and $this->statusMessage on new place and add back on original place. It should be working solution. (Works for me) We need to check that tests were passed or failed in tearDown() function by calling function $this->hasFailed() and this is not currently working. In case exception was thrown in test status is not correctly set. |
@CDJojn Why do you need to know in |
@sebastianbergmann Hello Sebastian, we don't use PHPUnit project only for unit tests, but also for functional tests which are bound on different external services and our internal CI processes. During tearDown() we do cleanup and we need to know if test was failed from any reason (own exceptions, failed assertions, technical failure), in this case we need to contact internal/external APIs to log this test was failed + save texts logs, screenshots etc... |
Same issue in 6.5. |
Results in:
The text was updated successfully, but these errors were encountered: