If you want to produce the perfect product, it must be tested in all aspects. There are several types of tests, each of which is specific to a particular aspect of the application.
This article will introduce the unit test, database test, System test, load test.
One, Unit test
Unit testing is the test of every step of the application, to ensure that its components are functioning properly. Without unit testing, it is generally quite difficult to find the cause of the error to run in your application.
Unit tests typically employ a unit test framework that provides the basic structure needed to write and run tests and output the results.
Some of the more commonly used unit testing frameworks include:
phpunit:http://phpunit.de/
simpletest:http://www.simpletest.org/
phpt:http://qa.php.net/write-test.php
Second, the database test
The PHPUnit database extension mimics the JUnit dbunit extension, which is the de facto Java unit Test framework. The PHPUnit database extension does not process the creation of databases, tables, or user credentials; it runs on the assumption that these have been created.
PHPUnit Database Test Reference: http://phpunit.de/manual/current/en/database.html
Third, System testing
Once the various components of the system and the interaction with the external system have been tested, we are going to test the application as a whole, which becomes a system test.
For Web applications, this is often done by writing automated tests that interact with the browser in the same way that a real user would.
The popular package for writing and executing this test is selenium, a Java-based server that runs a client to connect to it, executes commands to start the browser, and interacts with it. The software is often used to perform a series of actions within a Web application and asserts the contents of the last loaded file to confirm that it achieves the desired functionality.
selenium:http://seleniumhq.org/
The phpunit contains a selenium extension that allows these interactions to execute.
Iv. Load Test
Once the application is working properly, whether it's its constituent parts or as a whole, it's important to understand how the application works as a whole.
A load test simulates the behavior of a group of users to determine how the application behaves under load.
The following two test tools are introduced: AB, siege
1. AB Test Tools
As part of the Apache HTTP Server project, AB is a relatively simple developed benchmark tool and is suitable for most environments where Apache is installed.
It has a number of parameters, and we have a few tweaks to how it guides the test, with 3 parameters that are often used:
1)-C #: The number of concurrent requests per second, or the number of simultaneous users accessing the application.
2)-N #: The request to be sent.
3)-T #: The maximum time that the test lasts in seconds, assuming-n 50000.
So, for example, if you want to simulate the behavior of 10 concurrent users in a minute, you can use the following command:
Ten http://localhost/phpinfo.php
AB Use reference: http://httpd.apache.org/docs/2.0/programs/ab.html
2. Siege Test Tools
Another commonly used load test tool is siege, which is developed by Joe Dog Software. The load test for AB is limited to a specific URL, and siege can load test the entire application in addition to the URL. The Siege manual describes the options that it supports.
siege:http://www.joedog.org/siege-home/
Siege Manual: http://www.joedog.org/siege-manual/