Disclosure of Invention
In view of the above, there is a need to provide a testing method, an apparatus, a computer device and a storage medium, which can effectively shorten the testing time and reduce the human resource consumption.
In a first aspect, a method of testing, the method comprising:
acquiring test information; the test information is information required when test operation on the test webpage is executed;
generating a test case of the test webpage according to the test information according to a preset webpage dynamic html generation rule;
testing the test webpage by using the test case to obtain a test result;
and generating a test report according to the test result.
In one embodiment, generating a test case of a test webpage according to test information according to a preset webpage dynamic html generation rule includes:
acquiring a to-be-tested item corresponding to a test webpage from a background server through a selenium test interface according to the test information;
and generating a test case of the test webpage according to the item to be tested according to the webpage dynamic html generation rule.
In one embodiment, after generating the test case of the test webpage according to the test information, the method further includes:
and storing the test case in a preset test case file.
In one embodiment, the testing the test webpage by using the test case to obtain the test result includes:
reading a test case in the test case file;
using the test case to perform test operation on each item to be tested in the test webpage to obtain a test result; the test operation includes at least one of adding a test, deleting a test, modifying a test, and checking a test.
In one embodiment, the item to be tested includes at least one of a directory structure of the test web page, a parameter ID of the test web page, and a prompt value range of the test web page.
In one embodiment, generating a test report according to the test result includes:
marking each test result according to the test attribute of each test result;
and generating a test report according to the marked test results.
In one embodiment, the test attributes include: general, abnormal, and severe.
In a second aspect, a test apparatus, the apparatus comprising:
the acquisition module is used for acquiring test information; the test information is information required when test operation on the test webpage is executed;
the case generation module is used for generating a test case of the test webpage according to the test information according to a preset webpage dynamic html generation rule;
the test module is used for testing the test webpage by using the test case to obtain a test result;
and the report generation module is used for generating a test report according to the test result.
In a third aspect, a computer device comprises a memory and a processor, the memory stores a computer program, and the processor implements the testing method according to any one of the embodiments of the first aspect when executing the computer program.
In a fourth aspect, a computer-readable storage medium has stored thereon a computer program which, when executed by a processor, implements the testing method of any of the embodiments of the first aspect.
According to the testing method, the testing device, the computer equipment and the storage medium, the testing information is obtained, the testing case of the testing webpage is generated according to the testing information according to the preset webpage dynamic html generation rule, then the testing case is used for testing the item to be tested, the testing result is obtained, and the testing report is generated according to the testing result. In the test method, the terminal automatically generates the test case of the test webpage by using the webpage dynamic html generation rule, and then automatically tests the items to be tested in the test webpage by using the test case.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The testing method provided by the application can be applied to a testing system shown in fig. 1, wherein the system comprises a terminal and a background server, and the terminal is connected with the background server through a network. The terminal is used for testing Web products or Web projects in the communication equipment or the communication system, and the background server is used for providing data resources for the terminal when testing the Web products or the Web projects. The terminal can be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers and the like, and the server can be implemented by an independent server or a server cluster formed by a plurality of servers.
The following describes in detail the technical solutions of the present application and how the technical solutions of the present application solve the above technical problems by embodiments and with reference to the drawings. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments.
Fig. 2 is a flowchart of a testing method according to an embodiment, where an execution subject of the method is the terminal in fig. 1, and the method relates to a specific process of the terminal testing a test item on a test web page. As shown in fig. 2, the method specifically includes the following steps:
s101, obtaining test information; the test information is information required for executing test operation on the test webpage.
The test information is verification information which needs to be logged in when the terminal performs test operation on a Web page to be tested on certain communication equipment or a communication system, so that the terminal can acquire the authority of testing the Web page to be tested, and the test information specifically includes a URL of the test Web page, a user name of the test Web page and a password of the test Web page, wherein the URL of the test Web page, the user name of the test Web page and the password of the test Web page can be defined by developers or testers in advance according to actual design requirements.
In this embodiment, when the terminal needs to start testing the test web page, the user may input the test information on the terminal in various ways. For example, the user may directly input the test information in the information input window on the terminal, or alternatively, the user may also pre-configure the test information and store the test information in a corresponding configuration file, and the terminal may directly call the test information when the terminal needs to start testing the test web page. The embodiment is not limited to the way in which the user inputs the test information. After the user inputs the test information on the terminal, the terminal can immediately acquire the test information input by the user, so that the terminal can execute operations of logging in a corresponding test program, accessing a corresponding test webpage to be tested and the like according to the test information.
And S102, generating a test case of the test webpage according to the test information according to a preset webpage dynamic html generation rule.
The webpage dynamic html generation rule is a generation method for generating html webpages, and is an existing mature webpage generation method. In this embodiment, after the terminal acquires the test information input by the user based on the step of S101, the terminal may further acquire all relevant information of the test web page to be tested according to the test information, for example, a parameter ID, a directory structure, an information input box value range, a drop-down box option, and the like on the test web page. Then, the terminal can dynamically generate a test case when the test webpage needs to be tested according to all the acquired related information and a method indicated by a preset webpage dynamic html generation rule, so as to be used later.
S103, testing the test webpage by using the test case to obtain a test result.
When the terminal generates a test case for testing the test webpage based on the step of S102, the test case can be automatically used to simulate the click test method of the user, and perform a test on related items or parameters on the test webpage, so as to obtain the test result of the test webpage.
And S104, generating a test report according to the test result.
When the terminal tests the test web page based on the step of S103 to obtain a test result, the terminal may further perform data processing on the test result again, for example, add labels, statistical data, and the like. Then, the terminal can generate a test report according to the processed test result and a preset report format, so that a tester or a developer can effectively position, investigate and solve the problems on the test webpage according to the test report.
According to the testing method provided by the embodiment, the testing information is acquired, the testing case of the testing webpage is generated according to the testing information according to the preset webpage dynamic html generation rule, then the testing case is used for testing the item to be tested, the testing result is obtained, and the testing report is generated according to the testing result. In the test method, the terminal automatically generates the test case of the test webpage by using the webpage dynamic html generation rule, and then automatically tests the items to be tested in the test webpage by using the test case.
Fig. 3 is a flowchart of another implementation manner of S102 in the embodiment of fig. 2, and as shown in fig. 3, the step S102 "generating a test case of a test web page according to a preset web page dynamic html generation rule and test information" includes:
s201, acquiring a to-be-tested item corresponding to the test webpage from the background server through a selenium test interface according to the test information.
The background server is used for storing all items to be tested, or parameters, or other content information related to the testing webpage, and the background server and the terminal can be connected through a network. In this embodiment, when the terminal acquires the test information, the terminal may log in and start a corresponding test program, and acquire the to-be-tested items corresponding to the test web page from the background server according to the address indicated by the test information through a corresponding test interface on the test program, so that the terminal may generate a test case according to the to-be-tested items. It should be noted that, when a developer develops a test program in an early stage, the development may be specifically performed based on a selenium data packet, and therefore, in this embodiment, the terminal may specifically obtain relevant information of some test webpages on the background server through a selenium test interface.
Optionally, the item to be tested may specifically include at least one of a directory structure of the test web page, a parameter ID of the test web page, and a prompt value range of the test web page. It should be noted that, the limitation of the item to be tested in this embodiment is only an example, and in practical applications, the item to be tested may also include information on other types of test webpages. This embodiment is not limited thereto.
S202, generating a test case of the test webpage according to the to-be-tested item according to the webpage dynamic html generation rule.
In this embodiment, when the terminal obtains the item to be tested from the background server, the test case when the test webpage needs to be tested can be dynamically generated according to the webpage dynamic html generation rule, so as to be used later. It should be noted that, because the test is implemented by using the selenium technology, when the terminal generates a test case, a detailed test case related to Xpath corresponding to the selenium technology is generated. Since the selenium technology is widely applied, the test method provided by the application adopts the test program developed by the selenium development kit in the early stage, so that the applicability of the test method applied to the test program of the selenium is strong.
In the embodiment, the test of the test webpage is realized without manually compiling the test case, but the terminal automatically generates the test case to realize the test of the test webpage, so that the time for manually positioning and correcting all parameters on the test webpage when compiling the test case is greatly saved, and meanwhile, the consumption of human resources is reduced.
In practical applications, after the terminal performs the above S102, the terminal may further perform the following steps: and storing the test case in a preset test case file.
In the embodiment, the test case file is used for storing the test case automatically generated by the terminal. After the terminal dynamically generates the test case according to the webpage dynamic html generation rule, the generated test case can be further stored in a test case file so as to be used by the terminal later.
Fig. 4 is a flowchart of another implementation manner of S103 in the embodiment of fig. 2, and as shown in fig. 4, the step S103 "test the test webpage by using the test case to obtain the test result" includes:
s301, reading the test cases in the test case file.
When the terminal needs to use the test case to test the test webpage, the test case in the test case file can be read, so that the read test case can be used for testing the test webpage.
S302, carrying out test operation on each item to be tested in the test webpage by using the test case to obtain a test result; the test operation includes at least one of adding a test, deleting a test, modifying a test, and checking a test.
When the terminal reads the test case in the test case file, the test case can be used to perform test operation on each item to be tested in the test webpage, and a test result of each step is obtained. Specifically, the terminal may perform at least one test operation of an add test, a delete test, a modify test, and an inspection test on each item to be tested during the test.
In practical applications, after the terminal performs the above S103, the terminal may further perform the following steps: and storing the test result in a preset result document.
The result document is used for storing a test result of each step obtained after the terminal tests the test webpage step by step. When the terminal performs the step-by-step test on the test web page and obtains the test result of each step, the obtained test result can be further stored in a predefined result document for the terminal to use later.
Fig. 5 is a flowchart of another implementation manner of S104 in the embodiment of fig. 2, and as shown in fig. 5, the S104 "generating a test report according to a test result" includes:
s401, marking each test result according to the test attribute of each test result.
The test attribute represents the nature of the test result, for example, the test result may be a general result, an abnormal result, or a serious error result. In this embodiment, the test attributes include: the test result is a general result, the test result is an error result corresponding to the abnormality, and the test result is a serious error result corresponding to the abnormality.
And when the terminal needs to generate a test report according to the test result, generating a corresponding test report according to each test result. In this embodiment, the terminal may mark each test result first, and specifically, may mark each test result according to the test attribute of each test result, so as to mark the test attribute corresponding to each test result, so that a tester or a developer may quickly evaluate each test result according to the test attribute, thereby facilitating the tester or the developer to locate, investigate, and solve the problem on the test webpage later.
S402, generating a test report according to the marked test results.
After the terminal obtains the labeled test results, the terminal can generate the test reports according to the preset report formats, for example, the report formats of the EXE form, the WORD, the TXT, the webpage, and the like, so that the user can check the test reports. The test report shows the test result of each step when the test web page is tested and the corresponding test attribute information. Optionally, the test report may specifically be a test report in a form of a web page, and the test report in the form of the web page may include some statistical charts, curves, and the like in addition to the test result and the test attribute information. Therefore, the test report in the form of the webpage has stronger visibility and is more beneficial to the user to view.
In summary, the present application also provides a testing method, as shown in fig. 6, the method specifically includes:
s501, acquiring test information configured by a user; the test information includes the URL of the test web page, the username of the test web page, and the password of the test web page.
S502, calling a corresponding selenium test interface by using a selenium technology, and reading information related to the test webpage, such as a directory structure of the test webpage, a parameter ID of the test webpage, a prompt value range of the test webpage and the like from a background server according to the test information.
S503, according to a preset webpage dynamic html generation rule, generating a detailed test case related to Xpath according to the read information related to the test webpage, such as the directory structure of the test webpage, the parameter ID of the test webpage, the prompt value range of the test webpage and the like.
S504, storing the test case in a preset test case file.
And S505, reading the test cases in the test case file, simulating a user by adopting a selenium technology, and performing click test on the test webpage by using the read test cases to obtain a test result.
S506, storing the test result in a result document.
S507, labeling each test result in the result document according to the test attribute of each test result to obtain a labeled result document; the test attributes include general, abnormal, and severe.
And S508, generating a test report in a webpage form according to the marked result document.
The testing method provided by the embodiment realizes the full-automatic testing of the Web page, and does not need to intervene any manual operation in the testing process. When different products need to be tested, the testing method provided by the application only needs to reconfigure the URL of the testing webpage, the user name and the password of the testing webpage, and solves the problems that the traditional testing method only can test one product or item, and when different products or items need to be tested, the application range is small and the testing breadth is not enough due to the fact that a testing case and a testing program need to be redesigned. The test method provided by the application can be suitable for different products to be tested, and is wide in test range and strong in popularization and application.
It should be understood that although the various steps in the flow charts of fig. 2-6 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2-6 may include multiple sub-steps or phases that are not necessarily performed at the same time, but may be performed at different times, and the order of performance of the sub-steps or phases is not necessarily sequential.
In one embodiment, as shown in fig. 7, there is provided a test apparatus including: the system comprises an acquisition module 11, a use case generation module 12, a test module 13 and a report generation module 14, wherein:
an obtaining module 11, configured to obtain test information; the test information is information required when test operation on the test webpage is executed;
the generating case module 12 is used for generating a test case of the test webpage according to the test information according to a preset webpage dynamic html generating rule;
the test module 13 is used for testing the test web page by using the test case to obtain a test result;
and a report generation module 14, configured to generate a test report according to the test result.
In an embodiment, as shown in fig. 8, the use case generating module 12 includes:
the obtaining unit 121 is configured to obtain, through a selenium test interface, an item to be tested corresponding to a test web page from a background server according to the test information;
and the generating unit 122 is configured to generate a test case of the test webpage according to the item to be tested according to the webpage dynamic html generating rule.
In an embodiment, as shown in fig. 9, after the generating the use case module 12, the test apparatus further includes:
the first storage module 15 is configured to store the test case in a preset test case file.
In one embodiment, as shown in fig. 10, the test module 13 includes:
the reading unit 131 is configured to read a test case in the test case file;
the testing unit 132 is configured to perform a testing operation on each item to be tested in the testing webpage by using the test case to obtain a testing result; the test operation includes at least one of adding a test, deleting a test, modifying a test, and checking a test.
In an embodiment, the item to be tested includes at least one of a directory structure of a test web page, a parameter ID of the test web page, and a prompt value range of the test web page.
In one embodiment, as shown in fig. 11, the report generation module 14 includes:
the labeling unit 141 is configured to label each test result according to the test attribute of each test result;
and a report generating unit 142, configured to generate a test report according to the labeled test results.
In one embodiment, the test attributes include: general, abnormal, and severe.
For the specific definition of the test device, reference may be made to the above definition of a test method, which is not described in detail herein. The modules in the testing device can be wholly or partially implemented by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 12. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a testing method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
Those skilled in the art will appreciate that the architecture shown in fig. 12 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory and a processor, the memory having a computer program stored therein, the processor implementing the following steps when executing the computer program:
acquiring test information; the test information is information required when test operation on the test webpage is executed;
generating a test case of the test webpage according to the test information according to a preset webpage dynamic html generation rule;
testing the test webpage by using the test case to obtain a test result;
and generating a test report according to the test result.
The implementation principle and technical effect of the computer device provided by the above embodiment are similar to those of the above method embodiment, and are not described herein again.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, the computer program, when executed by a processor, further implementing the steps of:
acquiring test information; the test information is information required when test operation on the test webpage is executed;
generating a test case of the test webpage according to the test information according to a preset webpage dynamic html generation rule;
testing the test webpage by using the test case to obtain a test result;
and generating a test report according to the test result.
The implementation principle and technical effect of the computer-readable storage medium provided by the above embodiments are similar to those of the above method embodiments, and are not described herein again.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), synchronous Link (Synchlink) DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.