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 with empty dataProvider does not fail when alone #301

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

Test with empty dataProvider does not fail when alone #301

sandermarechal opened this issue Jul 18, 2011 · 2 comments

Comments

@sandermarechal
Copy link

A test with a dataProvider that returns an empty array normally generates a warning. But, when it is the only test, it does not generate a warning but is skipped instead. Example:

<?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 execute all tests, BarTest::testBar gives a warning, because of an empty dataProvider:

$ phpunit .
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 I just run a test on group bar the test is simply skipped without a warning. I would expect the same warning to be generated.

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



Time: 0 seconds, Memory: 3.50Mb

OK (0 tests, 0 assertions)
@edorian
Copy link
Contributor

edorian commented Nov 18, 2011

Depends on #10

@whatthejeff
Copy link
Contributor

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

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

F

Time: 0 seconds, Memory: 2.50Mb

There was 1 failure:

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


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

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