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

empty dataProvider causes test to be in-excludable #302

Closed
sandermarechal opened this issue Jul 18, 2011 · 2 comments
Closed

empty dataProvider causes test to be in-excludable #302

sandermarechal opened this issue Jul 18, 2011 · 2 comments

Comments

@sandermarechal
Copy link

When a test has an empty dataProvider, it does not seem possible to exclude it based on the group.

Here is the same test code I used for issue #301:

<?php

/**
 * This is e.g. phpunit-test/FooTest.php
 * @group foo
 */
class FooTest extends PHPUnit_Framework_TestCase
{
    public function testFoo()
    {
        $this->assertEquals(1, 1);
    }
}
<?php

/**
 * This is e.g. phpunit-test/BarTest.php
 * @group bar
 */
class BarTest extends PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider spit
     */
    public function testBar()
    {
        $this->assertEquals(1, 1);
    }

    public function spit()
    {
        return array();
    }
}

Or: https://gist.github.com/1089631

When I just run tests of group foo, the bar test is correctly skipped:

$ phpunit --group foo .
PHPUnit 3.5.14 by Sebastian Bergmann.

.

Time: 0 seconds, Memory: 3.75Mb

OK (1 test, 1 assertion)

When I do the reverse and exclude group bar instead of just including group foo, I get a warning about BarTest::testBar even though I want it excluded:

$ phpunit --exclude-group bar .
PHPUnit 3.5.14 by Sebastian Bergmann.

F.

Time: 0 seconds, Memory: 3.75Mb

There was 1 failure:

1) Warning
No tests found in suite "BarTest::testBar".


FAILURES!
Tests: 2, Assertions: 1, Failures: 1.

When the dataProvider is not empty, group exclusion works correctly. Here is what happens when I modify BarTest::spit to return a simple, 1-row dataset:

$ phpunit --exclude-group bar .
PHPUnit 3.5.14 by Sebastian Bergmann.

.

Time: 1 second, Memory: 3.75Mb

OK (1 test, 1 assertion)

I expect that BarTest is always excluded, even when the dataProvider happens to be empty. In fact, the enrire reason I am trying to exclude it is because I know beforehand that it will be empty!

@edorian
Copy link
Sponsor Contributor

edorian commented Nov 18, 2011

Related to #301, Depends on #10

@whatthejeff
Copy link
Contributor

This is no longer a bug. I think it was probably fixed by #781.

$ phpunit --exclude-group bar .
PHPUnit 3.7.18 by Sebastian Bergmann.

.

Time: 0 seconds, Memory: 2.50Mb

OK (1 test, 1 assertion)

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