Skip to content

Missing code coverage on objects within @dataProvider methods #920

@pionl

Description

@pionl
Q A
php-code-coverage version 9.2.15
PHP version 8.1.7
Driver PCOV (same result in XDebug - Github actions
PCOV version (if used) 1.0.11
Installation Method Composer
Usage Method PHPUnit
PHPUnit version (if used) 9.5.21

Hi,

I have an issue while collecting code coverage only when objects are constructed in @dataProvider method.

Snímek obrazovky 2022-06-29 v 13 52 20

The code coverage will collect code coverage in test methods.

I'm constructing objects within the dataProvider to allow different "checks" based on "closure" I'm passing to the object.

Is this desired functionality?

Verification

Repository: https://github.com/wrk-flow/php-get-typed-value

vendor/bin/phpunit --coverage-text

If I add new test to ArrayTransformerTest file then the code coverage for ArrayTransformer is collected.

    public function testCoverage(): void
    {
        $test = new ArrayTransformer(closure: fn () => []);
        $this->assertNotNull($test);
    }
```php

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions