Home  >  Article  >  Backend Development  >  What is the use of php unit testing?

What is the use of php unit testing?

(*-*)浩
(*-*)浩Original
2019-10-09 13:15:483689browse

php unit testing is a good idea. It provides an automated testing method and makes automated testing possible in agile development.

What is the use of php unit testing?

#php is different from other languages. Unit testing needs to be installed and configured by yourself, which is relatively troublesome. However, unit testing can improve the stability and robustness of the library. It’s still very powerful. Let’s teach you how to configure PHP unit testing (recommended learning: PHP video tutorial)

Note: PHP needs to be upgraded to version 7.1 or above

Configuration instructions

Global installation of phpunit command script

$ wget https://phar.phpunit.de/phpunit-7.0.phar
$ chmod +x phpunit-7.0.phar
$ sudo mv phpunit-7.0.phar /usr/local/bin/phpunit
$ phpunit --version
PHPUnit x.y.z by Sebastian Bergmann and contributors.

Global installation of phpunit code

composer global require phpunit/phpunit

Create phpunit.xml and place it in the root directory of your project. This file is a configuration file that phpunit will read by default:


    
        
            tests
        
    

Configure the phpstorm unit phpunit.phar path, Languages ​​& Frameworks > PHP > PHPUinit

For example, the local path of my phpunit is /usr/local/bin/phpunit

What is the use of php unit testing?Configure the unit test class Tip, Languages ​​& Frameworks > PHP > include path

For example, the local path of my phpunit package is /Users/chenqionghe/.composer/vendor/phpunit

What is the use of php unit testing?

The above is the detailed content of What is the use of php unit testing?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn