{
    "require-dev": {
        "phpunit/phpunit": "4.5.*"
    }
}
<?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();
<?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>
I executed : phpunit --bootstrap autoload.php tests
My Error : Cannot open file "autoload.php"
Can you help me ?
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.
You could give bootstrap="vendor/autoload.php" a try in your phpunit.xml. Then PHPUnit and your Tests would use the Composer Autoloader.
Or you could require the Composer Autoloader (in addition to Symfony's UCL) in your autoload.php by adding require 'vendor/autoload.php';. This results in two autoloaders being registered. 
Then run:
composer update - to fetch dependencies and rebuild the autoloading filesphpunit - to execute a test runYou don't need to run phpunit with --bootstrap, because the directive is already set in your phpunit.xml.
I think your folder layout is not right. You start with this:
c:\wamp\www\yourproject
  \src
  \tests
    \- phpunit.xml.dist
  \vendor
  \composer.json
phpunit to the require-dev section of your composer.json"bin-dir" : "bin", so that phpunit.bat lives in c:\wamp\www\yourproject\bin\phpunit.bat and not in c:\wamp\www\yourproject\vendor\bin\phpunit.bat
composer install or updatec:\wamp\www\yourproject\bin\phpunit.bat -c c:\wamp\www\yourproject\tests\phpunit.xml.dist
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With