-
Notifications
You must be signed in to change notification settings - Fork 62
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
Use PHPUnit Extension system instead of Listener #83
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…stem in PHPUnit 8
Class PHPUnit\Framework\TestCase implements interface PHPUnit\Framework\SelfDescribing which allows the test to return a string describing itself, including its data. However, including the data in the test output renders it incompatible with PHPUnit's --filter CLI flag. When upgrading to PHPUnit's Hook system, SpeedTrap methods had to switch from accepting object TestClass to string $test. The new $test variable reports the class name with an argument list enclosed in parens: JohnKary\PHPUnit\Listener\Tests\SomeSlowTest::testWithDataProvider with data set "Rock" (800) This format is not currently compatible with PHPUnit's --filter argument: # Does not run intended test case with dataProvider "Rock" vendor/bin/phpunit --filter='JohnKary\\PHPUnit\\Listener\\Tests\\SomeSlowTest::testWithDataProvider with data set "Rock" (800)' This commit assumes the vast majority of test suites will use PHPUnit's default TestCase class, thus their test will report with the data enclosed in parens. We will filter out the ` (800)` part from all test outputs and allows SpeedTrap to continue outputting a test format compatible with --filter: You should really speed up these slow tests (>500ms)... 1. 802ms to run JohnKary\\PHPUnit\\Listener\\Tests\\SomeSlowTest::testWithDataProvider with data set "Rock" vendor/bin/phpunit --filter='JohnKary\\PHPUnit\\Listener\\Tests\\SomeSlowTest::testWithDataProvider with data set "Rock"'
PHPUnit Extensions and Hooks no longer allow manipulating the Test Runner because they no longer have access to the TestCase class. Extensions are instead only given the string of the current test class, method and data. Without access to the Test Runner an Extension cannot stop further tests from running in a responsible way without terminating the PHP process.
PHPUnit 8.0.0 requires this as a minimum PHP version, so we must match it.
Hello, what is the status of this PR ? |
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PHPUnit 8 introduced the Hooks Extension system which deprecated the Listener system.
This PR completes the work started by @vlaurier in #67 to implement the Hooks Extension system, and will close issue #60.
New minimum version constraints
PHPUnit 8.0+
PHP 7.2+ (required by PHPUnit 8)
New namespace and method signatures
The SpeedTrap class has moved:
Various method signature within the
SpeedTrap
class have also been changed. Updates are required if you have extended SpeedTrap for other uses.New way to register SpeedTrap with
phpunit.xml
PHPUnit extensions are registered slightly differently in phpunit.xml:
Remove option stopOnSlow
Prior to this PR SpeedTrap supported an option
stopOnSlow
to prematurely stop the test runner after encountering a slow test.The PHPUnit Extension system does not allow Extensions to alter the test runner. The test runner cannot be stopped without killing the current PHP process. So the stopOnSlow feature had to be removed.
TODO