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

ReflectionException with $seleneseDirectory #72

Closed
crabcz opened this issue Nov 15, 2011 · 10 comments
Closed

ReflectionException with $seleneseDirectory #72

crabcz opened this issue Nov 15, 2011 · 10 comments

Comments

@crabcz
Copy link

crabcz commented Nov 15, 2011

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}
@crabcz
Copy link
Author

crabcz commented Nov 18, 2011

Couldn't wait to get this fixed, so I proposed a pull to sebastianbergmann/phpunit. Pull #414:
sebastianbergmann/phpunit#414

This is my first github pull request, so please be nice to me with criticism :)

@edorian
Copy link

edorian commented Nov 21, 2011

@giorgiosironi Tell me if you want this pulled :)

@giorgiosironi
Copy link
Owner

Of course. :)
However I need a simple things: a test written in Selenese targeting an HTML file; currently this functionality is not tested and I don't want to introduce regressions. The test just needs to be a simple hello world: loading a static HTML page and asserting that a text is present for example.

@edorian
Copy link

edorian commented Dec 15, 2011

I know the PR makes the issue go away but I don't understand why

Starting test 'SeleneseTest::/data/test.htm'.

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? :)

@giorgiosironi
Copy link
Owner

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...

@edorian
Copy link

edorian commented Dec 15, 2011

So doing if(!$className instanceof PHPUnit_Extensions_SeleniumTestCase) should to the trick there?

Not that it's really pretty but it feels a lot nicer than just ignoring all exceptions

@giorgiosironi
Copy link
Owner

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.

@zuernBernhard
Copy link

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 ?

@giorgiosironi
Copy link
Owner

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:
#72 (comment)

@edorian
Copy link

edorian commented Feb 18, 2012

Merged

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

4 participants