参考连接: http://blog.coinidea.com/web%E5%BC%80%E5%8F%91/php-1088.htmlphp
1. 网上不少人推荐使用pear的安装方式,尝试了不少博客中的方法,均已失败。 2. 我成功的方法是比较原生:html
下载地址:web
https://phpunit.de/index.htmlshell
下载下来的是.phar的PHP扩展。根据本身的PHP版本下载对应的PHPUnit版本windows
根据https://phpunit.de/manual/current/en/installation.html#installation.phar.windows循序渐进便可。app
1. 下载PHPUnit.phar到某个文件夹好比:C:\bin
2. 将这个文件夹C:\bin\到环境变量Path中 3. 在命令行中,当前路径移动到C:\bin,并在命令行下输入 4. echo @php “%~dpophpunit.phar”%*>phpunit.cmdide
在任意位置的命令行中输入:wordpress
phpunit --version
可以看见测试
至此,PHPUnit安装成功。ui
SayHello.php
<?php class SayHello { public function printHello() { echo 'Hello'; return 'Hello'; } } ?>
TestSayHello.php
<?php require_once 'SayHello.php'; class TestSayHello extends PHPUnit_Framework_TestCase { public function setUp(){ } public function tearDown(){ } public function testConnectionIsValid() { $hi = new SayHello(); $this->assertTrue($hi->printHello() == 'Hello'); } }
参考连接: http://blog.coinidea.com/web%E5%BC%80%E5%8F%91/php-1088.html