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

Regression with multiple test case classes declared in a single sourcecode file #3881

Closed
sebastianbergmann opened this issue Oct 4, 2019 · 14 comments
Labels
event/eu-fossa/2019-10 EU-FOSSA Hackathon: October 2019 type/bug Something is broken

Comments

@sebastianbergmann
Copy link
Owner

While cleaning up the reproducing example from #3879, I ran into the following issue:

<?php
use PHPUnit\Framework\TestCase;

abstract class AbstractTest extends TestCase
{
    /**
     * @dataProvider provider
     */
    public function testOne(string $parameter): void
    {
        $this->assertSame('test', $parameter);
    }

    public function provider(): array
    {
        return [
            ['test'],
        ];
    }
}

final class Test extends AbstractTest
{
}

With PHPUnit 8.4.0 I get

PHPUnit 8.4.0 by Sebastian Bergmann and contributors.

W                                                                   1 / 1 (100%)

Time: 34 ms, Memory: 6.00 MB

There was 1 warning:

1) Warning
Cannot instantiate class "AbstractTest".

WARNINGS!
Tests: 1, Assertions: 0, Warnings: 1.

With PHPUnit 8.3.5 I get

PHPUnit 8.3.5 by Sebastian Bergmann and contributors.

.                                                                   1 / 1 (100%)

Time: 34 ms, Memory: 6.00 MB

OK (1 test, 1 assertion)
@sebastianbergmann sebastianbergmann added type/bug Something is broken type/backward-compatibility Something will be/is intentionally broken labels Oct 4, 2019
@sebastianbergmann
Copy link
Owner Author

@flow-control Could this be related to #3830?

@sebastianbergmann sebastianbergmann removed the type/backward-compatibility Something will be/is intentionally broken label Oct 4, 2019
@sebastianbergmann
Copy link
Owner Author

Simpler reproducing test case:

<?php
use PHPUnit\Framework\TestCase;

abstract class AbstractTest extends TestCase
{
    public function testOne(): void
    {
        $this->assertTrue(true);
    }
}

final class Test extends AbstractTest
{
}

@realFlowControl
Copy link
Sponsor Contributor

Could be related, i'll have look at it. How are you calling phpunit and how is the filename? Is it test.php or AbstractTest.php ?

@sebastianbergmann
Copy link
Owner Author

According to git bisect, 82e7076 is the first "bad commit".

@sebastianbergmann
Copy link
Owner Author

@flow-control I have the code shown in #3881 (comment) in Test.php and invoke PHPUnit with phpunit Test.

@sebastianbergmann
Copy link
Owner Author

sebastianbergmann commented Oct 4, 2019

For the record, this is how I bisected this:

$ cat run.sh               
#!/bin/sh
composer update
./phpunit --fail-on-warning /tmp/Test.php
$ git bisect start
$ git bisect good 8.3.5
$ git bisect bad 8.4.0
$ git bisect run ./run.sh

@realFlowControl
Copy link
Sponsor Contributor

Thanks, i found the problem and i will create a PR in the next hours to solve this. Maybe i deleted a bit too much in 82e7076 ;-)

@sebastianbergmann
Copy link
Owner Author

Thank you for looking into this!

@sebastianbergmann sebastianbergmann added the event/eu-fossa/2019-10 EU-FOSSA Hackathon: October 2019 label Oct 4, 2019
realFlowControl added a commit to realFlowControl/phpunit that referenced this issue Oct 4, 2019
@realFlowControl
Copy link
Sponsor Contributor

Submitted a fix in PR #3882
hope the pipeline runs 🤞

@gleb-svitelskiy
Copy link
Contributor

gleb-svitelskiy commented Oct 6, 2019

But example from #3881 (comment) still not working
While this #3881 (comment) is fixed

@realFlowControl
Copy link
Sponsor Contributor

I'll have a look

@sebastianbergmann
Copy link
Owner Author

@gleb-svitelskiy #3881 (comment) is a different issue that is tracked in #3879.

@realFlowControl
Copy link
Sponsor Contributor

realFlowControl commented Oct 7, 2019

I can confirm, that it fails, but with the exact same error message as described in #3879, so i assume this is going to be fixed in that Issue than.

  1. Warning
    The data provider specified for Issue3881DataProviderTest::testOne is invalid.
    Cannot instantiate abstract class Issue3881DataProviderAbstractTest

@sebastianbergmann
Copy link
Owner Author

@flow-control Exactly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event/eu-fossa/2019-10 EU-FOSSA Hackathon: October 2019 type/bug Something is broken
Projects
None yet
Development

No branches or pull requests

3 participants