ergebnis / phpunit-slow-test-detector

⏱️ Provides a composer package with an extension for detecting slow tests in phpunit/phpunit.
MIT License
109 stars 5 forks source link

Measure duration of setup (before) & teardown (after) test class #398

Open mvorisek opened 9 months ago

mvorisek commented 9 months ago

TestCase::setUpBeforeClass and TestCasetearDownAfterClass are not measured now and cannot be measured now, as currently the duration is measured per test.

What about measuring these too and reporting it as Cl::setUpBeforeClass/Cl::tearDownAfterClass items?

basic tests added in: #397

please note this must work with test process isolation correctly, where it might be counted into individual test duration

one example of (possibly) slow TestCase::setUpBeforeClass is https://github.com/atk4/ui/blob/5.0.0/tests/DemosHttpTest.php#L35, ie. things like starting (shared) webserver for a whole test class

related with #378, but not blocking

mvorisek commented 8 months ago

before class duration can be measured using these hooks: https://github.com/sebastianbergmann/phpunit/blob/10.0.0/src/Framework/TestSuite.php#L344-L396

and after class duration: https://github.com/sebastianbergmann/phpunit/blob/10.0.0/src/Framework/TestRunner.php#L238 - https://github.com/sebastianbergmann/phpunit/blob/10.0.0/src/Framework/TestSuite.php#L439

localheinz commented 8 months ago

That was my plan, @mvorisek!