A data processing method and device for automated testing
By abstracting page elements into model variables and establishing mapping relationships, the test case maintenance complexity problem caused by page elements changes in UI automation tests is solved, and the testing efficiency and reliability are improved.
Patent Information
- Application Number
- CN201711477059.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2017-12-29
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2037-12-29
AI Technical Summary
When page elements change, the existing UI automation testing methods are cumbersome to maintain and error-prone, and the encoding is complex, making it difficult to effectively manage.
Abstract page elements into model variables, generate test cases through model functions, and establish forward and reverse mapping relationships, and update the association relationship to adapt to page elements changes.
It reduces the coupling between page elements and test cases, improves the execution efficiency and maintenance efficiency of test cases, enhances the reliability of regression execution, and simplifies the maintenance of test cases after page elements changes.
Smart Images

Figure CN109992496B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a data processing method and device for automated testing. Background Art
[0002] The user interface (UI) is the hub of interaction between users and the system. The complete realization of system functions and a good user experience need to be based on a style-friendly and easy-to-use user interface. Therefore, UI testing is a very important component of software testing. Currently, there are two main ways to implement UI automated testing: method one: drive the browser or mobile terminal simulator to check each test function point according to the software function flow; method two: use PO (Page Object, a page object-based UI test design pattern) to convert the page area into an object, and then test the user interface; wherein, the page area is a plurality of areas into which the user interface is artificially divided, such as a search area, a list area, etc.
[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art: when a page element of the user interface changes, all test cases using the page element need to be modified. When using method one for testing, the maintenance of the test cases is cumbersome and error-prone; when using method two for testing, there are too many objects to be maintained, the coding is complex, and error-prone. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a data processing method and device for automated testing, which reduces the coupling between page elements and test cases and improves the execution efficiency and maintenance efficiency of test cases by abstracting page elements into model variables, calling model variables to write model functions, and calling model functions to generate test cases.
[0005] To achieve the above objective, according to one aspect of an embodiment of the present invention, a data processing method for automated testing is provided.
[0006] A data processing method for automated testing according to an embodiment of the present invention comprises: abstracting each page element in a user interface into a model variable, calling the model variable to write a model function; calling the model function to generate a test case according to a test function point; and running the test case to perform automated testing.
[0007] Optionally, after the step of calling the model function to generate a test case and before the step of running the test case, it also includes: establishing an association relationship between the test case and the page element based on the model variables used in the test case; and running the test case includes: obtaining a test case related to the page element based on the association relationship, and running the obtained test case.
[0008] Optionally, the association relationship includes a forward mapping relationship and a reverse mapping relationship; establishing the association relationship between the test case and the page element based on the model variables used in the test case includes: establishing a forward mapping relationship from the test case to the page element based on the model function called in the test case and the model variables called in the model function; and deriving a reverse mapping relationship from the page element to the test case based on the forward mapping relationship.
[0009] Optionally, after the step of establishing the association relationship between the test case and the page element and before the step of obtaining the test case related to the page element based on the association relationship, it also includes: if the page element of the user interface changes, updating the model variables, model functions, test cases and association relationships corresponding to the changed page elements.
[0010] Optionally, if the page elements of the user interface change, the model variables, model functions, test cases and association relationships corresponding to the changed page elements are updated, including: when a new page element is added to the user interface, the newly added page element is abstracted as a model variable, the model variable is called to write a model function, the model function is called to generate a test case, and a new association relationship is created between the test case and the newly added page element; when the page elements of the user interface are modified, the model variables, model functions and test cases corresponding to the page elements are obtained and modified according to the association relationship, and the association relationship is updated according to the modification result; when the user interface deletes a page element, the model variables corresponding to the page element, the model functions containing only the model variables and the test cases containing only the model functions are deleted, and the association relationship is updated according to the deletion result.
[0011] To achieve the above objective, according to one aspect of an embodiment of the present invention, a data processing device for automated testing is provided.
[0012] A data processing device for automated testing according to an embodiment of the present invention comprises: a model function writing module, used to abstract each page element in a user interface into a model variable, and call the model variable to write a model function; a test case generation module, used to call the model function to generate a test case according to a test function point; and a test module, used to run the test case to perform automated testing.
[0013] Optionally, the device also includes: an association relationship establishment module, used to establish an association relationship between the test case and the page element based on the model variables used in the test case; the testing module is also used to obtain test cases related to the page element based on the association relationship and run the obtained test cases.
[0014] Optionally, the association relationship includes a forward mapping relationship and a reverse mapping relationship; the association relationship establishment module is also used to: establish a forward mapping relationship from the test case to the page element based on the model function called in the test case and the model variable called in the model function; and derive a reverse mapping relationship from the page element to the test case based on the forward mapping relationship.
[0015] Optionally, the device further comprises: an association relationship updating module, configured to update the model variables, model functions, test cases and association relationships corresponding to the changed page elements if the page elements of the user interface change.
[0016] Optionally, the association relationship update module is also used to: when a new page element is added to the user interface, abstract the newly added page element into a model variable, call the model variable to write a model function, call the model function to generate a test case, and create a new association relationship between the test case and the newly added page element; when a page element of the user interface is modified, obtain and modify the model variable, model function and test case corresponding to the page element according to the association relationship, and update the association relationship according to the modification result; and when the user interface deletes a page element, delete the model variable corresponding to the page element, the model function that only contains the model variable and the test case that only contains the model function, and update the association relationship according to the deletion result.
[0017] To achieve the above objective, according to another aspect of an embodiment of the present invention, an electronic device is provided.
[0018] An electronic device according to an embodiment of the present invention comprises: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement a data processing method for automated testing according to an embodiment of the present invention.
[0019] To achieve the above objective, according to another aspect of the embodiments of the present invention, a computer readable medium is provided.
[0020] A computer-readable medium according to an embodiment of the present invention stores a computer program, and when the program is executed by a processor, a data processing method for automated testing according to an embodiment of the present invention is implemented.
[0021] An embodiment of the above invention has the following advantages or beneficial effects: by abstracting page elements into model variables, abstracting page functions into model functions, and calling model functions to generate test cases, the coupling between page elements and test cases is reduced, and the execution efficiency and maintenance efficiency of test cases are improved; by establishing an association relationship between test cases and page elements, the execution efficiency and maintenance efficiency of test cases are improved; through the forward and reverse mapping relationship, the reliability of test case regression execution is improved; when page elements change, the test cases corresponding to the page elements are found through the association relationship, which improves the maintenance efficiency of test cases without increasing the complexity of coding.
[0022] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0024] Figure 1 is a schematic diagram of main steps of a data processing method for automated testing according to an embodiment of the present invention;
[0025] Figure 2 is a schematic diagram of the main flow of a data processing method for automated testing according to an embodiment of the present invention;
[0026] Figure 3 is a schematic diagram of main modules of a data processing device for automated testing according to an embodiment of the present invention;
[0027] Figure 4 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0028] Figure 5 It is a schematic diagram of the structure of a computer device suitable for implementing the electronic device of the embodiment of the present invention. DETAILED DESCRIPTION
[0029] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0030] Figure 1 FIG. 1 is a schematic diagram of the main steps of a data processing method for automated testing according to an embodiment of the present invention. Figure 1 As shown, the data processing method for automated testing according to the embodiment of the present invention mainly includes the following steps:
[0031] Step S101: Abstract each page element in the user interface into a model variable, and call the model variable to write a model function. Abstract the page elements into model variables, and abstract the page function points (i.e., the functions implemented by each page) into model functions. The model variables may be instance variables or local variables, for example; the model functions may be Python function or Java method, for example. The names of the model variables and model functions may vary depending on the programming language used. Among them, Python is an object-oriented, interpreted computer programming language; Java is an object-oriented programming language that can be used to write cross-platform application software.
[0032] Step S102: According to the test function point, call the model function to generate a test case. The test case defines the test function point and the functions that the user interface should implement. The model function can complete the user interface function according to the execution process of the test case. The test function point includes each page element and execution logic in the user interface. The execution logic, for example, tests whether the registration is successful. The execution logic to be tested is: the client sends a user registration request (Request) to the server; after receiving the user registration request, the server verifies the data in the user registration request and returns a response (Response) according to the verification result.
[0033] Step S103: Run the test case to perform automated testing. Test cases corresponding to each test function point are generated through steps S101 and S02, and the test results can be obtained by running each test case.
[0034] Figure 2 FIG. 1 is a schematic diagram of the main flow of a data processing method for automated testing according to an embodiment of the present invention. Figure 2As shown, the data processing method for automated testing according to the embodiment of the present invention mainly includes the following steps:
[0035] Step S201: Locate each page element in the user interface. The user interface includes various page elements such as text, pictures, buttons, links, input boxes, etc., and the page elements in the user interface can be located using positioning methods such as ID (locating by the identifier of the page element), Class (locating by the type of the page element), or Xpath (a document positioning language).
[0036] Step S202: Abstract each located page element into a model variable, and call the model variable according to the page function point to write a model function. The model variables and model functions constitute a page model. Assuming that the page model is represented by P, the model variables can be represented as: page text variable P.var1, page image variable P.var2, clickable button variable P.var3...; the model function can be represented as: get page text function P.func1 (P.varN,...), form submission function P.func2 (P.varN,...), page search function P.func3 (P.varN,...),.... A model function may need to call multiple model variables. For example, in the get page text function, the page text variable P.var1 and the page image variable P.var2 may need to be called. Ellipses are used in the model function to represent other required model variables. In a preferred embodiment, the model variables are called to write the model function according to UCD (User Centered Design).
[0037] Step S203: Based on the test function point, call the model function to generate a test case. Call the model function and the corresponding model variables to generate all test cases covering the Product Requirement Document (PRD). The test case may be, for example:
[0038] Test page text accuracy case1:test_text_accurate(P.funcM(),...)
[0039] Test button clickability case2:test_button_click(P.funcM(),...)
[0040] Test form improves function case3:test_submit_form(P.funcM(),...)
[0041] Similarly, a test case may need to call multiple model functions, so ellipsis is used in the test case to represent other required model functions.
[0042] Taking the test of any user login page as an example, the test function points include checking the username input box, password input box, and login button. Each input box needs to be checked for input, the length of the input characters, and the legality of the input characters; the button needs to be checked for clickability; and finally, the server's response to legal logins (i.e. correct username and password) and illegal logins (i.e. incorrect username or password) needs to be checked. The page function points include entering the username, entering the user password, and clicking the login button. The processing at this time is:
[0043] Create a new page model P (which can be a Java class or a Python module). This page model P has three model variables, namely P.var1 for the username input box, P.var2 for the password input box, and P.var3 for the login button.
[0044] Create three model functions based on the page function points: P.func1 for entering the user name, P.func2 for entering the password, and P.func3 for calling P.func1 and P.func2 and clicking the login button.
[0045] Write a test case based on the test function point: Call P.func3 to complete the login operation of the login page. Then determine whether the actual result (the result returned by P.func3) matches the expected result (such as whether to jump to the page).
[0046] Step S204: Establish an association relationship between the test case and the page element based on the model variables used in the test case. The association relationship includes a forward mapping relationship and a reverse mapping relationship. In actual engineering applications, test cases need to be used to test the functions of page elements, so it is necessary to first derive the forward mapping relationship, and then infer the reverse mapping relationship from the forward mapping relationship. The association relationship can specifically be: first, based on the model function called in the test case and the model variables called in the model function, establish a forward mapping relationship from the test case to the page element; then, infer the reverse mapping relationship from the page element to the test case based on the forward mapping relationship.
[0047] Among them, a forward mapping relationship can be expressed as:
[0048] Test_case->P.funcX(),...->P.attrX,...->page_elementX,...
[0049] A reverse mapping relationship can be expressed as:
[0050] Page_element->P.attrX,...->P.funcX(),...->test_caseX
[0051] In the embodiment, a plurality of forward mapping relationships and corresponding reverse mapping relationships are established according to actual needs, and all mapping relationships constitute a mapping relationship table.
[0052] Step S205: If the page elements of the user interface change, the model variables, model functions, test cases and associations corresponding to the changed page elements are updated. The page elements of the user interface are modified by the designer. If the designer informs the tester of the changes in the page elements after the modification, the tester can update the associations according to the changes. If the designer does not inform the tester of the changes in the page elements after the modification, an error will be reported when executing the original test case. At this time, the tester needs to check whether it is an error in the test case or a bug in the program code itself. The changes in page elements are divided into three situations, namely, addition, modification and deletion. For example, the modification changes the default text of the input box from "user name / mobile phone number" to "user name / mobile phone number / email". The following introduces the update process of the association for each of these three situations.
[0053] When a new page element is added to the user interface, the new page element is abstracted as a model variable, a test case corresponding to the model variable is generated, and an association relationship between the test case and the page element is established. That is, according to the execution process of step 201 to step 204, an association relationship between the new page element and the corresponding test case is newly established.
[0054] When a page element of the user interface is modified, the model variables, model functions, and test cases corresponding to the page element are found and modified according to the association relationship, and the association relationship is updated according to the modification result, that is, the model variables, model functions, test cases, and association relationships related to the modified page element are corrected.
[0055] When the user interface deletes a page element, the model variables corresponding to the page element, the model functions that only contain the model variables, and the test cases that only contain the model functions are deleted, and then the association relationship is updated according to the deletion result. When a page element is deleted, its corresponding model functions and test cases may be used by other page elements, so only the model variables corresponding to the page element, the model functions that only contain the model variables, and the test cases that only contain the model functions need to be deleted, and then the page element and the above-mentioned model variables, model functions, and test cases are deleted from the association relationship.
[0056] Step S206: Acquire test cases related to the page elements according to the association relationship, and run the acquired test cases to perform automated testing. If the page elements of the user interface change, search for test cases according to the updated reverse mapping relationship; if the page elements do not change, directly execute the test cases obtained in step S203.
[0057] In addition, in order to facilitate other testers and managers to understand the test status in real time, the test results can be generated into a test report, which can then be automatically sent to relevant personnel via email.
[0058] It can be seen from the data processing method for automated testing in the embodiment of the present invention that by abstracting page elements into model variables, abstracting page functions into model functions, and calling model functions to generate test cases, the coupling between page elements and test cases is reduced, and the execution efficiency and maintenance efficiency of test cases are improved; by establishing an association relationship between test cases and page elements, the execution efficiency and maintenance efficiency of test cases are improved; through the forward and reverse mapping relationship, the reliability of test case regression execution is improved; when page elements change, the test cases corresponding to the page elements are found through the association relationship, which improves the maintenance efficiency of test cases and does not increase the complexity of coding.
[0059] Figure 3 Schematic diagram of the main modules of the data processing device for automated testing according to an embodiment of the present invention. Figure 3 As shown, the data processing device 300 for automated testing according to the embodiment of the present invention mainly includes:
[0060] The model function writing module 301 is used to abstract each page element in the user interface into a model variable, and call the model variable to write the model function. The page elements are abstracted into model variables, and the page function points are abstracted into model functions. The model variables can be instance variables or local variables, for example; the model functions can be Python function functions or Java method methods, for example. The names of model variables and model functions will change accordingly depending on the programming language used.
[0061] The test case generation module 302 is used to call the model function to generate a test case according to the test function point. The test case defines the test function point and the function that the user interface should implement, and the model function can complete the user interface function according to the execution process of the test case. The test function point includes each page element and execution logic in the user interface.
[0062] The test module 303 is used to run the test cases to perform automated testing. The test cases corresponding to each test function point are generated by the model function writing module 301 and the test case generating module 302. The test results can be obtained by running each test case.
[0063] In addition, the data processing device 300 for automated testing of the embodiment of the present invention may also include: an association relationship establishment module and an association relationship update module (not shown in the figure). Among them, the association relationship establishment module is used to establish the association relationship between the test case and the page element according to the model variables used in the test case. The association relationship includes a forward mapping relationship and a reverse mapping relationship. The association relationship can be specifically: first, according to the model function called in the test case and the model variable called in the model function, a forward mapping relationship from the test case to the page element is established; then, according to the forward mapping relationship, a reverse mapping relationship from the page element to the test case is obtained. The association relationship update module is used to update the model variables, model functions, test cases and association relationships corresponding to the changed page elements if the page elements of the user interface change.
[0064] From the above description, it can be seen that by abstracting page elements into model variables, abstracting page functional points into model functions, and calling model functions to generate test cases, the coupling between page elements and test cases is reduced, and the execution efficiency and maintenance efficiency of test cases are improved; by establishing an association relationship between test cases and page elements, the execution efficiency and maintenance efficiency of test cases are improved; through the forward and reverse mapping relationship, the reliability of test case regression execution is improved; when page elements change, the test cases corresponding to the page elements are found through the association relationship, which improves the maintenance efficiency of test cases without increasing the complexity of coding.
[0065] Figure 4 An exemplary system architecture 400 is shown to which a data processing method for automated testing or a data processing system for automated testing according to an embodiment of the present invention can be applied.
[0066] like Figure 4 As shown, system architecture 400 may include terminal devices 401, 402, 403, network 404 and server 405. Network 404 is used to provide a medium for communication links between terminal devices 401, 402, 403 and server 405. Network 404 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0067] Users can use terminal devices 401, 402, 403 to interact with server 405 through network 404 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 401, 402, 403, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0068] The terminal devices 401 , 402 , and 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0069] The server 405 may be a server that provides various services, such as a background management server (only an example) that provides support for click events generated by users using the terminal devices 401, 402, and 403. The background management server may analyze and process the received click data, text content, and other data, and feed back the processing results (such as target push information, product information - only an example) to the terminal device.
[0070] It should be noted that the data processing method for automated testing provided in the embodiment of the present application is generally executed by the server 405 , and accordingly, the data processing device for automated testing is generally arranged in the server 405 .
[0071] It should be understood that Figure 4 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.
[0072] According to an embodiment of the present invention, the present invention also provides an electronic device and a computer-readable medium.
[0073] The electronic device of the present invention comprises: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement a data processing method for automated testing according to an embodiment of the present invention.
[0074] The computer-readable medium of the present invention stores a computer program thereon, and when the program is executed by a processor, a data processing method for automated testing according to an embodiment of the present invention is implemented.
[0075] Reference below Figure 5 , which shows a schematic diagram of the structure of a computer system 500 suitable for implementing an electronic device of an embodiment of the present invention. Figure 5 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0076] like Figure 5 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the computer system 500 are also stored. The CPU 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0077] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that a computer program read therefrom is installed into the storage section 508 as needed.
[0078] In particular, according to the embodiments disclosed in the present invention, the process described in the main step diagram above can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the main step diagram. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the central processing unit (CPU) 501, the above-mentioned functions defined in the system of the present invention are executed.
[0079] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0080] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0081] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be arranged in a processor, for example, they may be described as: a processor including a model function writing module, a test case generation module and a test module. The names of these modules do not constitute a limitation on the module itself in some cases, for example, the model function writing module may also be described as "a module that abstracts each page element in the user interface into a model variable, and calls the model variable to write a model function".
[0082] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: abstracting each page element in the user interface into a model variable, calling the model variable to write a model function; calling the model function to generate a test case according to the test function point; and running the test case to perform automated testing.
[0083] From the above description, it can be seen that by abstracting page elements into model variables, abstracting page functional points into model functions, and calling model functions to generate test cases, the coupling between page elements and test cases is reduced, and the execution efficiency and maintenance efficiency of test cases are improved; by establishing an association relationship between test cases and page elements, the execution efficiency and maintenance efficiency of test cases are improved; through the forward and reverse mapping relationship, the reliability of test case regression execution is improved; when page elements change, the test cases corresponding to the page elements are found through the association relationship, which improves the maintenance efficiency of test cases without increasing the complexity of coding.
[0084] The above product can execute the method provided by the embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not described in detail in this embodiment, please refer to the method provided by the embodiment of the present invention.
[0085] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A data processing method for automated testing, characterized in that: include: Each page element in the user interface is abstracted into a model variable, and the model variable is called according to the page function point to write a model function; wherein the page function point is each function implemented by the page; According to the test function point, calling the model function to generate a test case; According to the model variables used in the test case, an association relationship between the test case and the page element is established; wherein the association relationship includes a forward mapping relationship and a reverse mapping relationship; Run the test cases to perform automated testing.
2. The method according to claim 1, characterized in that The running of the test case includes: acquiring a test case related to the page element according to the association relationship, and running the acquired test case.
3. The method according to claim 1, characterized in that The establishing of an association relationship between the test case and the page element according to the model variable used in the test case includes: Establishing a forward mapping relationship from the test case to the page element according to the model function called in the test case and the model variable called in the model function; A reverse mapping relationship from the page element to the test case is obtained according to the forward mapping relationship.
4. The method according to any one of claims 1 to 3, characterized in that After the step of establishing the association relationship between the test case and the page element and before the step of obtaining the test case related to the page element according to the association relationship, it also includes: if the page element of the user interface changes, updating the model variables, model functions, test cases and association relationships corresponding to the changed page elements.
5. The method according to claim 4, characterized in that If the page elements of the user interface change, the model variables, model functions, test cases and association relationships corresponding to the changed page elements are updated, including: When a new page element is added to the user interface, the new page element is abstracted into a model variable, the model variable is called to write a model function, the model function is called to generate a test case, and a new association relationship between the test case and the new page element is created; When a page element of the user interface is modified, the model variables, model functions and test cases corresponding to the page element are acquired and modified according to the association relationship, and the association relationship is updated according to the modification result; When the user interface deletes a page element, the model variable corresponding to the page element, the model function containing only the model variable, and the test case containing only the model function are deleted, and the association relationship is updated according to the deletion result.
6. A data processing device for automated testing, characterized in that: include: A model function writing module is used to abstract each page element in the user interface into a model variable, and call the model variable according to the page function point to write the model function; wherein the page function point is each function realized by the page; A test case generation module, used to call the model function to generate a test case according to the test function point; An association relationship establishment module, used to establish an association relationship between the test case and the page element according to the model variables used in the test case; The test module is used to run the test cases to perform automated testing.
7. The device according to claim 6, characterized in that The testing module is further used to obtain test cases related to the page elements according to the association relationship, and run the obtained test cases.
8. The device according to claim 6, characterized in that The association relationship establishment module is also used for: Establishing a forward mapping relationship from the test case to the page element according to the model function called in the test case and the model variable called in the model function; as well as A reverse mapping relationship from the page element to the test case is obtained according to the forward mapping relationship.
9. The device according to any one of claims 6 to 8, characterized in that The device also includes: an association relationship updating module, which is used to update the model variables, model functions, test cases and association relationships corresponding to the changed page elements if the page elements of the user interface change.
10. The device according to claim 9, characterized in that The association relationship updating module is further used for: When a new page element is added to the user interface, the newly added page element is abstracted into a model variable, the model variable is called to write a model function, the model function is called to generate a test case, and a new association relationship between the test case and the page element is newly established; When a page element of the user interface is modified, the model variables, model functions and test cases corresponding to the page element are acquired and modified according to the association relationship, and the association relationship is updated according to the modification result; as well as When the user interface deletes a page element, the model variables corresponding to the page element, the model functions only including the model variables, and the test cases only including the model functions are deleted, and the association relationship is updated according to the deletion result.
11. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.
12. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Webpage testing method and device
CN104820640A