我刚刚安装了一个新的Laravel 5项目,这是我在这个版本上的第一个项目。 PHPUnit应该是开箱即用的框架和我看到的每个教程只是说在项目文件夹中键入phpunit
以启动单元测试。
我检查了PHPUnit是在composer.json
,我也做了一个composer install
和composer update
以防万一它不会在这里
website(master)$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Removing phpunit/phpunit (4.6.1)
- Installing phpunit/phpunit (4.6.2)
Downloading: 100%
但它只是不起作用phpunit
根本不被承认
website(master)$ phpunit
-bash: phpunit: command not found
似乎没有人在谷歌搜索之前就遇到过这个问题。我希望我没有犯任何愚蠢的错误。有什么想法或建议吗?多谢你们 ;)
我没有全局安装PHPUnit,也没有定义路径。对于任何有同样问题的人:
composer global require phpunit/phpunit
composer global require phpunit/dbunit
然后你把它添加到你~/.bash_profile
或~/.profile
export PATH=~/.composer/vendor/bin:$PATH
当您没有全局安装phpunit时会发生这种情况。
运行此命令以使用本地版本(与composer一起安装):
vendor/bin/phpunit
您可以在运行cmd
命令之前在phpunit
中运行此命令:
doskey phpunit="vendor/bin/phpunit"
如果你像我一样懒惰,你可以运行这个:
doskey pu="vendor/bin/phpunit"
在composer.json中包含此行
"phpunit/phpunit": "4.0.*",
运行composer update。您应该能够在Laravel目录上运行以下命令。
vendor/bin/phpunit