Is it necessary for PHP to perform automatic tests like phpunit?

Source: Internet
Author: User
How many people have systematically used Automatic Testing in PHP projects? Are they determined by the project size and complexity? How many people have systematically used Automatic Testing in PHP projects? Are they determined by the project size and complexity?

Reply content:

How many people have systematically used Automatic Testing in PHP projects? Are they determined by the project size and complexity?

I think unit testing is due to the increasing size of software and the increasing requirement on code reliability.
PHP, as a language designed for web page performance, is generally not a project in the past. I think there are two reasons:
1. The disadvantage of PHP Execution speed hinders it from becoming the main backend language.
2. Some features of PHP are not suitable for collaborative development by large teams (the earliest PHP does not support OO, and PHP5.3 has no namespaces before ...)
The project is not big, and PHP's unit testing needs are naturally not urgent.

However, with the development of technology in recent years, the speed of PHP is becoming increasingly difficult (redis, HHVM, PHP7, etc ), from PHP5, we can see that the features of PHP are more and more suitable for the development of large teams (namespace and other concepts ). in addition, with the rise of Saas and other concepts in the IT field, website services become more and more complex.

Therefore, large and even super-large PHP projects have emerged and will certainly be more in the future, so there will be more and more demands for PHP unit testing.

I am at a low level, and the above understanding is inevitable wrong. It's just a family of words, please pat

I think, regardless of the project size, using phpunit for automatic testing is a standard specification.

PHP is good at web development, most of which are simple warehouse receiving and warehouse receiving operations with few business logic. It is recommended that automated acceptance testing be the primary function, supplemented by unit testing. My approach is to combine acceptance testing and unit testing to cover the entire test case. For example, the registration function write acceptance test and the unit test for the username and password verification classes.

I have seen that many tutorials in textbooks will perform unit tests on controllers. This is not bad, but a bit too much.

In short, my experience is: mixed use of acceptance testing and unit testing, which primarily test business classes.

Automated Testing allows you to detect code errors caused by modifications in a timely manner after code modifications, reducing the number of bugs caused by code modifications. I think it is better to choose automated testing based on the above reasons.

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.