Disclosure of Invention
In view of the foregoing problems, an object of the present invention is to provide an automated testing method, a testing server and a system for a mobile browser, so as to shorten testing time and improve testing efficiency.
According to one aspect of the invention, an automated testing method for a mobile browser is provided, which comprises the following steps:
counting the number of all pages to be tested and the number of mobile terminals connected with the test server, wherein the number of the mobile terminals is at least two or more;
selecting at least two mobile terminals from the mobile terminals connected with the test server according to the counted number of the mobile terminals, starting a test process of the selected mobile terminals, and then respectively sending pages to be tested to the selected mobile terminals for automatic test;
and respectively receiving and storing the test results of the corresponding mobile terminals.
Wherein, the test server comprises a main server and a sub-server, wherein,
connecting with a main server through at least one sub server;
counting all pages to be tested through the main server, and distributing the counted pages to be tested to the sub-servers;
and counting the number of the mobile terminals connected with the sub server through the sub server, then acquiring the distributed page to be tested from the main server, and sending the page to the mobile terminals.
In addition, the present invention provides a test server for a mobile browser, comprising:
the statistical unit is used for counting all pages to be tested and counting the number of the mobile terminals connected with the test server, wherein the number of the mobile terminals is at least two or more;
the test processing unit is used for selecting at least two mobile terminals from the mobile terminals connected with the test server according to the number of the mobile terminals counted by the counting unit, starting the test process of the selected mobile terminals, and then respectively sending pages to be tested to the selected mobile terminals for automatic test;
and the result processing unit is used for storing the test results after respectively receiving the test results of the corresponding mobile terminals.
In another aspect, the present invention provides an automated testing system for a mobile browser, including the aforementioned testing server and mobile terminals, wherein at least two mobile terminals are connected to the testing server to complete an automated test.
Wherein, mobile terminal includes:
the page to be tested acquiring unit is used for acquiring a page to be tested pushed by the test server;
the test unit is used for reading the information of the page to be tested and testing the page;
and the test result sending unit is used for sending the test result to the test server.
By using the automatic testing method, the testing server and the system of the mobile browser, the testing cases are tested in parallel by performing distributed deployment on the mobile terminal or performing distributed deployment on the testing server and the mobile terminal respectively, so that the time for completely running the testing cases once can be shortened, the testing time is shortened and the testing efficiency is improved on the basis of ensuring the quality of codes submitted each time.
To the accomplishment of the foregoing and related ends, one or more aspects of the invention comprise the features hereinafter fully described and particularly pointed out in the claims. The following description and the annexed drawings set forth in detail certain illustrative aspects of the invention. These aspects are indicative, however, of but a few of the various ways in which the principles of the invention may be employed. Further, the present invention is intended to include all such aspects and their equivalents.
Detailed Description
Specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
The method aims at the problems that when the existing mobile terminal browser is used for automatic testing, only a single-process running test case can be used, the time for completely running a test case once is too long, and the testing efficiency is low. According to the invention, distributed deployment is carried out on the mobile terminal, or distributed deployment is carried out on the test server and the mobile terminal respectively, the test server starts the test process of the mobile terminal according to the number of the mobile terminals connected with the test server, and the test cases to be tested are tested respectively through a plurality of test processes, so that the test of the whole test case is completed in a short time, the test time is greatly shortened on the basis of ensuring the quality of codes submitted when a mobile terminal browser is developed, and the test efficiency is improved.
It should be noted that, the mobile terminal mentioned in the present invention may refer to a mobile terminal device such as a mobile phone, an IPAD, etc., but is not limited thereto.
In order to illustrate the method for automatically testing the mobile browser provided by the present invention, fig. 2 shows a flow of the method for automatically testing the mobile browser according to the embodiment of the present invention.
As shown in fig. 2, from the perspective of the test server, the automated test method for a mobile browser provided by the present invention includes:
s210: the test server counts the number of all the pages to be tested and the number of the mobile terminals connected with the test server, wherein the number of the mobile terminals is at least two or more.
And counting the number of all pages to be tested and the number of the mobile terminals connected with the test server through the main process of the test server.
Specifically, the main process of the test server collects all pages to be tested connected with the main process, forms a list of pages to be tested, and counts the mobile terminals connected with the main process.
S220: and selecting at least two mobile terminals from the mobile terminals connected with the test server according to the counted number of the mobile terminals, starting a test process of the selected mobile terminals, and then respectively sending pages to be tested to the selected mobile terminals for automatic test.
In addition, after the number of the mobile terminals connected with the test server is counted by the main process of the test server, the mobile terminals with the same number are informed to start the test processes in the mobile terminals according to the counted number, and the test cases are tested in parallel by using a plurality of test processes, so that the test time is saved.
In an example of the present invention, it is assumed that 5 mobile phones are connected to the test server, and at this time, the test server may start the test processes of 4 mobile phones for performing an automated test, or may start the test processes of 5 mobile phones for performing an automated test.
S230: and respectively receiving and storing the test results of the corresponding mobile terminals. That is, after receiving the test result of the mobile terminal in the test process of testing the page to be tested, the test server stores the test result.
In the process of carrying out automatic testing on the mobile terminal, firstly, a testing process of the mobile terminal acquires a page to be tested pushed by a testing server; then the mobile terminal reads the information of the page to be tested and tests the page; and after the mobile terminal completes the test of the page to be tested, the mobile terminal sends the test result to the test server.
Specifically, after receiving the test result sent by the mobile terminal, the test server stores the test result to the test server.
As can be seen from the flow shown in fig. 2, according to the automated testing method for the mobile browser provided by the present invention, by setting the distributed mobile terminals, the test server can perform parallel tests on the test cases by starting the test processes in the mobile terminals, so that the time for completely running a test case once can be shortened, and the testing efficiency is greatly improved on the basis of ensuring the quality of the code submitted each time.
It should be noted that, the above is exemplified by setting a plurality of distributed mobile terminals, and the present invention may further set a distributed test server on the basis of the above. When there are multiple mobile terminals and one test server, then the test efficiency may be limited to a single test server, which is mainly embodied in two aspects: the method comprises the steps that firstly, the connection number and the process number of the maximum mobile terminal supported by a test server are measured; and secondly, the processing capacity of a single test process of the mobile terminal. Therefore, based on the above two aspects, in one example of the present invention, the test server is configured as a distributed server, and can be divided into a main server and a plurality of sub servers, wherein at least one sub server is connected with the main server. The main server is used for distributing the pages to be tested of all the test cases to the sub-servers, and the main process of the sub-servers informs the test process of the mobile terminal when to start testing and the content of the testing, and receives the test result to judge whether the testing is passed or not.
Specifically, all pages to be tested are counted by the main server, and the counted pages to be tested are distributed to the sub-servers; and counting the number of the mobile terminals connected with the sub server through the sub server, then acquiring the distributed page to be tested from the main server, sending the page to be tested to the mobile terminal connected with the sub server, and informing the mobile terminal of starting a test process in the mobile terminal.
Specifically, a plurality of sub-servers are connected with the main server, and each sub-server is respectively connected with the mobile terminal as a test server, so that the number of the mobile terminals connected with the test server can be greatly increased, the number of test processes started by the test server can be greatly increased on the basis of the original mobile terminal distributed scheme, the test time is further shortened, and the test efficiency is improved.
In addition, it should be noted that the automated testing method for the mobile browser provided by the present invention also supports dynamic extension, that is, the mobile terminal can be added to the test at any time, and can also quit the test at any time.
Specifically, when a new mobile terminal is connected with the test server (i.e. the new mobile terminal is added to the test), the test server starts the test process of the new mobile terminal and sends a page to be tested to the new mobile terminal; when the mobile terminal is disconnected from the test server (i.e. the mobile terminal quits the test), the test server receives a disconnection message sent by the test process of the mobile terminal, and retrieves the test of the corresponding page to be tested, namely the page to be tested is placed back into the page list to be tested.
In order to describe the method for automatically testing the mobile browser in more detail, fig. 3, fig. 4, fig. 5, and fig. 6 respectively illustrate the automatic testing process provided by the present invention in more detail by way of example. Fig. 3 shows a process flow of a main process of a test server according to an embodiment of the present invention. As shown in fig. 3:
s310: the main process of the test server counts url of the page to be tested and counts the number of the mobile terminals connected to the test server;
s320: the main process of the test server informs the mobile terminal to start a test process and sends a page to be tested to the mobile terminal;
s330: waiting for a test process of the mobile terminal to return a message;
s340: judging whether a new access message of the mobile terminal exists, if so, entering a step S350, otherwise, entering a step S360;
s350: the main process of the test server starts a new test process of the mobile terminal, and then returns to S330;
s360: judging whether a message for completing the test of the test process exists, if so, entering the step S370, otherwise, returning to the step S330;
whether the test is finished or not is judged in two modes, one mode is to know when the test is finished from the webpage, and the other mode is to consider that the test is finished after the browser finishes webpage loading, analyzing and rendering.
S370: judging whether the test is completed completely, if so, entering the step S380, otherwise, returning to the step S330;
s380: and the test server informs the mobile terminal to stop and destroy the test process, generates a test result report and finishes the test.
It should be noted that, in this embodiment, 1 test server and a plurality of mobile terminals are used as an example, and the same is true if the test servers are divided into a main server and a sub server, except that the main server divides all pages to be tested into the sub servers, and then the sub servers notify the mobile terminals to start a test process and distribute the pages to be tested to the mobile terminals.
Fig. 4 shows a process flow of a test procedure initiated at a mobile terminal according to an embodiment of the invention. As shown in fig. 4:
s410: after a test process of the mobile terminal is started, acquiring a url of a page to be tested from a main process of a test server;
s420: the test process informs the mobile terminal of the automatic test software;
s430: setting timeout time and waiting for messages;
s440: judging whether an automatic test result of the mobile terminal exists or not, if so, entering a step S450, otherwise, entering a step S460;
s450: sending the test result of the mobile terminal to a test server for storage, and completing the test;
s460: judging whether the time is overtime, if yes, entering step S470, otherwise, returning to step S430;
s470: judging whether the mobile terminal automation test software crashes, if so, entering S480, otherwise, entering S490;
s480: sending the crash result of the mobile terminal automation test software to a test server for storage, and completing the test;
s490: and sending the overtime result to a test server for storage, and finishing the test.
Fig. 5 shows a process flow of the test server when the mobile terminal is disconnected from the test server according to an embodiment of the present invention. As shown in fig. 5:
s510: when a test process started by the mobile terminal scans that the mobile terminal is disconnected with the test server, transmitting the url of the page to be tested to the test server by using a message;
s520: after receiving the disconnection message of the test process, the test server puts the url of the page to be tested back into the page list to be tested;
s530: the test server stops and shuts down the processes it initiates that relate to the test.
Fig. 6 shows a process flow of a mobile terminal according to an embodiment of the present invention. As shown in fig. 6:
s610: a test process of the mobile terminal waits for the url of the page to be tested pushed by the test server;
s620: the mobile terminal acquires the url of the page to be tested from the test server;
s630: the mobile terminal reads the webpage according to the url of the webpage to be detected, analyzes and executes js;
s640: and the mobile terminal sends the test operation result to the test server.
According to the example, the total time for completely running a test case once can be shortened by using the automatic test method provided by the invention, and the test efficiency is improved.
Specifically, in order to illustrate the effect of the automated testing method provided by the present invention, in one example of the present invention, if the automated testing method provided by the present invention is not used, the total time for running all the automated testing cases is ten or more hours; in another embodiment of the present invention, the total time for running all the automated test cases is shortened to less than ten minutes by using the automated test method provided by the present invention, so the test time is greatly shortened, and the efficiency is greatly improved.
Corresponding to the method, the invention further provides an automated testing system of the mobile browser, and fig. 7 shows a logical structure of the automated testing system of the mobile browser according to the embodiment of the invention.
As shown in fig. 7, the automated testing system 700 for mobile browsers provided by the present invention includes a test server 710 and a mobile terminal 720. Wherein, at least two mobile terminals 720 are connected with the test server 710 to complete the automatic test.
Specifically, the test server 710 provided by the present invention includes a statistics unit 711, a test processing unit 712, and a result processing unit 713.
The statistical unit 711 is configured to count all pages to be tested and the number of mobile terminals connected to the test server, where the number of the mobile terminals is at least two or more; the test processing unit 712 is configured to select at least two mobile terminals from the mobile terminals connected to the statistical unit 711 according to the number of the mobile terminals counted by the statistical unit 711, start a test process of the selected mobile terminals, and then send pages to be tested to the selected mobile terminals respectively for automated testing; the result processing unit 713 is configured to store the test results after receiving the test results of the corresponding mobile terminals respectively.
The test server further comprises a main server and a sub server, wherein the main server is used for counting all pages to be tested and then distributing the counted pages to be tested to the sub servers; the sub-server is used for counting the number of the mobile terminals connected with the sub-server, then acquiring the distributed page to be tested from the main server and sending the page to the mobile terminals; wherein, at least one sub-server is connected with the main server.
In addition, the mobile terminal 720 provided by the present invention includes a page under test acquiring unit 721, a testing unit 722 and a test result sending unit 723.
The page to be tested acquiring unit 721 is configured to acquire a page to be tested pushed by the test server; the test unit 722 is used for reading the information of the page to be tested and testing the page; the test result sending unit 723 is configured to send the test result to the test server.
By the automatic testing method, the testing server and the system of the mobile browser, distributed deployment is carried out on the mobile terminal, or distributed deployment is carried out on the testing server side and the mobile terminal respectively, the testing server starts a plurality of testing processes to carry out parallel testing on the testing cases, so that the testing of the whole testing case is completed in a short time, and the efficiency of the whole testing is improved on the basis that the quality of codes submitted each time when the mobile terminal browser is developed is guaranteed.
The automated testing method, the testing server and the system of the mobile browser according to the present invention are described above by way of example with reference to the accompanying drawings. However, it should be understood by those skilled in the art that various modifications can be made to the method, the server and the system for automatically testing the mobile browser provided by the present invention without departing from the scope of the present invention. Therefore, the scope of the present invention should be determined by the contents of the appended claims.