phpunit-speedtrap icon indicating copy to clipboard operation
phpunit-speedtrap copied to clipboard

Switch over to using hooks instead of implementing deprecated TestListener

Open localheinz opened this issue 6 years ago • 4 comments

To allow compatibility with phpunit/phpunit:^9.0.0, for which the TestListener interface will have been removed, an implementation using hooks need to be developed.

For reference, see

  • https://github.com/sebastianbergmann/phpunit/issues/3389
  • https://github.com/sebastianbergmann/phpunit/issues/3390

I took a stab at this earlier, but it appears there's a bit of a challenge as the hooks only receive the name of the test, rather than the TestCase. That is, from the name of the test the test class and test need to be derived in order to introspect its annotations for determining whether the test is configured for a different threshold then the basic setting in phpunit.xml.

localheinz avatar Apr 30 '19 06:04 localheinz

@localheinz Thank you for these details.

Looks like we will need a new major release and core logic to support PHPUnit 9.0. That version is set for release in February 2020.

Any chance you still have your implementation attempt? If so could you push it as a branch to your fork? I'm curious to see it and could offer some ideas.

johnkary avatar Jun 28 '19 22:06 johnkary

Instant upgrade path https://github.com/rectorphp/rector/pull/1270

Looks like we will need a new major release and core logic to support PHPUnit 9.0. That version is set for release in February 2020.

That's not related. Hooks are actually supported since PHPUnit 7.1.

TomasVotruba avatar Jul 02 '19 10:07 TomasVotruba

@johnkary what's the current state of this ticket? Is there anything we can help you with to get this fixed?

NicoHaase avatar Dec 01 '20 14:12 NicoHaase

Also interested in regaining this awesome feature.

Anything we can do to facilitate progress? Does #83 need to be rebased?

beporter avatar Jan 03 '22 18:01 beporter

Quick update: for those of you coming here and looking for an alternative that works with

  • phpunit/phpunit:^8.5.26
  • phpunit/phpunit:^9.6.0
  • phpunit/phpunit:^10.4.0

as well as

  • PHP 7.4
  • PHP 8.1
  • PHP 8.2
  • PHP 8.3

I just released ergebnis/phpunit-slow-test-detector:2.6.0 with support for all of these.

localheinz avatar Dec 03 '23 13:12 localheinz