The use of PHPUnit and Xdebug

Source: Internet
Author: User
Tags pear

Basic Description:

1.xdebug is a bug debug exposure tool used by program apes in the course of debugging programs

Install under Windows:

1) download PHP corresponding DLL file: https://xdebug.org/download.php

2) in the php.ini file to do the corresponding Xdebug configuration, only need to add the following code at the end

[Xdebug]zend_extension="c:/xampp/php/ext/php_xdebug.dll"

3) because I am an integrated environment XAMPP one-click installation, do not need to download DLL files, within XAMPP already exist, just add the corresponding configuration at the end of the PHP configuration file, Please do not have an additional extention, if you download DLL files, Note Download the file that matches the PHP version and the thread; zend_extension this name will also change with the PHP version, if you encounter the corresponding problem, there are many corresponding instructions on the network.

2.phpunit is the Tester Unit Test tool, the programmer's development code to each class to each method of "assertion", often the programmer in the development process will also write the corresponding test case code, facilitate the test of late code changes.

  1) in the integrated environment XAMPP, my installation is Pear command line installation:

Install Phpunit/phpunit

After installation, you will see the Pear.bat file in the root directory of PHP

  After installation, it is best to set PHPUnit as the environment variable, so that it can be used globally, phpunit environment variables corresponding to the directory is the Pear.bat file is located in the directory  

2) After installation I create a test file with the following code:

<? PHP // This is my first Test class extends phpunit_framework_testcase{  publicfunction  testfirst () {  $stack = 7    ;   $this->assertequals (0,$stack); }}

3) After creating the unit test file, let's go to the command line to execute it, the following is the command line display:

C:\users\v_lihuan1>PHPUnit F:\www\testCase.phpPHPUnit3.7. +by Sebastian Bergmann.ftime:0Seconds, Memory:2. 00MbThere was1failure:1) myfirsttest::testfirstfailed asserting that7Matches expected0. F:\www\testCase.php:6Failures!Tests:1, assertions:1, Failures:1.

Now phpunit can be used, as for the assertion of the content and code, we just need to see the corresponding PHPUnit method document can be

3.pdepend is a tool for static code analysis in PHP. It can be used to check the size and complexity of your code in your PHP project. I am also the first installation, if there is something wrong, please advise us

Execute command line: Pear Install Pdepend/php_depend-beta, the following issues occur

F:\www\xdebug>pearInstallpdepend/php_depend-betadid not download optional dependencies:pecl/imagick, use--alldeps to download Automaticallypdepend/php_depend can optionally use package"Pecl/imagick"(Version >=2.2. 0b2) Downloading Php_depend-1.1.4. tgz. Starting to download Php_depend-1.1.4. tgz (179,584bytes) ... ...... ....... Done:179,584byteserror:failed tomkdirC:\php\pear\docs\php_dependf:\www\xdebug>

As described in the article is missing the corresponding dependent Pecl/imagick, you need to install the plug-in first. I found pear. There are commands that can be executed all at once, as follows:

F:\www\xdebug>pearInstall--alldeps pdepend/php_depend-betadownloading php_depend-1.1.4. tgz. Starting to download Php_depend-1.1.4. tgz (179,584bytes) ....... ...................... Done:179,584bytesdownloading Imagick-3.4.3. tgz. Starting to download Imagick-3.4.3. tgz (245,410bytes) ... Done:239,218bytesInstallOk:channel://pear.pdepend.org/php_depend-1.1.4Error:unable to unpack c:\users\v_lihu~1\appdata\local\temp\pear\download\imagick-3.4.3. Tgzf:\www\xdebug>

As shown above: Pecl/imagick decompression failed, according to understanding, that is, the installation is not successful??

"To be continued .... 】

The following issues were encountered during use:

Prerequisites Note:

1.phpunit is set in the environment variable so that it can be used globally

2.phpunit-version View PHPUnit version

3.phpunit can execute all test cases within a folder and generate report files, which makes it easier for us to manage the global code

F:\www\xdebug>phpunit--coverage-html/3.7.  +  53. 25MbOK (11in doneF : \www\xdebug>
/ test1  is the location of the generated report file,test.php is the test case to be executed, and we can also set it as a folder, then all the test cases under the folder will be executed

The use of PHPUnit and Xdebug

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.