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

Cannot run_single_phpunit_test when test uses @dataProvider #36

Open
adamtomat opened this issue Oct 9, 2017 · 2 comments
Open

Cannot run_single_phpunit_test when test uses @dataProvider #36

adamtomat opened this issue Oct 9, 2017 · 2 comments

Comments

@adamtomat
Copy link

I have a test which is using a data provider. It runs as expected when running the whole file, however the individual test filter does not account for data providers.


Example Test:

use Tests\TestCase;

class ExampleTest extends TestCase
{
    function exampleDataProvider()
    {
        return [
            ['foo'],
        ];
    }

    /**
     * @test
     * @dataProvider exampleDataProvider
     */
    function example_test($foo)
    {
        $this->assertSame('foo', $foo);
    }
}

Output when running run_phpunit_test:

cd /Users/adamtomat/Sites/<repo> && /Users/adamtomat/Sites/<repo>/vendor/phpunit/phpunit/phpunit /Users/adamtomat/Sites/<repo>/tests/Feature/ExampleTest.php

OK (1 test, 1 assertion)

Output when running run_single_phpunit_test:

cd /Users/adamtomat/Sites/<repo> && /Users/adamtomat/Sites/<repo>/vendor/phpunit/phpunit/phpunit /Users/adamtomat/Sites/<repo>/tests/Feature/ExampleTest.php --filter '/::example_test$/'

No tests executed!

After a little searching around, it looks like the filter needs to account for tests with data providers, which explains why it doesn't work:

https://stackoverflow.com/questions/12193606/cannot-run-single-test-with-data-provider-in-phpunit

@mvdnbrk
Copy link

mvdnbrk commented Oct 30, 2017

Also came across this problem. Created a pull request to solve this. #37

@devonmather
Copy link

Same issue here 👍🏻

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

No branches or pull requests

3 participants