This is a follow up issue to #2458487: Alter php.xml.dist to remove test classes from code coverage reports.

It is about removing test files from the code coverage reports with

./vendor/bin/phpunit --coverage-html ~/d8CodeCoverage/

Thing have changed, in the month since the issue was committed.- it look like test coverage has improved and in the current iteration new test files have risen up to clutter the top of the insufficient code coverage list [ see dashboard.html ] - this is a meaningless distraction and the 50 or so files can be removed with a stroke of a pen ... er I mean by refreshing the php.xml.dist

There are located in ./core/modules/system/tests/modules/form_test/src/Form

and have the prefix FormTest*.php
From git blame the files were introduced over a year ago #2030165: Convert form_test_* functions to classes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

martin107’s picture

Title: Remove more false positives from the insufficient code coverage lists. » 8% of the files having zero test coverage are incorrectly listed.
Assigned: martin107 » Unassigned
Status: Active » Needs review
FileSize
3.25 KB

I want to add additional rules that are correct but cast the widest net......

Removing files that match the wildcard FormTest*.php only grabs a small group of files.

better would be '*/tests/*' but there is no way in phpunit to do this....

So I have manually added every '*/test/*' in core today, this creates a maintenance headache.

But when I do this the number of files with zero coverage drops from 2182 to 2004 files.

So 8% of the files were being incorrectly listed.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dawehner’s picture

I'm confused that * doesn't work, given that it works for testsuites.

martin107’s picture

I'm confused that * doesn't work, given that it works for testsuites.

Thanks @dawehner

Yeah I am confused by that ... also

I want to ditch the patch - it is unmaintainable and find out why * does not work.

I think the only way to make progress is hard.

By way of explanation I am have been having trouble,.. over the last 4 months

using

/vendor/bin/phpunit --coverage-html ~/d8CodeCoverage/

it has not been that stable or at least there are conflict with contrib modules.

For example I found out today that https://www.drupal.org/project/image_raw_formatter has a reference to an acient version of phpunit (3.7 )
in its composer.json which was causing conflicts until I dumped it.

The solution is to put the work into get D8 working on a modern version of phpunit and then tickle many active contrib project to do the same.

On a modern version of phpunit the bug might have been solved by now, or least we will not get laughed at when we ask for support

For me D8 and my contrib modules settle on phpunit 4.8.24 which according to https://phpunit.de/ is the old stable release ( supported until Feb 2017 )
I would like to shoot for the current stable release phpunit 5.3

Anyway I need to look at this some more ... but I am posting earlier because I want to hear other opinions

martin107’s picture

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dawehner’s picture

@martin107
I'm wondering, is this still an issue?

martin107’s picture

Yes it is still a problem

Just to keep track from #4

For me my D8 and my contrib modules settle on phpunit 4.8.24 which according to https://phpunit.de/ is the old stable release ( supported until Feb 2017 )
I would like to shoot for the current stable release phpunit 5.3

When I looked today, six months or so later - my dev site has advanced to phpunit 4.8.27 - so in semantic versioning terms - "up by a few patch versions"

On a modern version of phpunit the bug might have been solved by now, or least we will not get laughed at when we ask for support

I no longer think the wildcard support is going to change anytime soon :) - but February is that much closer so maybe a side issue is needed to upgrade phpunit to at version that will be supported beyond Feb.

Every time I google for something along the lines of "phpunit exclude wildcards" I see stack overflow issues grumbling about this.

the solution is always use @group tags to filter out what you don't want

here is an example from Oct 2016

http://stackoverflow.com/questions/40040243/phpunit-exclude-tests-from-e...

I cannot see a way forward on this issue.... but hope springs external

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

borisson_’s picture

Since #2927806: Use PHPUnit 6 for testing when PHP version >= 7.2, we're a 6.x version of phpunit for tests running on php 7.2.
I'm not sure if this problem is fixable in that version of phpunit, otherwise I think we could integrate something like the patch in #1 and write a test that tests that all core modules are listed in there.

borisson_’s picture

Added a test to verify that all core modules are listed in there.

martin107’s picture

FileSize
6.07 KB
581 bytes

borisson_ ++ that is a really good improvement...it has brightened my day.

When I look at the test results ... it is warning we have an additional coding standard error.

unused "use" statement.

cut cut snip snip.. it is trivial to fix.

TLDR;

apropos o' nothing .. phpunit version watch.. yep as you say with php 7.2.x we are now getting warnings prompting us to run

composer run drupal-phpunit-upgrade

which today given, for myself at least. PHPUnit 6.5.8.. yay that is an improvement.

borisson_’s picture

Because this adds more work when adding a new module to core, this might need additional review from a core maintainer. I've tagged this issue with Needs subsystem maintainer review. Not sure if that is the right tag though.

borisson_’s picture

I'm not sure who I need to ping to get this reviewed by the correct maintainer. @dawehner can you help point to the correct person?

dawehner’s picture

Status: Needs review » Needs work
Issue tags: -Needs subsystem maintainer review
index 2a55d680f3..163d539dfd 100644
--- a/core/phpunit.xml.dist

--- a/core/phpunit.xml.dist
+++ b/core/phpunit.xml.dist

+++ b/core/phpunit.xml.dist
@@ -68,6 +68,82 @@

@@ -68,6 +68,82 @@
       <exclude>
         <directory suffix="Test.php">./</directory>
         <directory suffix="TestBase.php">./</directory>
+        <directory>./modules/action/tests</directory>
+        <directory>./modules/aggregator/tests</directory>
+        <directory>./modules/automated_cron/tests</directory>

Looking at https://github.com/sebastianbergmann/phpunit/blob/da1e2740d203e37e5311b0... it looks like you can specify a pattern, which I think we should do.

martin107’s picture

Assigned: Unassigned » martin107
Status: Needs work » Needs review
FileSize
641 bytes

Ah cool, My comment from #1 that there is no exclude pattern was from 2015

Thanks @dawehner .. that is useful information.

It would be a pitty to axe @borisson_'s test code...

But if that works then the solution would be ...this one liner

That would catch all *Test.php *TestBase.php *TestTrait.php all well as all test submodules.

I will test a machine run overnight and report back if it works.

martin107’s picture

Ah the pattern should be

*Tests*

also a counter example of things showing up that don't fit the pattern.

Drupal\simpletest\WebTestBase

So I am currently testing

<exclude-pattern>*/Tests/*</exclude-pattern>
<exclude-pattern>*/simpletest/*</exclude-pattern>
martin107’s picture

FileSize
124.01 KB

From #17

it looks like you can specify a pattern, which I think we should do.

I am going to have to go back to the drawing board ... filtering just does not have the effect that the documentation details

Here is a screen shot from the dashboard

It does show that ArchiveTar and DisplayPluginBase are our biggest "Project Risks"

but lots of things are obscured by test files showing up unexpectedly.

*/Tests/*

and

*/simpleTest*

Filter has failed

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

martin107’s picture

Assigned: martin107 » Unassigned
dawehner’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/phpunit.xml.dist
@@ -64,11 +64,8 @@
+      <!-- Exclude all test modules, tests etc -->

That seems 100% sensible for me!

catch’s picture

Version: 8.6.x-dev » 8.7.x-dev
Status: Reviewed & tested by the community » Fixed

Committed 93319b2 and pushed to 8.7.x. Thanks!

  • catch committed 93319b2 on 8.7.x
    Issue #2478115 by martin107, borisson_: 8% of the files having zero test...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

martin107’s picture

Just a little housekeeping

there is a follow up issue.