Skip to content
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

Closed
wants to merge 8 commits into from
Closed

Make use of PHPUnit 9 code coverage and reporting #1431

wants to merge 8 commits into from

Conversation

BlairCooper
Copy link
Contributor

Fixes #1430

Added support for Clover HTML report.
Pass phpunit.xml configuration values to filter and code coverage
classes.

Fixes #1430

Added support for Clover HTML report.
Pass phpunit.xml configuration values to filter and code coverage
classes.
Fixes #1430

Added support for Clover HTML report.
Pass phpunit.xml configuration values to filter and code coverage
classes.
@codecov
Copy link

codecov bot commented Nov 13, 2020

Codecov Report

Merging #1431 (29eba89) into master (e5b487f) will decrease coverage by 0.19%.
The diff coverage is 38.81%.

Impacted file tree graph

@@             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     
Impacted Files Coverage Δ Complexity Δ
...t/formatter9/CloverHtmlPHPUnitResultFormatter9.php 0.00% <0.00%> (ø) 4.00 <4.00> (?)
classes/phing/tasks/ext/phpunit/PHPUnitTask.php 52.06% <23.52%> (+8.14%) 99.00 <0.00> (+13.00)
...asses/phing/tasks/ext/phpunit/FormatterElement.php 45.45% <33.33%> (-0.89%) 20.00 <0.00> (+1.00) ⬇️
...ses/phing/tasks/ext/phpunit/PHPUnitTestRunner9.php 48.54% <48.54%> (ø) 47.00 <47.00> (?)
...ses/phing/tasks/ext/phpunit/PHPUnitTestRunner8.php 0.00% <0.00%> (-43.45%) 54.00% <0.00%> (-6.00%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e5b487f...29eba89. Read the comment docs.

@@ -51,28 +51,13 @@
</target>

<target name="reports" depends="configure">
<delete dir="tmp"/>
<delete dir="tmp"/>
Copy link
Member

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.

Copy link
Contributor Author

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;
Copy link
Member

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.

Copy link
Contributor Author

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") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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 = [];
Copy link
Member

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.

Copy link
Contributor Author

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\"");
}

/**
*
*/
Copy link
Member

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.

Copy link
Contributor Author

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 = [],
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

@siad007 siad007 left a 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;
}
Copy link
Member

@siad007 siad007 Nov 14, 2020

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.

Copy link
Contributor Author

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
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #1432

Copy link
Member

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" >
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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")

@siad007
Copy link
Member

siad007 commented Nov 14, 2020

@BlairCooper as you can see in #1432, there is no problem with the merge coverage feature.
Please revert all changes, which are not part of CloverHtmlPHPUnitResultFormatter9 and FormatterElement
Also the extended configuration feature with PHPUnitTask::codeCoverageConfig is a great new addition, which should go into the next release.

@BlairCooper
Copy link
Contributor Author

Reworking with just new formatter and runner for PHPUnit 9.

@BlairCooper BlairCooper deleted the phpunit9coverage branch November 14, 2020 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Make better use of PHPUnit 9 code coverage and reporting
2 participants