Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Advanced codecoverage #5922

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

Closed
wants to merge 9 commits into from
Closed

Conversation

SamMousa
Copy link
Collaborator

@SamMousa SamMousa commented May 25, 2020

This PR adds support for setting any code coverage setting via the advanced key:

coverage:
  remote: false
  enabled: true
  local: true
  advanced:
    forceCoversAnnotation: true
    checkForMissingCoversAnnotation: true

It uses reflection to see if a setting is available and if so, it attempts to configure it. This means that it will work for current features as well.

Todo

@SamMousa SamMousa self-assigned this Jun 1, 2020
Copy link
Member

@DavertMik DavertMik left a comment

Choose a reason for hiding this comment

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

Please document changes and move settings from "advanced" level

enabled: [Asserts]
coverage:
enabled: true
advanced:
Copy link
Member

Choose a reason for hiding this comment

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

I don't think "advanced" have any meaning here.
code coverge settings are already as advanced as possible 😄

so please add those settings to coverage level and document them at CodeCoverage guide

Copy link
Member

Choose a reason for hiding this comment

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

or maybe if I understood it wrong, please find a better name instead of "advanced"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They are settings that are proxied directly to the underlying library; that is what makes them advanced.
Since we also have settings for the Codeception module I did not want to put them in the same namespace; it doesn't improve readability.
Currently we have these settings:

protected $defaultSettings = [
        'enabled'        => false,
        'remote'         => false,
        'local'          => false,
        'xdebug_session' => 'codeception',
        'remote_config'  => null,
        'show_uncovered' => false,
        'c3_url'         => null,
        'work_dir'       => null,
        'cookie_domain'  => null,
    ];

They are not the same, or even related to, the settings for the php-code-coverage library. That is why they do not live in the same namespace.

I'm not gonna bother discussing the name here since I honestly don't care about it :), if you have any other suggestion I'd be happy to change it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

so please add those settings to coverage level and document them at CodeCoverage guide

This is something I explicitly will not do. It would only serve as a duplicate of the underlying library documentation and will quickly grow out of date.
Instead I have referred to the source code of the library (since there is no documentation for all its configuration options). -- This leads us back to the original name: advanced.

Basically this is a way for you to go deep into the inner workings and change stuff, it is advanced because it requires reading the library source code and because troubles from using it will likely not be supported by the Codeception community.

Copy link
Member

Choose a reason for hiding this comment

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

@SamMousa
thanks, now I got the point. How about naming it "phpCodeCoverage" - which is just how you explained things.

coverage:
  phpCodeCoverage:
    # here go advanced settings

?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah fine with me. Will change it after the weekend

@SamMousa SamMousa mentioned this pull request Jun 5, 2020

if (isset($settings['coverage']['advanced'])) {
foreach ($settings['coverage']['advanced'] as $key => $value) {
$method = 'set' . ucfirst($key);
Copy link
Member

Choose a reason for hiding this comment

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

All set methods will be removed in php-code-coverage 9.0.0 - https://github.com/sebastianbergmann/php-code-coverage/blob/master/ChangeLog.md#removed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, just checked the changes, will be simple to accommodate them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

While the changes are simple to accomodate it means we must require php 7.3 and phpunit 9.3.
I am fine with upping this requirement, but I know others are not (@Naktibalda).

I will not spend time on creating multiple code paths just to accomodate older software versions as it goes against most of what I believe in; so I'm closing this PR.

Copy link

@frvade frvade Jun 12, 2020

Choose a reason for hiding this comment

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

What about upping the version of the Codeception to justify upping the requirements? We're using Codeception in our projects whith parallel tests by splitting tests in group. That's crazy fast and convenient. And it's impossible to use phpCodeCoverage as it is now in the stable version of Codeception because we're getting incorrect results when merging code coverage. So we're stucked with using our fork with hacks.

Personally I don't see any problems requiring latest version of the main testing package and especially version of the language that was published almost 2 years ago.

Please consider adding this options of codeCoverage package as it is severly needed by many developers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree; but the reality is that the main contributors on Codeception need to support older PHP versions.
We do not have the capacity to maintain multiple versions at this time.

@SamMousa SamMousa closed this Jun 8, 2020
@Naktibalda Naktibalda reopened this Jan 3, 2021
@Naktibalda
Copy link
Member

@SamMousa I think that these changes can be implemented in Codeception 5.0

And it is a one more reason to set lowest supported reason of PHPUnit to 9.0.

@Naktibalda Naktibalda changed the base branch from 4.1 to 5.0 January 3, 2021 11:16
@Naktibalda
Copy link
Member

Closes #5768

@Naktibalda
Copy link
Member

Replaced by #6423

@Naktibalda Naktibalda closed this Jul 28, 2022
@SamMousa SamMousa deleted the advanced-codecoverage branch August 16, 2022 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants