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

Test class loaded during data provider execution is not discovered #2833

Closed
kubawerlos opened this issue Oct 29, 2017 · 4 comments · Fixed by N0rthernL1ghts/eloquent-bootstrap#2 or Zemhart/project_UAS_PHP#20

Comments

@kubawerlos
Copy link
Contributor

Q A
PHPUnit version 6.4.3
PHP version 7.1.11
Installation Method Composer

Having 2 test cases:

<?php

class ATest extends \PHPUnit\Framework\TestCase
{
    /**
     * @dataProvider provide
     */
    public function testNothingA($x)
    {
        $this->assertTrue($x);
    }

    public function provide() : array
    {
        $a = new \ReflectionClass(BTest::class);

        return [[true]];
    }
}

and

<?php

class BTest extends \PHPUnit\Framework\TestCase
{
    public function testNothingB()
    {
        $this->assertTrue(false);
    }
}

running them will result with executing only ATest.

It's not even listed:

vendor/bin/phpunit --list-tests
PHPUnit 6.4.3 by Sebastian Bergmann and contributors.

Available test(s):
 - Tests\ATest::testNothingA#0

After removing $a = new \ReflectionClass(BTest::class); or moving this line to testNothingA both classes will be executed. The problem is only with data provider.

@sebastianbergmann sebastianbergmann changed the title Calling reflection class for test class in data provider results with skipping execution of that test class. Test class loaded during data provider execution is not discovered Nov 10, 2017
@sebastianbergmann
Copy link
Owner

#2834 was reverted due to #2859

@kubawerlos
Copy link
Contributor Author

So I use my test case from the first solution plus the test from #2859 (comment) and try again, right?

@sebastianbergmann
Copy link
Owner

Yes, please.

@keradus
Copy link
Contributor

keradus commented Nov 15, 2017

at PHP CS Fixer, we come across this issue as well. it will be great to addition to have this solved!
would be really great to have it solved 👍
big 👍 for one actually working on it, we are with you @kubawerlos !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment