-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
Tests: fix recording code coverage for Tokenizer tests #314
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
Until now, code coverage was not being recorded for the Tokenizer tests due to the way the tests were set up. This new `AbstractTokenizerTestCase` class is intended to fix this. **Background info:** * Code run in a `setUpBeforeClass()` method does not cause code coverage to be recorded. * Code run in a `setUp()` method _does_ cause code coverage to be recorded. Now, the `AbstractMethodUnitTest` test case class was originally set up to allow for testing the utility methods in the `File` class. To do so in the most efficient way and to allow the tests to be fast, the file containing the code being used in the tests, is only tokenized once in a `setUpBeforeClass()` method. Over time, when Tokenizer tests were being introduced, the `AbstractMethodUnitTest` class also started to be used by these, which was fine as code coverage wasn't being measured or recorded anyway. However, this last part has been changed recently via PR 144, so now it is time to ensure that the Tokenizer related tests record code coverage too. This new test case class allows for that by moving the tokenization of the code used in the tests from `setUpBeforeClass()` to a `setUp()` method. As the tokenized file won't change during the test run, this is still only done once, but as that "once" is now in the `setUp()` method, it should allow for code coverage to be recorded. Note: while code coverage can now be measured and recorded for Tokenizer related tests, it will still not be very precise as the `Tokenizer\PHP` class contains "monster methods", which means that the `@covers` tags in the Tokenizer related tests cannot be set up to target only a small, specific part of that class, as targeted by the test. But that's a problem for another time. Loosely related to 146
Note: yes, the CI builds will be slower due to this change. This is mostly due to the code coverage calculations during the test run being very slow on PHP 5.4. This can't be helped, though the impact should be much less for the 4.0 branch in which the minimum PHP version becomes PHP 7.2. |
6 tasks
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.
Description
Tests: new AbstractTokenizerTestCase class
Until now, code coverage was not being recorded for the Tokenizer tests due to the way the tests were set up.
This new
AbstractTokenizerTestCase
class is intended to fix this.Background info:
setUpBeforeClass()
method does not cause code coverage to be recorded.setUp()
method does cause code coverage to be recorded.Now, the
AbstractMethodUnitTest
test case class was originally set up to allow for testing the utility methods in theFile
class.To do so in the most efficient way and to allow the tests to be fast, the file containing the code being used in the tests, is only tokenized once in a
setUpBeforeClass()
method.Over time, when Tokenizer tests were being introduced, the
AbstractMethodUnitTest
class also started to be used by these, which was fine as code coverage wasn't being measured or recorded anyway.However, this last part has been changed recently via PR #144, so now it is time to ensure that the Tokenizer related tests record code coverage too.
This new test case class allows for that by moving the tokenization of the code used in the tests from
setUpBeforeClass()
to asetUp()
method.As the tokenized file won't change during the test run, this is still only done once, but as that "once" is now in the
setUp()
method, it should allow for code coverage to be recorded.Note: while code coverage can now be measured and recorded for Tokenizer related tests, it will still not be very precise as the
Tokenizer\PHP
class contains "monster methods", which means that the@covers
tags in the Tokenizer related tests cannot be set up to target only a small, specific part of that class, as targeted by the test. But that's a problem for another time.Implement use of the new AbstractTokenizerTestCase class
AttributesTest: add missing
@covers
tagSuggested changelog entry
N/A
Related issues/external references
Loosely related to #146