PhpUnit Netbeans Minimalist Configuration

Source: Internet
Author: User
Tags autoload netbeans

0x01. Download two Phar packages:

wget Https://phar.phpunit.de/phpunit.pharwget Https://phar.phpunit.de/phpunit-skelgen.phar

0x02. Make these two packages executable

chmod +x phpunit.pharchmod +x Phpunit-skelgen.phar

0x03. Move (or create a soft connection) into the directory of your environment variable

MV PHPUNIT.PHAR/USR/LOCAL/BIN/PHPUNITMV Phpunit-skelgen.phar/usr/local/bin/phpunit-skelgen

at this point, PHPUnit and the framework for generating the tests have been deployed. It's simple!

0x04. Netbeans Global Configuration

Menu--tools [tools]-options [options]-PHP--Frameworks & Tools Select the PHPUnit on the left, set [PHPUnit Script] and [Skelet On Generator Script] If you are in your PATH environment variable, click [Search] to go, if not, fill in the path yourself. In this example, the two paths are:  /usr/local/bin/phpunit   /usr/local/bin/phpunit-skelgen Click OK, exit configuration

0x05. NetBeans project configuration

On the project name, right-click Property [Properties]--test [testing] to add test catalog. Expand left side test [testing] tree, click [PHPUnit] tick [use Bootstrap], then select Launch Script or click [Generate] to automatically generate one. Tick [use Bootstrap for Creating New Unit Tests]
If you do not tick [use Bootstrap for Creating New Unit Tests], when you generate a class that inherits or implements an interface, you are prompted
Final error:interface ... not found in ... Final Error:class ... not found in ...
0x06. Modifying bootstrap.php

Automatically generated bootstrap.php may not meet their actual requirements, modify it, it is generally the role of automatic loading class library. For example, if you use some framework to load your own classes, then include the framework's autoload.php file and include your own autoload.php. Like what:

<?php/* * to the license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. *//** * @author *///todo:check include Path//ini_set (' include_path ', Ini_get (' include_path '));//Put Your code Hererequi Re __dir__. ‘.. /.. /.. /my/autoload.php ';
0x07. How to use
In the Code window, select the file you want to test, menu--tools [tools]--build test [create Tests] or in the Project window, select the file you want to test, right--tools [tools]--Generate test [create Tests]

0x08. How to use the command line

Phpunit-skelgen

"/usr/bin/php" "/usr/local/bin/phpunit-skelgen" "--ansi" "Generate-test" "--bootstrap=/path/to/bootstrap.php" " Namespace\myclass ""/path/to/namespace/myclass.php "" Namespace\myclasstest ""/path/to/namespace/myclasstest.php "

PHPUnit

"/usr/bin/php" "/usr/local/bin/phpunit" "--colors" "--log-junit" "/tmp/nb-phpunit-log.xml" "--bootstrap" "/path/to/ bootstrap.php ""/path/to/netbeans-8.0/php/phpunit/netbeanssuite.php ""--run=/path/to/test/namespace/ Myclasstest.php "

PhpUnit Netbeans Minimalist Configuration

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.