-
-
Notifications
You must be signed in to change notification settings - Fork 319
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
Make use of PHPUnit 9 code coverage and reporting #1431
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1431 +/- ##
============================================
- Coverage 54.27% 54.08% -0.20%
- Complexity 9119 9178 +59
============================================
Files 467 469 +2
Lines 22153 22289 +136
============================================
+ Hits 12024 12054 +30
- Misses 10129 10235 +106
Continue to review full report at Codecov.
|
@@ -51,28 +51,13 @@ | |||
</target> | |||
|
|||
<target name="reports" depends="configure"> | |||
<delete dir="tmp"/> | |||
<delete dir="tmp"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this ws change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -1,4 +1,6 @@ | |||
<?php | |||
use PHPUnit\TextUI\XmlConfiguration\CodeCoverage\CodeCoverage; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imports should be right after the file comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused, removed.
@@ -168,6 +168,9 @@ public function getFormatter() | |||
$this->formatter = new SummaryPHPUnitResultFormatter7($this->parent); | |||
} elseif ($this->type === "clover") { | |||
$this->formatter = new CloverPHPUnitResultFormatter7($this->parent); | |||
} elseif ($this->type === "clover-html") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added to the documentation as part of a separate change to follow this pull request.
/** | ||
* @var \PHPUnit\Runner\TestHook[] | ||
*/ | ||
private $listeners = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should rename all occurences to hook
(s) instead to cover the new behavior of phpunit.
Same for all accessors names as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put \PHPUnit\Framework\TestListener back on the class. Changing to use TestHook is beyond the scope of this change. It is certainly something that should be looked at in the future.
@@ -51,6 +51,33 @@ public function testXmlFormatter() | |||
$this->assertInLogs("<testcase name=\"testSayHello\" class=\"HelloWorldTest\""); | |||
} | |||
|
|||
/** | |||
* | |||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove useless empty comment blocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
*/ | ||
public function __construct( | ||
Project $project, | ||
$groups = [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add missing argument type hints.
Same for all new methods in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need some more time to go through this PR.
So the request changes could be extended later on.
|
||
if ($res->riskyCount() > 0) { | ||
$this->hasRisky = true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reduce complexity and avoid not needed conditions.
$this->hasFailures = $res->failureCount() > 0;
As seen in the Codecov Report
- Complexity 9119 9187 +68
There is also a big raise on missing test coverage for your changes:
- Misses 10129 10242 +113
We should investigate why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the complexity suggestion. The raise in missing coverage is likely due to adding PHPUnitTestRunner9 which results in PHPUnitTestRunner8 not being used.
* @author Michiel Rook <mrook@php.net> | ||
* @package phing.tasks.ext.phpunit | ||
*/ | ||
class PHPUnitTestRunner9 implements \PHPUnit\Runner\TestHook |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reenable the required and useful enhancement for collecting coverage data by db.
Without this feature we are not able to merge coverage across different runs of phpunit tasks to merge test coverage from multiple test runs from different projects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That isn't something I removed. It appears PHPUnit no longer writes to the coverage database.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #1432
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code coverage merge feature (special the db function) has nothing to do with phpunit itself.
Please have a look at the coverage tasks https://github.com/phingofficial/task-coverage/tree/master/src
</target> | ||
|
||
<target name="testPhpunitConfig"> | ||
<phpunit configuration="phpunit-test.xml" codecoverage="false" > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will increase test execution time in build from 35s to 61s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but also adds to the code coverage and specifically tests new code that was added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but also adds to the code coverage and specifically tests new code that was added.
To be honest - it just executes the whole test suite again and ignores code-coverage entirely! (codecoverage="false"
)
@BlairCooper as you can see in #1432, there is no problem with the merge coverage feature. |
Reworking with just new formatter and runner for PHPUnit 9. |
Fixes #1430
Added support for Clover HTML report.
Pass phpunit.xml configuration values to filter and code coverage
classes.