I can't test with phpunit: Cannot open file "autoload.php"

composer-php, php, phpunit, wamp

Solution

I am working with PHPUnit 7 and basis on that I have mentioned solution in the below which is tested and working 100%

If you are windows user then type following on cmd: "vendor/bin/phpunit" --bootstrap ./vendor/autoload.php ./tests/EmailTest

Make sure I have updated ./ before vendor and tests.

Problem

Config : - PHPUNIT: 4.5.0 - PHP : 5.4.12 - Server: Wamp - Composer: version 1.0-dev 2015-02-17 21:55:44 composer.json : ``` { "require-dev": { "phpunit/phpunit": "4.5.*" } } ``` autoload.php : ``` <?php date_default_timezone_set("Europe/Paris"); require __DIR__.'/vendor/Symfony/Component/ClassLoader/UniversalClassLoader.php'; use Symfony\Component\ClassLoader\UniversalClassLoader; $loader = new UniversalClassLoader(); $loader->registerNamespaces(array( 'Hangman' => __DIR__.'/src', 'Symfony' => __DIR__.'/vendor', )); $loader->register(); ``` phpunit.xml : ``` <?xml version="1.0" encoding="UTF-8"?> <!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html --> <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="autoload.php" > <testsuites> <testsuite name="hangman"> <directory>tests/Hangman/Tests</directory> </testsuite> </testsuites> <filter> <blacklist> <directory>vendor</directory> </blacklist> </filter> </phpunit> ``` Problem : I executed : `phpunit --bootstrap autoload.php tests` My Error : `Cannot open file "autoload.php"` Can you help me ?

Original source