I have gone through various tutorials/posts to install PHPUnit with Selenium on my Ubuntu system. I believe I have everything setup as required:
/usr/share/php$ phpunit --version
PHPUnit 3.6.10 by Sebastian Bergmann.
So using the IDE I create my test, and save it for running, which appears to be setup as required. So I run the test using:
phpunit /home/retrobadger/working_files/tutorials/phpunit/selenium1.php
But everytime I run it, I get the error below:
PHP Fatal error: Class 'PHPUnit_Extensions_SeleniumTestSuite' not found in /usr/share/php/PHPUnit/Extensions/SeleniumTestCase.php on line 394
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_SeleniumTestCase::suite() /usr/share/php/PHPUnit/Extensions/SeleniumTestCase.php:0
The file in extensions exists, and I have set very open priviledges to it. The only things I can think of are that either my SeleniumTestCase.php is faulty, or that I need to require another file no other tutorials have suggested.
Any recommendations would be greatly appreciated. I have little experience with PHPUnit so expect my mistake is a basic one.
Thanks for any advice you can give,
Dan
Check that you include PHPUnit when you call tests.. either in php.ini, or with IDE that you run, or explicitly - right now it just can't find class.. which means that PHPUnit is not reachable. Try a simplier class, PHPUnit_Extensions_SeleniumTestCase
Related
I am trying to debug Magendo 1.9.2.4 app\code\core\Mage\Core\Controller\Varien\Router\Standard.php. I am using PhpStorm with Xdebug.
During the debug it shows me an error that it cannot find the class Abstract that it's referring to.
Here is the full log:
C:\xampp\php\php.exe -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 C:\xampp\htdocs\vaimo\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php
PHP Fatal error: Class 'Mage_Core_Controller_Varien_Router_Abstract' not found in C:\xampp\htdocs\vaimo\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php on line 28
PHP Stack trace:
PHP 1. {main}() C:\xampp\htdocs\vaimo\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php:0
Fatal error: Class 'Mage_Core_Controller_Varien_Router_Abstract' not found in C:\xampp\htdocs\vaimo\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php on line 28
Call Stack:
0.0699 193008 1. {main}() C:\xampp\htdocs\vaimo\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php:0
Process finished with exit code 255
Class Standard extends from Abstract class which is located in different file but in the same folder with Standard.
You are doing it wrong.
You are debugging your code in CLI environment ("PHP Script" type of Run/Debug Configuration). This way you are executing your C:\xampp\htdocs\vaimo\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php file directly in terminal hence the Magento's bootstrap code (class autoloading etc) is not executed and PHP (yes, this error comes from PHP interpreter itself) is unable to find your parent class.
Solution: do not debug in CLI mode using "PHP Script" type of config -- debug it via browser as Web Application instead with correct type of config. This way normal Magento routine will be in place (autoloading/configs/db connection/etc) -- https://confluence.jetbrains.com/display/PhpStorm/Debugging+PHP+Web+Applications+with+Run+Debug+Configurations.
All debugging materials
Zero-configuration approach -- when you initiate debugging from the browser using xdebug browser extension or manually setting up cookie/xdebug param.
I know, isnt as if Composer or Travis not work, I do not get to do that work fine, I do not understand how autoload runs locally but not in Travis build.
If someone could shed light on this problem that I have, I would be very grateful.
The problem specifically is displayed when you can not find an interface ...
as the error pops up when you do not see the "namespace\namespace\interface", I think that should be the autoload, should not be loading very well for the test in Travis.
Here is:
PHP Fatal error: Interface 'RestGalleries\Interfaces\User' not found in /home/travis/build/estebanmatias92/RestGalleries/src/RestGalleries/APIs/Flickr/FlickrUser.php on line 15
PHP Stack trace:
PHP 1. {main}() /home/travis/.phpenv/versions/5.4.25/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /home/travis/.phpenv/versions/5.4.25/bin/phpunit:46
PHP 3. PHPUnit_TextUI_Command->run() /home/travis/.phpenv/versions/5.4.25/share/pyrus/.pear/php/PHPUnit/TextUI/Command.php:129
PHP 4. PHPUnit_TextUI_TestRunner->doRun() /home/travis/.phpenv/versions/5.4.25/share/pyrus/.pear/php/PHPUnit/TextUI/Command.php:176
PHP 5. PHPUnit_Framework_TestSuite->run() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/TextUI/TestRunner.php:349
PHP 6. PHPUnit_Framework_TestSuite->run() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:705
PHP 7. PHPUnit_Framework_TestSuite->run() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:705
PHP 8. PHPUnit_Framework_TestSuite->runTest() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:745
PHP 9. PHPUnit_Framework_TestCase->run() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:775
PHP 10. PHPUnit_Framework_TestResult->run() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:783
PHP 11. PHPUnit_Framework_TestCase->runBare() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/Framework/TestResult.php:648
PHP 12. PHPUnit_Framework_TestCase->runTest() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:838
PHP 13. ReflectionMethod->invokeArgs() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:983
PHP 14. RestGalleriesTest->testFindUserReturnApiUserObject() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:983
PHP 15. Composer\Autoload\ClassLoader->loadClass() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:0
PHP 16. Composer\Autoload\includeFile() /home/travis/build/estebanmatias92/RestGalleries/vendor/composer/ClassLoader.php:269
PHP 17. include() /home/travis/build/estebanmatias92/RestGalleries/vendor/composer/ClassLoader.php:363
Frankly I can not think it can be right now. I leave my code on github and the failing build (Until the time, i have failed at all with this, but leave the last build to see).
Github: https://github.com/estebanmatias92/RestGalleries
Travis CI build: https://travis-ci.org/estebanmatias92/RestGalleries/jobs/19337261
Are you are working on OSX which has case-insensitive filesystem by default? Try renaming the folder interfaces to Interfaces.
I am having a great deal of trouble with NetBeans 7.2.1 using PHP and the Include Path. This may or may not be related to Netbeans PHP Include Path seems unused, either Project or Global where I state that NetBeans is not using its Project or Global Include Path. However, in this case, NetBeans is not searching the entire PHP Include_Path variable.
The PHP Include_Path is listed in the error messages. The file AutoloaderFactory.php is in
D:\PHP\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Loader;
However, when I try to use NetBeans/Tools/Create PHPUnit Tests, I receive a series of warning and error messages saying that AutoloaderFactory.php is not found. These messages search only three of the provided libraries which do not include the library with the required class.
As a NetBeans noob, I am obviously not understanding something about it. But, I can't build my project because it won't find the required classes no matter what I do, including using Project, Globabl and PHP Include Paths. Can someone help me?
The error messages are included below. Thanks...RG
PHPUnit Skeleton Generator 1.2.0 by Sebastian Bergmann.
Warning: include(D:\Program Files (x86)\Zend\ZendServer\share\ZendFramework\library\Zend\Loader\AutoloaderFactory.php): failed to open stream: No such file or directory in D:\PHP\zf2-tutorial\init_autoloader.php on line 38
Call Stack:
0.0007 321856 1. {main}() K:\phpunit-skelgen:0
0.0062 472944 2. SebastianBergmann\PHPUnit\SkeletonGenerator\Command::main() K:\phpunit-skelgen:45
0.0167 980480 3. ReflectionClass->newInstanceArgs() K:\pear\SebastianBergmann\PHPUnit\SkeletonGenerator\Command.php:171
0.0167 980936 4. SebastianBergmann\PHPUnit\SkeletonGenerator\TestGenerator->__construct() K:\pear\SebastianBergmann\PHPUnit\SkeletonGenerator\Command.php:171
0.0178 987216 5. include_once('D:\PHP\zf2-tutorial\module\Album\src\Album\Controller\AlbumController.php') K:\pear\SebastianBergmann\PHPUnit\SkeletonGenerator\TestGenerator.php:125
0.0213 993680 6. require_once('D:\PHP\zf2-tutorial\init_autoloader.php') D:\PHP\zf2-tutorial\module\Album\src\Album\Controller\AlbumController.php:4
Warning: include(): Failed opening 'D:\Program Files (x86)\Zend\ZendServer\share\ZendFramework\library\Zend\Loader\AutoloaderFactory.php' for inclusion (include_path='D:\PHP\Includes;D:\PHP\zf2-tutorial;D:\PHP\ZendProjects\htdocs\Includes;D:\PHP\zf2-tutorial\vendor\zendframework\zendframework\library;D:\Program Files (x86)\Zend\ZendServer\share\ZendFramework\library;K:\pear') in D:\PHP\zf2-tutorial\init_autoloader.php on line 38
Call Stack:
0.0007 321856 1. {main}() K:\phpunit-skelgen:0
0.0062 472944 2. SebastianBergmann\PHPUnit\SkeletonGenerator\Command::main() K:\phpunit-skelgen:45
0.0167 980480 3. ReflectionClass->newInstanceArgs() K:\pear\SebastianBergmann\PHPUnit\SkeletonGenerator\Command.php:171
0.0167 980936 4. SebastianBergmann\PHPUnit\SkeletonGenerator\TestGenerator->__construct() K:\pear\SebastianBergmann\PHPUnit\SkeletonGenerator\Command.php:171
0.0178 987216 5. include_once('D:\PHP\zf2-tutorial\module\Album\src\Album\Controller\AlbumController.php') K:\pear\SebastianBergmann\PHPUnit\SkeletonGenerator\TestGenerator.php:125
0.0213 993680 6. require_once('D:\PHP\zf2-tutorial\init_autoloader.php') D:\PHP\zf2-tutorial\module\Album\src\Album\Controller\AlbumController.php:4
Fatal error: Class 'Zend\Loader\AutoloaderFactory' not found in D:\PHP\zf2-tutorial\init_autoloader.php on line 39
Call Stack:
0.0007 321856 1. {main}() K:\phpunit-skelgen:0
0.0062 472944 2. SebastianBergmann\PHPUnit\SkeletonGenerator\Command::main() K:\phpunit-skelgen:45
0.0167 980480 3. ReflectionClass->newInstanceArgs() K:\pear\SebastianBergmann\PHPUnit\SkeletonGenerator\Command.php:171
0.0167 980936 4. SebastianBergmann\PHPUnit\SkeletonGenerator\TestGenerator->__construct() K:\pear\SebastianBergmann\PHPUnit\SkeletonGenerator\Command.php:171
0.0178 987216 5. include_once('D:\PHP\zf2-tutorial\module\Album\src\Album\Controller\AlbumController.php') K:\pear\SebastianBergmann\PHPUnit\SkeletonGenerator\TestGenerator.php:125
0.0213 993680 6. require_once('D:\PHP\zf2-tutorial\init_autoloader.php') D:\PHP\zf2-tutorial\module\Album\src\Album\Controller\AlbumController.php:4
I totally purged NetBeans and reinstalled it. That included doing a registry clean after uninstalling NetBeans. At this point, the PHP Include_Path is being searched. I do not know whether or not the NetBeans Include_Path is being searched but that is another problem and I am not even sure why I should care since that won't matter after implementation. I'd be glad to hear a better answer.
After restarting Netbeans, search worked for me, Netbeans 7.4.
I have a PHPUnit test suite that is currently causing a fatal error due to a class definition that's not being found. This, ultimately, is a failure of the testing code itself and a failure by the developer to vindicate the test itself before committing code.
However, things like this do happen from time to time, and it would be wonderful if, when a fatal error occurs (regardless of who's ultimately responsible), the test simply be marked as a failure, and the remainder of the test suite still be executed.
I have read about the --process-isolation switch and as far as I can tell, it should take care of this. Since each test runs in a separate process, if the child dies due to a fatal error, the parent can still continue to run. In fact, this is stated explicitly in this answer to a similar question: https://stackoverflow.com/a/5340151/84762 which shows the exact type of output I would like to see myself.
However, I seem to get the exact same output regardless of whether or not I use the --process-isolation flag:
WITHOUT process isolation
[kogi#phagocyte ~]$ /usr/bin/phpunit --colors --verbose --coverage-html "target/coverage" ~/app/zend/tests/application/
PHP Fatal error: Class 'Rmd_Database_OldObject' not found in /home/kogi/app/zend/private/models/translate/Poll.php on line 9
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/pear/PHPUnit/TextUI/Command.php:130
PHP 4. PHPUnit_Runner_BaseTestRunner->getTest() /usr/share/pear/PHPUnit/TextUI/Command.php:150
PHP 5. PHPUnit_Framework_TestSuite->addTestFiles() /usr/share/pear/PHPUnit/Runner/BaseTestRunner.php:96
PHP 6. PHPUnit_Framework_TestSuite->addTestFile() /usr/share/pear/PHPUnit/Framework/TestSuite.php:419
PHP 7. PHPUnit_Util_Fileloader::checkAndLoad() /usr/share/pear/PHPUnit/Framework/TestSuite.php:358
PHP 8. PHPUnit_Util_Fileloader::load() /usr/share/pear/PHPUnit/Util/Fileloader.php:79
PHP 9. include_once() /usr/share/pear/PHPUnit/Util/Fileloader.php:95
PHP 10. require_once() /home/kogi/app/zend/tests/application/translate/PollTest.php:11
Fatal error: Class 'Rmd_Database_OldObject' not found in /home/kogi/app/zend/private/models/translate/Poll.php on line 9
Call Stack:
0.0003 91584 1. {main}() /usr/bin/phpunit:0
0.0076 612672 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
0.0076 613744 3. PHPUnit_TextUI_Command->run() /usr/share/pear/PHPUnit/TextUI/Command.php:130
0.0246 1249464 4. PHPUnit_Runner_BaseTestRunner->getTest() /usr/share/pear/PHPUnit/TextUI/Command.php:150
0.0706 1626680 5. PHPUnit_Framework_TestSuite->addTestFiles() /usr/share/pear/PHPUnit/Runner/BaseTestRunner.php:96
0.1691 8053584 6. PHPUnit_Framework_TestSuite->addTestFile() /usr/share/pear/PHPUnit/Framework/TestSuite.php:419
0.1693 8057320 7. PHPUnit_Util_Fileloader::checkAndLoad() /usr/share/pear/PHPUnit/Framework/TestSuite.php:358
0.1694 8057664 8. PHPUnit_Util_Fileloader::load() /usr/share/pear/PHPUnit/Util/Fileloader.php:79
0.1711 8240600 9. include_once('/home/kogi/app/zend/tests/application/translate/PollTest.php') /usr/share/pear/PHPUnit/Util/Fileloader.php:95
0.1805 9187768 10. require_once('/home/kogi/app/zend/private/models/translate/Poll.php') /home/kogi/app/zend/tests/application/translate/PollTest.php:11
WITH process isolation
[kogi#phagocyte ~]$ /usr/bin/phpunit --colors --verbose --coverage-html "target/coverage" --process-isolation ~/app/zend/tests/application/
PHP Fatal error: Class 'Rmd_Database_OldObject' not found in /home/kogi/app/zend/private/models/translate/Poll.php on line 9
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/pear/PHPUnit/TextUI/Command.php:130
PHP 4. PHPUnit_Runner_BaseTestRunner->getTest() /usr/share/pear/PHPUnit/TextUI/Command.php:150
PHP 5. PHPUnit_Framework_TestSuite->addTestFiles() /usr/share/pear/PHPUnit/Runner/BaseTestRunner.php:96
PHP 6. PHPUnit_Framework_TestSuite->addTestFile() /usr/share/pear/PHPUnit/Framework/TestSuite.php:419
PHP 7. PHPUnit_Util_Fileloader::checkAndLoad() /usr/share/pear/PHPUnit/Framework/TestSuite.php:358
PHP 8. PHPUnit_Util_Fileloader::load() /usr/share/pear/PHPUnit/Util/Fileloader.php:79
PHP 9. include_once() /usr/share/pear/PHPUnit/Util/Fileloader.php:95
PHP 10. require_once() /home/kogi/app/zend/tests/application/translate/PollTest.php:11
Fatal error: Class 'Rmd_Database_OldObject' not found in /home/kogi/app/zend/private/models/translate/Poll.php on line 9
Call Stack:
0.0003 91752 1. {main}() /usr/bin/phpunit:0
0.0076 612824 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
0.0076 613896 3. PHPUnit_TextUI_Command->run() /usr/share/pear/PHPUnit/TextUI/Command.php:130
0.0246 1250360 4. PHPUnit_Runner_BaseTestRunner->getTest() /usr/share/pear/PHPUnit/TextUI/Command.php:150
0.0708 1627528 5. PHPUnit_Framework_TestSuite->addTestFiles() /usr/share/pear/PHPUnit/Runner/BaseTestRunner.php:96
0.1688 8054296 6. PHPUnit_Framework_TestSuite->addTestFile() /usr/share/pear/PHPUnit/Framework/TestSuite.php:419
0.1690 8057992 7. PHPUnit_Util_Fileloader::checkAndLoad() /usr/share/pear/PHPUnit/Framework/TestSuite.php:358
0.1691 8058336 8. PHPUnit_Util_Fileloader::load() /usr/share/pear/PHPUnit/Util/Fileloader.php:79
0.1707 8241296 9. include_once('/home/kogi/app/zend/tests/application/translate/PollTest.php') /usr/share/pear/PHPUnit/Util/Fileloader.php:95
0.1801 9188464 10. require_once('/home/kogi/app/zend/private/models/translate/Poll.php') /home/kogi/app/zend/tests/application/translate/PollTest.php:11
For those of us that can't effectively diff in our heads, the two outputs are literally identical (other than the execution time and memory usage which is negligibly different).
In both cases, the fatal error kills the entire test suite. In this particular case, this happens in the 3rd test and the remaining 150 tests (in several other files/suites) are never executed.
What am I doing wrong here? Is there some other way to survive a fatal error (marking the test as failed) in one test and still execute remaining tests?
EDIT
I am using PHPUnit 3.6.10
EDIT
Comments on the answer to this question have inspired a new ticket on PHPUnit's GitHub page: https://github.com/sebastianbergmann/phpunit/issues/545
PHPUnit loads each test file that will be run before running any tests. This causes PHP to parse these files and execute their top-level code. If any class is loaded that, for example, extends a class that doesn't exist, you'll get a fatal error.
I don't see any way around this without enhancing PHPUnit to parse the files without executing their code during the scanning process.
I am running Zend Framework 1.10 on Ubuntu 10.04, just installed Xdebug to generate code coverage, via PECL.
If I run phpunit like so:
$ phpunit --coverage-html ~/coverage
It works just fine. Unittests run, then code coverage output is generated. No error messages or warnings.
But if I do:
$ phpunit
The tests run fine, but when code coverage begins, I get this:
Generating code coverage report, this may take a moment.PHP Warning: mkdir(): Permission denied in /usr/share/php/PHPUnit/Util/Filesystem.php on line 209
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:52
PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:147
PHP 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:214
PHP 5. PHPUnit_Util_Report::render() /usr/share/php/PHPUnit/TextUI/TestRunner.php:479
PHP 6. PHPUnit_Util_Filesystem::getDirectory() /usr/share/php/PHPUnit/Util/Report.php:87
PHP 7. mkdir() /usr/share/php/PHPUnit/Util/Filesystem.php:209
Warning: mkdir(): Permission denied in /usr/share/php/PHPUnit/Util/Filesystem.php on line 209
Call Stack:
0.0003 322324 1. {main}() /usr/bin/phpunit:0
0.0521 4658252 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:52
0.0521 4658716 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:147
0.5944 12773356 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:214
37.1550 24746768 5. PHPUnit_Util_Report::render() /usr/share/php/PHPUnit/TextUI/TestRunner.php:479
37.1550 24746768 6. PHPUnit_Util_Filesystem::getDirectory() /usr/share/php/PHPUnit/Util/Report.php:87
37.1560 24746984 7. mkdir() /usr/share/php/PHPUnit/Util/Filesystem.php:209
Before I installed Xdebug, running phpunit without any arguments worked just fine.
I presume this is just a silly permissioning problem stemming from my PECL installation of Xdebug, but it looks like everything in /usr/share/php/phpunit is supposed to be permissioned as root, soooooo...any ideas?
The error message just tells you that mkdir can't create a folder somewhere but not where it is trying to do so.
I would assume you have an phpunit.xml.dist in which a <logger> of the type coverage-html is defined with a target that doesn't exist on your machine which your current user doesn't have write access too.
PHPUnit doesn't try to generate a coverage report without somneone telling it do and if you don't do it on the cli a phpunit.xml is the only option left.