From PHP's automated testing

Source: Internet
Author: User
PHP's testing environment is implemented using PHP, which has to be considered an innovation. Compared with compiled languages, PHP, as a dynamic language, has many advantages in coping with changes, and testing is a very different place. In fact, the use of PHP is only the framework of the controller, that is, the source code under the root directory of the run-tests.php file. As a controller, it controls the entire test process

From PHP's automated testing

Yesterday, I read the PHP automatic test implementation code for the TIPI project. Here, I have some feelings and the record is as follows.

1. test yourself and develop testing process specifications.
PHP's testing environment is implemented using PHP, which has to be considered an innovation. Compared with compiled languages, PHP, as a dynamic language, has many advantages in coping with changes, and testing is a very different place. In fact, the use of PHP is only the framework of the controller, that is, the source code under the root directory of the run-tests.php file. As a controller, it controls the entire test process. Taking a test process as an example, there are three parts in total: preparation, running, and display results. The preparation activities include reading and setting environment variables required for testing, parsing test parameters, parsing test script names, and parsing various paragraphs in the test script for various output files; the running activities include constructing test statements, executing test statements, and obtaining actual running results. The displayed result activities include comparison and output of test results, related records, and display of the overall test report.

This controller is the specification for PHP automatic testing. all logic is in this script file, and it is a constant process at a time point. Changes in the test, such as the test environment, test input data, content to be verified, and expected results for different inputs and test points are stored in the PHPT file, use different tags as segments for separation. These files are divided by modules. a use case is a file. compared with writing a use case into code, it not only has advantages in workload, but also in scalability, readability, and maintainability.

2. simple monitoring framework

First, confirm the requirements of our monitoring framework. Now we want to monitor whether the data is normal, whether the data status conforms to the business logic, and send the monitoring results to the relevant persons in charge. Starting from this simple requirement, we can find that what changes here is the monitoring content, but what remains unchanged is the entire monitoring process: querying specific data sources, confirm data correctness and rationality based on specific services, and send the results to relevant owners.

For constant factors, we can implement them in the code in the form of public modules. if there are different types and permission controls in the form of reporting results, we can put these configurations into the database, of course, we still need to implement these reporting methods in the code.

For the changing factors, we can learn the PHP testing process and define one-by-one monitoring based on certain rules. we can call it a monitoring case. Define the name, input, process, and expected results in the use case. For example, we can define-SQL-field as the data source. Of course, these contents can be stored separately or centrally in the database.

This monitoring process can be tested.

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.