Skip to content

Tests with data providers in parent class don't work anymore #3879

Closed
@l-x

Description

@l-x
Q A
PHPUnit version 8.4.0
PHP version 7.3.9
Installation Method Composer

Summary

Tests classes that contain a test method utilizing a data provider defined in a parent class will produce a warning.

Previous Behavior

No warnings will be shown

Current Behavior

Warning:

The data provider specified for FuTest::testFu is invalid.
Cannot instantiate abstract class AbstractFuTestCase

How to reproduce

abstract class AbstractFuTestCase extends \PHPUnit\Framework\TestCase
{
    public function dataProvider(): array
    {
        return [
            ['fu'],
            ['bar'],
        ];
    }

    /**
     * @dataProvider dataProvider
     */
    public function testFu(string $bar): void
    {
        $this->assertTrue(true);
    }
}

class FuTest extends AbstractFuTestCase
{

}

Just run the FuTest

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething is broken

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions