-
Notifications
You must be signed in to change notification settings - Fork 271
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
ReflectionException with $seleneseDirectory #72
Comments
Couldn't wait to get this fixed, so I proposed a pull to sebastianbergmann/phpunit. Pull #414: This is my first github pull request, so please be nice to me with criticism :) |
@giorgiosironi Tell me if you want this pulled :) |
Of course. :) |
I know the PR makes the issue go away but I don't understand why
shows up at all. There seems to be an underlying issues with that that would only get covered up why implementing this try/catch solution? Can you take another look at it please and tell me if thats really the correct fix? :) |
In the case of Selenese tests, there is no test*() method but the test is specified as an external HTML file containing the commands. When generating the suite for a Testcase Class, the current implementation does not have a method to refer to, so it uses the filename as $name, the first parameter of PHPUnit_Framework_TestCase::__construct(). The code in PHPUnit_Util_Test always assume the name is a valid method, however, and so it explodes. Now if only that $name would have been called $testMethodName or $perClassUniqueTestName, we would know which code is correct... |
So doing Not that it's really pretty but it feels a lot nicer than just ignoring all exceptions |
I think a cleaner solution is to check before creating a ReflectionMethod with method_exists(): this allows any Testcase Class to create tests using a name not corresponding to any method and avoids the use of exceptions for flow control. |
So what is the Solutiuon for the end-user ? merging the pullrequest until there is a new release thich fixes the problem ? Why not include the Pull-Request until there is a new solution that works like you suggest ? |
PHPUnit_Selenium cannot do anything for this issue; it can be fixed by relaxing PHPUnit expectation on "test names are always methods" like explained here: |
Merged |
copied from:
@mhoareau84 wrote here sebastianbergmann/phpunit#389 :
and I have the same behavior
I am trying to use a directory of Selenese/HTML files as tests with the property $seleneseDirectory,
as described here: http://www.phpunit.de/manual/3.6/en/selenium.html#selenium.seleniumtestcase.examples.WebTest4.php
Here my test:
setHost ( "127.0.0.1" ); $this->setPort ( 8888 ); $this->setBrowser ( "*safari" ); $this->setBrowserUrl ( "http://www.google.com/" ); $this->setTimeout ( 60000 ); } ``` } When i run the following command line: phpunit SeleneseTest.php It is working correctly. But when i add the option for code coverage, i got the following error: phpunit --coverage-html build/logs/coverage/ SeleneseTest.php PHPUnit 3.5.15 by Sebastian Bergmann. . ReflectionException: Method SeleneseTest::selenium_ide/search.html() does not exist in /Users/user/pear/share/pear/PHP/CodeCoverage/Util.php on line 218 (search.html is my test case in html saved by selenium IDE) Is that a bug ? Or did I miss something ? --- I have the same issues, even without code coverage on: I'm using phpunit 3.6.3 Here's my stack trace: $ phpunit --debug --verbose --bootstrap _tests/phpUnit/bootstrap.php _tests/selenium/html/SeleneseTest.php PHPUnit 3.6.3 by Sebastian Bergmann. Starting test 'SeleneseTest::/data/test.htm'. .exception 'ReflectionException' with message 'Method SeleneseTest::/data/test.htm() does not exist' in /usr/share/php/PHPUnit/Util/Test.php:264 Stack trace: #0 /usr/share/php/PHPUnit/Util/Test.php(264): ReflectionMethod->__construct('SeleneseTest', '/data/dev/actum...') #1 /usr/share/php/PHPUnit/Util/Test.php(370): PHPUnit_Util_Test::parseTestMethodAnnotations('SeleneseTest', '/data/test.htm...') #2 /usr/share/php/PHPUnit/Util/Test.php(421): PHPUnit_Util_Test::getGroups('SeleneseTest', '/data/dev/actum...') #3 /usr/share/php/PHPUnit/Framework/TestResult.php(390): PHPUnit_Util_Test::getSize('SeleneseTest', '/data/test.htm...') #4 /usr/share/php/PHPUnit/Framework/TestResult.php(742): PHPUnit_Framework_TestResult->endTest(Object(SeleneseTest), 28.454544067383) #5 /usr/share/php/PHPUnit/Extensions/SeleniumTestCase.php(527): PHPUnit_Framework_TestResult->run(Object(SeleneseTest)) #6 /usr/share/php/PHPUnit/Framework/TestSuite.php(772): PHPUnit_Extensions_SeleniumTestCase->run(Object(PHPUnit_Framework_TestResult)) #7 /usr/share/php/PHPUnit/Framework/TestSuite.php(745): PHPUnit_Framework_TestSuite->runTest(Object(SeleneseTest), Object(PHPUnit_Framework_TestResult)) #8 /usr/share/php/PHPUnit/TextUI/TestRunner.php(325): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult), false, Array, Array, false) #9 /usr/share/php/PHPUnit/TextUI/Command.php(187): PHPUnit_TextUI_TestRunner->doRun(Object(PHPUnit_Framework_TestSuite), Array) #10 /usr/share/php/PHPUnit/TextUI/Command.php(125): PHPUnit_TextUI_Command->run(Array, true) #11 /usr/bin/phpunit(44): PHPUnit_TextUI_Command::main() #12 {main}The text was updated successfully, but these errors were encountered: