PHPUnit Download website http://www.phpunit.cn/
I. Installation PHPUnit
1. Select version
I'm using a PHP version of 5.6.25 so I chose PHPUnit 5.7.
2. Installation process
Create a directory for the PHP binary executable file, for exampleC:\bin
will be ;C:\bin
appended to the PATH
environment variable " directory of PHP; E:\wamp64\bin\php\php5.6.25 is also attached PATH
to the environment variable "
Download Phpunit.phar and save the file toC:\bin\phpunit.phar
Open cmd command line
Create an outsourced batch processing script (automatically generated in the last Bin directory C:\bin\phpunit.cmd 文件
):
c:\users\username> cd c:\binc:\bin"%~dp0phpunit.phar" %* > Phpunit.cmdc:\bin> Exit
- " Note that the download is generally Phpunitx-y.phar, with the version number, so to remove the version number modified file named Phpunitx.phar"
Open a new CMD command-line window and confirm that you can execute PHPUnit under any path:
C:\bin>phpunit--5.7. by Sebastian Bergmann and contributors.
two. Test with PHPUnit在C:\bin 目录下创建文件StackTest.php
<?PHP Usephpunit\framework\testcase; classStacktestextendsTestCase { Public functionTestpushandpop () {$stack= []; $this->assertequals (0,Count($stack)); Array_push($stack, ' foo '); $this->assertequals (' foo '),$stack[Count($stack)-1]); $this->assertequals (1,Count($stack)); $this->assertequals (' foo '),Array_pop($stack)); $this->assertequals (0,Count($stack)); } } ?>
To testC:\bin>phpunit stacktest.phpphpunit 5.7.19 by Sebastian Bergmann and contributors . 1/1 (100%) time:543 MS, Memory:13.00mbok (1 Test, 5 assertions)
Installation of Wamp PHP Unit Test tool phpunit under Windows