giorgiosironi / phpunit-selenium

Selenium RC integration for PHPUnit
http://www.phpunit.de/
Other
601 stars 271 forks source link

browserOnAllTests() weird behaviour #239

Open zerkms opened 11 years ago

zerkms commented 11 years ago

The current implementation looks like:

private function browserOnAllTests(PHPUnit_Framework_TestSuite $suite, array $browser)
{
    foreach ($suite->tests() as $test) {
        if ($test instanceof PHPUnit_Framework_TestSuite) {
            $this->browserOnAllTests($test, $browser);
        } else {
            $test->setupSpecificBrowser($browser);
        }
    }
}

How to reproduce: create a test with wrong @dataProvider, like return array(1,2,3);

Stacktrace:

$ phpunit --filter Null FiltersTest.php
PHP Fatal error:  Call to undefined method PHPUnit_Framework_Warning::setupSpecificBrowser() in /usr/share/php/PHPUnit/Extensions/SeleniumBrowserSuite.php on line 95
PHP Stack trace:
PHP   1. {main}() /usr/bin/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
PHP   3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:130
PHP   4. PHPUnit_Runner_BaseTestRunner->getTest() /usr/share/php/PHPUnit/TextUI/Command.php:150
PHP   5. ReflectionMethod->invoke() /usr/share/php/PHPUnit/Runner/BaseTestRunner.php:124
PHP   6. PHPUnit_Extensions_Selenium2TestCase::suite() /usr/share/php/PHPUnit/Runner/BaseTestRunner.php:124
PHP   7. PHPUnit_Extensions_SeleniumTestSuite::fromTestCaseClass() /usr/share/php/PHPUnit/Extensions/Selenium2TestCase.php:309
PHP   8. PHPUnit_Extensions_SeleniumBrowserSuite->setupSpecificBrowser() /usr/share/php/PHPUnit/Extensions/SeleniumTestSuite.php:135
PHP   9. PHPUnit_Extensions_SeleniumBrowserSuite->browserOnAllTests() /usr/share/php/PHPUnit/Extensions/SeleniumBrowserSuite.php:86
PHP  10. PHPUnit_Extensions_SeleniumBrowserSuite->browserOnAllTests() /usr/share/php/PHPUnit/Extensions/SeleniumBrowserSuite.php:93

UPD: the message in the PHPUnit_Framework_Warning is The data provider specified for FiltersTest::testFilterByNull is invalid.\nData set #0 is invalid.

So seems like this warning should be forwarded further without running?

giorgiosironi commented 11 years ago

Do correct @dataProvider methods work? If you want to improve the error message I will look at a PR

zerkms commented 11 years ago

Correct @dataProvider does work, but it was tricky to find out the issue, since the original error message was lost and not informative was output

yugaego commented 11 years ago

I encountered the same problem on a fresh installation from PEAR today. I'm getting:

phpunit --verbose functional/GTest.php

PHP Fatal error: Call to undefined method PHPUnit_Framework_Warning::setupSpecificBrowser() in /usr/lib/php/pear/PHPUnit/Extensions/SeleniumBrowserSuite.php on line 95 PHP Stack trace: PHP 1. {main}() /usr/bin/phpunit:0 PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46 PHP 3. PHPUnit_TextUI_Command->run() /usr/lib/php/pear/PHPUnit/TextUI/Command.php:129 PHP 4. PHPUnit_Runner_BaseTestRunner->getTest() /usr/lib/php/pear/PHPUnit/TextUI/Command.php:150 PHP 5. ReflectionMethod->invoke() /usr/lib/php/pear/PHPUnit/Runner/BaseTestRunner.php:124 PHP 6. PHPUnit_Extensions_SeleniumTestCase::suite() /usr/lib/php/pear/PHPUnit/Runner/BaseTestRunner.php:124 PHP 7. PHPUnit_Extensions_SeleniumTestSuite::fromTestCaseClass() /usr/lib/php/pear/PHPUnit/Extensions/SeleniumTestCase.php:618 PHP 8. PHPUnit_Extensions_SeleniumBrowserSuite->setupSpecificBrowser() /usr/lib/php/pear/PHPUnit/Extensions/SeleniumTestSuite.php:135 PHP 9. PHPUnit_Extensions_SeleniumBrowserSuite->browserOnAllTests() /usr/lib/php/pear/PHPUnit/Extensions/SeleniumBrowserSuite.php:86

When I checked the code that causes the error, it appeared, that actually I'm getting PHPUnit_Framework_Warning with the error: Test method "testNotBannedGroupNewsList" in test class "GTest" is not public., which remains hidden and difficult to troubleshoot.

zerkms commented 11 years ago

@yugenekr, as long as there are at least two of us I will try to provide a pull-request then

zerkms commented 11 years ago

Well, for me phpunit 3.6.10 (just a phpunit without selenium, in similar case) behaves even worse - it just skips the test with issue without any notifications.