Skip to content
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

Prevent tearDownAfterClass exceptions from killing PHPUnit #3490

Merged
merged 6 commits into from
Jan 21, 2019
Merged

Prevent tearDownAfterClass exceptions from killing PHPUnit #3490

merged 6 commits into from
Jan 21, 2019

Conversation

epdenouden
Copy link
Contributor

Found out yesterday that tearDown[AfterClass] exceptions were not handled by TestSuite the way it does for setUp[BeforeClass]. PHP simply exits to the command line:

image

This fix will report exceptions in tearDownAfterClass() by adding a dummy test at the end of a TestSuite called tearDownAfterClass with the original message and stack trace. A corrected code location hint is added to the top pointing to the offending line.

On the command line:

./phpunit tests/_files/ExceptionInTearDownAfterClassTest.php                                                         ✔ 

[header]
..                                                                  2 / 2 (100%)F

Time: 251 ms, Memory: 4.00MB

There was 1 failure:

1) Failure::tearDownAfterClass
throw Exception in tearDownAfterClass()

/Users/ewout/proj/phpunit/tests/_files/ExceptionInTearDownAfterClassTest.php:28
/Users/ewout/proj/phpunit/src/Framework/TestSuite.php:755
[etc]

FAILURES!
Tests: 3, Assertions: 2, Failures: 1.

In IntelliJ it looks like this:

image

@codecov
Copy link

codecov bot commented Jan 20, 2019

Codecov Report

Merging #3490 into 7.5 will increase coverage by 0.06%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##                7.5    #3490      +/-   ##
============================================
+ Coverage     83.36%   83.43%   +0.06%     
- Complexity     3622     3623       +1     
============================================
  Files           143      143              
  Lines          9639     9648       +9     
============================================
+ Hits           8036     8050      +14     
+ Misses         1603     1598       -5
Impacted Files Coverage Δ Complexity Δ
src/Framework/TestSuite.php 85.16% <100%> (+0.37%) 149 <0> (+1) ⬆️
src/Framework/SyntheticError.php 45.45% <0%> (+45.45%) 4% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b880c49...e9cec72. Read the comment docs.

@sebastianbergmann sebastianbergmann merged commit e9e0a01 into sebastianbergmann:7.5 Jan 21, 2019
@epdenouden epdenouden deleted the bugfix-teardownafterclass branch January 21, 2019 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants