Test case script generation method, system, medium and electronic device
By parsing the Rest API to define documents and generate a graphical stream visual editing page, users can intuitively edit test case logic and automatically convert it into scripts, solving the complexity and compatibility issues of Rest API test case writing in the existing technology, improving testing efficiency and quality.
Patent Information
- Application Number
- CN202111280146.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-29
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2041-10-29
AI Technical Summary
When generating Rest API test cases, the existing technology has problems such as high learning threshold, complex logic and difficult to troubleshoot, resulting in low efficiency and quality of test cases writing.
By obtaining the Rest API definition document, parsing element and parameter format information, and outputting a graphical stream visual editing page, users can intuitively edit the test case logical relationship, automatically convert it into unified use case description information, and finally generate a test case script.
Reduces the operation requirements of testers for scripts, simplifies the test case writing process, reduces the error rate, improves the test efficiency and quality, realizes the decoupling of test cases and test engines, and solves the incompatibility of scripts in different test engine environments. question.
Smart Images

Figure CN113900958B_ABST
Abstract
Description
Background Art
[0002] At present, most online systems are developed in accordance with the Rest API specification, using a front-end and back-end separation architecture, and exchanging data in JSON format. Therefore, most conventional test case writing requires understanding the input and output parameter formats of specific Rest API requests, and then using the specific syntax or tools of the automated testing framework to generate test cases.
[0003] However, this solution for generating test cases still has defects such as a certain learning threshold for using the test framework, a high time cost for understanding the input and output parameter formats of Rest API requests, and the logic of complex test cases is difficult to understand and troubleshoot. Summary of the invention
[0004] In the field of software testing technology, in order to solve the above technical problems, the purpose of the present application is to provide a method, system, computer-readable medium and electronic device for generating a test case script.
[0005] According to one aspect of an embodiment of the present application, a method for generating a test case script is provided, the method comprising:
[0006] Obtain a REST API definition document, and parse the REST API definition document to obtain elements and parameter format information corresponding to the elements;
[0007] Outputting a graphic flow visualization editing page, wherein the graphic flow visualization editing page includes components corresponding to the elements;
[0008] According to the target components selected from the components of the graphic flow visualization editing page, the target components are displayed, and parameter data corresponding to the parameter format information of each target component is acquired;
[0009] According to the received interactive instruction, drawing a graphic flow in the graphic flow visualization editing page, wherein the graphic flow is used to represent the logical relationship between the target components;
[0010] Acquire graphics stream data corresponding to the graphics stream, and use the parameter data and the graphics stream data as graphics stream editing data;
[0011] According to the format specification of describing the test case, the graphic flow editing data is converted into unified test case description information;
[0012] The unified use case description information is converted into a test case script.
[0013] According to one aspect of an embodiment of the present application, a system for generating a test case script is provided, the system comprising:
[0014] A Rest API analysis module is used to obtain a Rest API definition document and parse the Rest API definition document to obtain elements and parameter format information corresponding to the elements;
[0015] A front-end graphic stream editing module is used to output a graphic stream visualization editing page, wherein the graphic stream visualization editing page includes components corresponding to the elements, wherein the front-end graphic stream editing module is further used to:
[0016] According to the target components selected from the components of the graphic flow visualization editing page, the target components are displayed, and parameter data corresponding to the parameter format information of each target component is acquired;
[0017] According to the received interactive instruction, drawing a graphic flow in the graphic flow visualization editing page, wherein the graphic flow is used to represent the logical relationship between the target components; and
[0018] Acquire graphics stream data corresponding to the graphics stream, and use the parameter data and the graphics stream data as graphics stream editing data;
[0019] A unified use case description conversion module, used to convert the graphic flow editing data into unified use case description information according to the format specification of describing the test case;
[0020] The adaptation and conversion module is used to convert the unified use case description information into a test case script.
[0021] According to one aspect of an embodiment of the present application, a computer-readable medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method described in the above embodiment is implemented.
[0022] According to one aspect of an embodiment of the present application, there is provided an electronic device, including:
[0023] one or more processors;
[0024] The storage device is used to store 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 described in the above embodiments.
[0025] The technical solution provided by the embodiments of the present application may have the following beneficial effects:
[0026] The test case script generation method provided in the present application includes the following steps: obtaining a Rest API definition document, parsing the Rest API definition document, obtaining elements and parameter format information corresponding to the elements; outputting a graphic flow visualization editing page, the graphic flow visualization editing page including components corresponding to the elements; displaying the target components according to the target components selected from the components of the graphic flow visualization editing page, and obtaining parameter data corresponding to the parameter format information of each target component; drawing a graphic flow in the graphic flow visualization editing page according to the received interaction instructions, the graphic flow being used to represent the logical relationship between the target components; obtaining graphic flow data corresponding to the graphic flow, and using the parameter data and the graphic flow data as graphic flow editing data; converting the graphic flow editing data into unified use case description information according to the format specification for describing the test case; converting the unified use case description information into a test case script.
[0027] Under this method, on the one hand, users can edit test cases in a visual way through graphic flows, which can be automatically converted into test case scripts after editing. This method is simple, intuitive, easy to understand, and convenient to operate. It greatly reduces the scripting ability requirements of testers and greatly reduces the learning threshold. On the other hand, when editing test cases, only parameter data needs to be provided, and the parameter data is set according to the parameter format information. The parameter format information is obtained by parsing the Rest API definition document, so the parameter data can be standardized, thereby reducing the error rate and improving software evaluation efficiency. In addition, the entire solution automatically generates test case scripts through unified test case description information, and the test case scripts can be executed in the actual test engine, thus realizing the decoupling of test case writing from the specific test engine and solving the script incompatibility problem of different test engine environments.
[0028] It should be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0030] Figure 1 is a system architecture diagram of a method for generating a test case script according to an exemplary embodiment;
[0031] Figure 2 is a flow chart of a method for generating a test case script according to an exemplary embodiment;
[0032] Figure 3is a schematic diagram of a graphic flow visualization editing page according to an exemplary embodiment;
[0033] Figure 4 is a schematic diagram of a parameter data acquisition page according to an exemplary embodiment;
[0034] Figure 5 is a schematic diagram showing a display mode of a test case script in a test engine according to an exemplary embodiment;
[0035] Figure 6 is a block diagram of a system for generating a test case script according to an exemplary embodiment;
[0036] Figure 7 It is a schematic diagram of a flow chart of generating scripts by a generation system based on test case scripts according to an exemplary embodiment;
[0037] Figure 8 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION
[0038] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0039] In addition, the drawings are only schematic illustrations of the present application and are not necessarily drawn to scale. The same reference numerals in the drawings represent the same or similar parts, and their repeated descriptions will be omitted. Some of the block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities.
[0040] Writing test cases is the main work of the software evaluation process. The efficiency, quality and correctness of test case writing are not only related to the tester's own ability, but also closely related to the test case generation tool. In the related technology, when using existing tools such as jmeter and robotframework to write test cases, it is impossible to verify whether the path, method and parameters of the request are correct when calling the Rest API; and there is a lack of an intuitive way to describe the relationship between the various elements in the test case; in addition, the test tool needs to be installed locally before it can be used.
[0041] To this end, this application first provides a method for generating a test case script, which can overcome the above defects. Test cases can be written on a page only in an Internet environment, which makes it convenient for testers to understand the logical structure of the entire test case, improves the efficiency, quality and correctness of test case writing, and thus greatly improves the efficiency of the software evaluation workflow.
[0042] The implementation terminal of the present application can be any device with computing, processing and communication functions, which can be connected to an external device for receiving or sending data. Specifically, it can be a portable mobile device, such as a smart phone, a tablet computer, a laptop computer, a PDA (Personal Digital Assistant), etc., or it can be a fixed device, such as a computer device, a field terminal, a desktop computer, a server, a workstation, etc. It can also be a collection of multiple devices, such as the physical infrastructure or server cluster of cloud computing.
[0043] Optionally, the implementation terminal of the present application may be a server or a physical infrastructure of cloud computing.
[0044] Figure 1 FIG. 1 is a schematic diagram of a system architecture of a method for generating a test case script according to an exemplary embodiment. Figure 1 As shown, the system architecture 100 includes a terminal device, a network 104 and a server 105, wherein the terminal device may specifically include a desktop computer 101, a smart phone 102 and a laptop computer 103, and each terminal device is connected to a server 110 via the network 104, thereby realizing the interaction between the terminal device and the server 110. The server 110 is an implementation terminal of the embodiment of the present application, on which a test case script generation system is deployed. When a test case script generation method provided by the present application is applied to Figure 1In the system architecture shown, a process can be as follows: first, the user of the laptop computer 103 sends a Rest API definition document to the server 110 through the network 104. The user of the laptop computer 103 can be a developer of the RestAPI; then, after obtaining the Rest API definition document, the server 110 parses it to obtain the elements and the corresponding parameter format information; then, the server 110 outputs a graphic flow visualization editing page including the components corresponding to the elements, and returns the graphic flow visualization editing page to the terminal device according to the request of the terminal device; then, the user of the terminal device interacts with the test case script generation system through the graphic flow visualization editing page, and the user can select the target component on the graphic flow visualization editing page, draw the graphic flow by connecting lines, and submit the parameter data corresponding to the target component through the page, so that the server 110 obtains the graphic flow editing data including the parameter data and the graphic flow data; finally, the server 110 converts the graphic flow editing data into the unified use case description information, and converts the unified use case description information into the test case script.
[0045] In one embodiment of the present application, the server 110 is also deployed with a test engine, and the server 110 outputs the generated test case script to a specified directory that can be read by the test engine.
[0046] In one embodiment of the present application, a test engine is deployed on the desktop computer 101 and the smart phone 102. After outputting the test case script, the server 110 generates a link for downloading the test case script and sends the link to the desktop computer 101 and the smart phone 102. The desktop computer 101 and the smart phone 102 can download the test case script through the obtained link and complete the test by executing the test case script.
[0047] It is worth mentioning that Figure 1 This is only one embodiment of the present application. Figure 1 In the embodiment, the REST API definition document is submitted to the implementation terminal by the terminal device, but in other embodiments or specific applications, the REST API definition document can also be created and written locally in the implementation terminal; Figure 1 In the embodiment, the terminal interacting with the test case script generation system and the implementation terminal are different terminals, but in other embodiments of the present application, the terminal interacting with the test case script generation system and the implementation terminal can also be the same terminal. The embodiment of the present application does not make any limitation to this, and the protection scope of the present application should not be limited in any way.
[0048] Figure 21 is a flow chart of a method for generating a test case script according to an exemplary embodiment. Physically, the method for generating a test case script provided in this embodiment can be executed by a server; logically, the method for generating a test case script provided in this embodiment can be executed by a test case script generation system, such as Figure 2 As shown, the following steps may be included:
[0049] Step 210: Obtain a Rest API definition document, and parse the Rest API definition document to obtain elements and parameter format information corresponding to the elements.
[0050] The Rest API definition document (specifically, an OpenAPI specification document) can be written by developers, which defines the writing specifications of the Rest API. The Rest API can also be called the RESTFUL API, which is an API (Application Programming Interface) based on the Rest (Representational State Transfer) technology. RESTFUL is a design style and development method for network applications, based on HTTP, and can be defined in XML format or JSON format.
[0051] Therefore, the test case script generated based on the solution of the embodiment of the present application can actually realize interface testing.
[0052] The Rest API definition document can be obtained from the tester's terminal, and can also be obtained from other locations such as databases.
[0053] By parsing the Rest API definition document, you can get elements such as HTTP request, response assertion, and branch. For an element, you can not only parse the corresponding parameter format information, but also parse other specification information. For example, for the HTTP request element, you can extract the request path, request method, header information, input and output parameter formats, etc. by parsing the Rest API definition document.
[0054] In one embodiment of the present application, the obtaining of the Rest API definition document includes: obtaining the submitted Rest API definition document through a page or an interface.
[0055] Specifically, when a developer accesses the test case script generation system, he can submit the Rest API definition document by clicking a control on the access page. The test case script generation system can also provide an interface to the outside, and the Rest API definition document can be submitted by calling the interface.
[0056] The parameter format information defines the specification of the parameter data required to call the Rest API.
[0057] Step 220: output a graphic flow visualization editing page, wherein the graphic flow visualization editing page includes components corresponding to the elements.
[0058] The graphic flow visualization editing page may be a Web page. The user end (such as a tester's terminal) may receive the output graphic flow visualization editing page by accessing the page.
[0059] In one embodiment of the present application, the components include HTTP requests, response assertions, and branches.
[0060] As mentioned above, an element may be an object such as an HTTP request, a response assertion, a branch, etc. Therefore, a component corresponding to an element may be a component such as an HTTP request, a response assertion, a branch, etc. It is easy to understand that the types of elements may be various and may not be limited to the above.
[0061] Step 230 , according to the target components selected from the components of the graphic flow visualization editing page, the target components are displayed, and parameter data corresponding to the parameter format information of each target component is acquired.
[0062] The user end can interact with the system through the graphic stream visualization editing page to edit the graphic stream. The selected target component is the component used to establish the graphic stream.
[0063] In one embodiment of the present application, the acquiring of parameter data corresponding to the parameter format information of each target component includes: verifying the corresponding parameter data according to the parameter format information.
[0064] In the embodiment of the present application, the parameter data is verified based on the parameter format information so that the provided parameter data is legal, thereby ensuring the accuracy of the test.
[0065] Parameter data corresponding to the parameter format information can be obtained by selecting from a list.
[0066] In one embodiment of the present application, the obtaining of parameter data corresponding to the parameter format information of each target component includes: providing a list control including multiple standard parameter data corresponding to the parameter format information, so as to obtain parameter data selected from the multiple standard parameter data through the list control.
[0067] In an embodiment of the present application, parameter data is obtained by using a list control, and the standard parameter data in the list control is legal parameter data set according to parameter format information, so that the obtained parameter data is legal, thereby ensuring the accuracy of the test.
[0068] Figure 3 FIG. 1 is a schematic diagram of a graphic flow visualization editing page according to an exemplary embodiment. Figure 3 As shown in the figure, the graphical flow visualization editing page includes two areas, the left area is the component area, which can include multiple components such as HTTP request, response assertion, branch, etc., among which if() is a branch component, and the target component can be selected in the component area; the right area is the editing area, which can display the target component. Figure 3 In the editing area, HTTP represents the HTTP component, the assertion result can be the response assertion component, and the two branches corresponding to the assertion success and assertion failure can be branch components. The right area can also be used to edit the displayed target component to obtain the corresponding parameter data.
[0069] Step 240: Draw a graphic flow in the graphic flow visualization editing page according to the received interaction instruction, wherein the graphic flow is used to represent the logical relationship between the target components.
[0070] The graphical flow is actually a visual logical relationship diagram between target components, which records the test case logic.
[0071] In one embodiment of the present application, the graphic flow visualization editing page includes a first area and a second area, and the target component is displayed according to the target component selected from the components of the graphic flow visualization editing page, and parameter data corresponding to the parameter format information of each target component is obtained, including:
[0072] According to the received drag instruction, move a target component selected from the components displayed in the first area to the second area, and display the target component in the second area;
[0073] Outputting a parameter data acquisition page according to the received editing instruction for the target component, and acquiring parameter data corresponding to the parameter format information of each of the target components through the parameter data acquisition page;
[0074] Drawing the graphic flow in the graphic flow visualization editing page according to the received interactive instruction includes:
[0075] A graphic stream is drawn in the second area according to the interaction instruction received through the second area.
[0076] Please continue to see Figure 3, where the first region can be Figure 3 The left area in the second area can be Figure 3 The right area in the first area. The user can select the target component in the first area (such as clicking), and then drag the selected target component to the second area on the right, and the second area will display the dragged target component. The user can also edit the target component in the second area. Specifically, the user can enter the parameter data acquisition page by performing specific operations such as double-clicking or right-clicking on the target component to provide the corresponding parameter data. The user can draw lines between the target components in the second area to form a graphic flow.
[0077] The parameter data acquisition page is actually a component editing page, through which the data required for testing can be filled in. In a parameter data acquisition page, the parameter data of only one target component can be acquired, or the parameter data of multiple target components can be acquired at the same time.
[0078] A list of all parsed REST API requests can be displayed on the parameter data acquisition page of the REST API request component. Testers select the REST API request to be tested in the list and fill in the input parameter data, edit the assertion information, such as asserting the status code, and then choose to end the process or initiate another Rest API request based on the assertion result.
[0079] Figure 4 is a schematic diagram of a parameter data acquisition page according to an exemplary embodiment.
[0080] See also Figure 4As shown in the figure, for a REST API request component, in the corresponding parameter data acquisition page, it can be used to obtain parameters that can be selected from a list, such as API documents, API operations, and API methods. It can also be used to obtain request parameters, response assertion related parameters, output parameters, etc. through list selection or input. In the request parameter section, users can enter API request header, request parameters, and request body information; in the request header area, users can also select from the provided reference types, specifically input parameters, global variables, and values. The specific reference type selected can be parameter format information. Depending on the selected reference type, the selectable values of the reference value will change. If the reference type selects a value, the reference value can accept any input. In the response assertion section, the request response can also be asserted. The options include assertion mode, assertion parameters, assertion rules, reference type, and reference value. The response assertion related parameters provided by the user can be obtained by selection or input. The assertion mode can select status code, response body, etc. In the output parameter section, the response information can be saved to a global variable through the configuration of parameter data for use in subsequent graphic flow components. When the user clicks Figure 4 After clicking the confirmation button on the displayed page, the parameter data input of the REST API request component is completed.
[0081] In addition, the parameter data acquisition page can also display other information obtained by parsing the Rest API definition document, for example, basic information such as the URL can be displayed.
[0082] Step 250: Obtain graphics stream data corresponding to the graphics stream, and use the parameter data and the graphics stream data as graphics stream editing data.
[0083] Graphics stream data is the background data corresponding to the graphics stream displayed on the front end.
[0084] Step 260: convert the graphic flow editing data into unified test case description information according to the format specification for describing the test case.
[0085] In other words, the unified test case description is defined by a format specification for describing test cases, which defines various elements, their attributes, and their inclusion relationships. For example, test cases, test steps, branch assertions, etc. can be defined.
[0086] The unified use case description information mainly includes test steps (i.e., the steps array field), which may include call keywords, branches, and loop controls, etc. At the same time, it may also include built-in keywords such as send request, assert, assign, and extract request result.
[0087] An example of unified use case description information is as follows:
[0088]
[0089]
[0090]
[0091] For example, in the above example, steps can be test steps, http is the keyword for sending request, http_assert is the keyword for assertion, http_extract is the keyword for extracting request result, and "if_true" and "if_false" are branches in the test steps.
[0092] Step 270: convert the unified use case description information into a test case script.
[0093] In one embodiment of the present application, converting the unified use case description information into a test case script includes: converting the unified use case description information into a test case script that can be executed by at least one designated test engine.
[0094] The unified test case description information can be converted into a test case script that can be executed by each designated test engine by setting the corresponding plug-in. Specifically, the designated test engine can be a test engine such as jmeter and robotframework. The jmeter conversion plug-in and the robotframework conversion plug-in can be set to convert them into corresponding test case scripts respectively.
[0095] The script formats that can be recognized and executed by different test engines may be different. The embodiments of the present application can convert the unified use case description information into scripts that can be executed by each test engine, thereby achieving the isolation and decoupling of test case script writing and the test engine, and can generate scripts for different test engines more flexibly, with stronger applicability.
[0096] In one embodiment of the present application, the unified use case description information includes a custom function, and converting the unified use case description information into a test case script executable by at least one specified test engine includes: encapsulating the custom function in the unified use case description information into an element that can be recognized by the corresponding specified test engine.
[0097] Specifically, a custom function can be created in the unified use case description information to encapsulate recurring test steps into the function. For example, in the jmeter conversion plug-in, the custom function can be encapsulated using the TestFragment element that jmeter can recognize.
[0098] In one embodiment of the present application, the method further includes: obtaining an element custom code; converting the graphic flow editing data into unified use case description information includes: converting the graphic flow editing data and the element custom code into unified use case description information.
[0099] For example, testers can implement jmeter custom Java Request elements through Java code and then reference them in the unified use case description.
[0100] In the embodiments of the present application, the unified use case description retains a certain degree of scalability. For testers with strong coding skills, complex test logic can be implemented by creating custom keywords.
[0101] In one embodiment of the present application, after converting the unified use case description information into a test case script, the method further includes: performing interface testing by executing the test case script.
[0102] As mentioned above, the element and parameter format information is obtained by parsing the Rest API definition document. Therefore, the graphic flow editing data and the unified use case description information also correspond to the interface. Based on this, the test case script finally generated can be used for interface testing.
[0103] In one embodiment of the present application, after converting the unified use case description information into a test case script that can be executed by at least one designated test engine, converting the unified use case description information into a test case script also includes: outputting the test case script to the reading directory of the corresponding designated test engine.
[0104] In an embodiment of the present application, by directly outputting the test case script to the reading directory of the corresponding designated test engine, the designated test engine can directly execute the test case script for testing, thereby improving the test efficiency.
[0105] Figure 5 This is a schematic diagram of how a test case script is displayed in a test engine according to an exemplary embodiment. After generating a test case script in the jmeter script format and importing the test case script into the jmeter test engine, each element will be displayed in the display interface of the jmeter test engine as Figure 5 Nodes in the tree structure on the left.
[0106] To sum up, through the test case script generation method provided in the embodiment of the present application, Rest API test case scripts can be generated online in a graphical flow manner. Test cases can be written on the page only in an Internet-connected environment, so that testers can intuitively understand the logical structure of the entire test case. Rest API definition documents are also used to assist in editing test cases, thereby improving the efficiency, quality and correctness of test case writing. At the same time, the embodiment of the present application also decouples test case writing from a specific test engine, thereby solving the problem of script incompatibility in different test engine environments.
[0107] According to another aspect of the present application, the present application also provides a system for generating test case scripts. The following is a system embodiment of the present application.
[0108] Figure 6 The invention is a block diagram of a system for generating test case scripts according to an exemplary embodiment.
[0109] like Figure 6 As shown, the test case script generation system 600 includes:
[0110] The Rest API analysis module 610 is used to obtain a Rest API definition document and parse the Rest API definition document to obtain elements and parameter format information corresponding to the elements.
[0111] The Rest API analysis module can perform correctness analysis on the acquired Rest API definition document and save the RestAPI definition document in the test case script generation system.
[0112] The Rest API analysis module provides an access interface to the front-end graphic stream editing module, so that the front-end graphic stream editing module can obtain the parsing results of the Rest API analysis module.
[0113] The front-end graphic stream editing module 620 is used to output a graphic stream visualization editing page, wherein the graphic stream visualization editing page includes components corresponding to the elements, wherein the front-end graphic stream editing module is further used to:
[0114] According to the target components selected from the components of the graphic flow visualization editing page, the target components are displayed, and parameter data corresponding to the parameter format information of each target component is acquired;
[0115] According to the received interactive instruction, drawing a graphic flow in the graphic flow visualization editing page, wherein the graphic flow is used to represent the logical relationship between the target components; and
[0116] Graphics stream data corresponding to the graphics stream is acquired, and the parameter data and the graphics stream data are used as graphics stream editing data.
[0117] The front-end graphic flow editing module provides a graphic flow visualization editing page. The page provides elements such as Rest API, assertion and branch. Testers edit each element and combine the elements in the editing page by connecting them to form a test case. When editing Rest API elements, the page will display the imported Rest API. By selecting different RestAPIs, the page will display different parameters for testers to fill in.
[0118] The unified test case description conversion module 630 is used to convert the graphic flow editing data into unified test case description information according to the format specification of describing the test case.
[0119] The adaptation and conversion module 640 is used to convert the unified test case description information into a test case script.
[0120] The adaptation and conversion module can be developed using programming languages such as Java, python, and golang. The adaptation and conversion module can traverse the unified use case description information and convert the unified use case description information into an executable script file in a format that can be recognized by the test engine. The adaptation and conversion module may include a conversion plug-in corresponding to each test engine, and the unified use case description information is converted into a test case script through the conversion plug-in. Specifically, the adaptation and conversion module may include a jmeter conversion plug-in and a robotframework conversion plug-in, and the corresponding conversion interface is defined and implemented in the conversion plug-in. The unified use case description information can be converted into a test case script through the conversion interface. For example, a person familiar with the robotframework format script can implement the above-mentioned conversion interface, and by calling the conversion interface, the unified use case description information can be converted into a script that can be executed by the robotframework test engine, thereby providing a robotframework conversion plug-in.
[0121] Figure 7 FIG. 1 is a flow chart showing a script generation process of a test case script generation system according to an exemplary embodiment. Figure 7As shown, the specific process includes the following: first, the Rest API document is imported into the Rest API analysis module, and the Rest API analysis module parses it; then, the Rest API analysis module sends the parsing result to the front-end graphic stream editing module; then, the user can perform editing operations through the front-end graphic stream editing module to establish a graphic stream test case; next, the graphic stream test case is sent to the unified use case description conversion module, and the unified use case description conversion module converts the graphic stream test case into a unified use case description; then, the unified use case description is sent to the adaptation and conversion module, and the adaptation and conversion module converts the unified use case description into a test case script; finally, the test framework executes the test case script.
[0122] According to another aspect of the present application, an electronic device capable of implementing the above method is also provided.
[0123] Those skilled in the art will appreciate that various aspects of the present application may be implemented as a system, method or program product. Therefore, various aspects of the present application may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to as "circuit", "module" or "system" herein.
[0124] Figure 8 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown.
[0125] It should be noted that Figure 8 The computer system 800 of 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 application.
[0126] like Figure 8 As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 802 or the program loaded from the storage part 808 to the random access memory (RAM) 803, such as executing the method described in the above embodiment. In the RAM 803, various programs and data required for system operation are also stored. The CPU 801, ROM 802 and RAM 803 are connected to each other through a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0127] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed so that a computer program read therefrom is installed into the storage section 808 as needed.
[0128] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes 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 flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 809, and / or installed from a removable medium 811. When the computer program is executed by a central processing unit (CPU) 801, various functions defined in the system of the present application are executed.
[0129] It should be noted that the computer-readable medium shown in the embodiment of the present application 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), a 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 application, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable program code is carried. Such propagated data signals 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 programs 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, wired, etc., or any suitable combination of the above.
[0130] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the 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 flowchart, and the combination of boxes in the block diagram or flowchart 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.
[0131] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not constitute limitations on the units themselves in some cases.
[0132] As one aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device implements the method described in the above embodiment.
[0133] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.
[0134] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation methods of the present application.
[0135] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary technical means in the art that are not disclosed in the present application.
[0136] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A method for generating a test case script, characterized in that: The method comprises: Obtain a REST API definition document, and parse the REST API definition document to obtain elements and parameter format information corresponding to the elements; Outputting a graphic flow visualization editing page, wherein the graphic flow visualization editing page includes a component corresponding to the element, and the graphic flow visualization editing page includes a first area and a second area; According to the received drag instruction, move a target component selected from the components displayed in the first area to the second area, and display the target component in the second area; Outputting a parameter data acquisition page according to the received editing instruction for the target component, and providing a list control including a plurality of standard parameter data corresponding to the parameter format information through the parameter data acquisition page, so as to acquire parameter data selected from the plurality of standard parameter data through the list control; Drawing a graphic flow in the second area according to the interaction instruction received through the second area, the graphic flow being used to represent the logical relationship between the target components; Acquire graphics stream data corresponding to the graphics stream, and use the parameter data and the graphics stream data as graphics stream editing data; According to the format specification of describing the test case, the graphic flow editing data is converted into unified test case description information; The unified use case description information is converted into a test case script.
2. The method according to claim 1, characterized in that The converting the unified use case description information into a test case script comprises: The unified test case description information is converted into a test case script that can be executed by at least one designated test engine.
3. The method according to claim 2, characterized in that After converting the unified use case description information into a test case script executable by at least one designated test engine, converting the unified use case description information into a test case script further includes: Output the test case script to the reading directory of the corresponding specified test engine.
4. The method according to claim 2, characterized in that: The unified use case description information includes a custom function, and converting the unified use case description information into a test case script executable by at least one specified test engine includes: The user-defined functions in the unified use case description information are encapsulated into elements that can be recognized by the corresponding specified test engine.
5. The method according to claim 1, characterized in that: The components include HTTP requests, response assertions, and branches.
6. The method according to claim 1, characterized in that The obtaining of the Rest API definition document includes: Get the submitted REST API definition document through the page or interface.
7. A test case script generation system, characterized in that: The system comprises: A Rest API analysis module is used to obtain a Rest API definition document and parse the Rest API definition document to obtain elements and parameter format information corresponding to the elements; A front-end graphic stream editing module is used to output a graphic stream visualization editing page, wherein the graphic stream visualization editing page includes components corresponding to the elements, and the graphic stream visualization editing page includes a first area and a second area, wherein the front-end graphic stream editing module is further used to: According to the received drag instruction, move a target component selected from the components displayed in the first area to the second area, and display the target component in the second area; Outputting a parameter data acquisition page according to the received editing instruction for the target component, and providing a list control including a plurality of standard parameter data corresponding to the parameter format information through the parameter data acquisition page, so as to acquire parameter data selected from the plurality of standard parameter data through the list control; According to the interaction instruction received through the second area, drawing a graphic flow in the second area, the graphic flow being used to represent the logical relationship between the target components; and Acquire graphics stream data corresponding to the graphics stream, and use the parameter data and the graphics stream data as graphics stream editing data; A unified use case description conversion module, used to convert the graphic flow editing data into unified use case description information according to the format specification of describing the test case; The adaptation and conversion module is used to convert the unified use case description information into a test case script.
8. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
9. An electronic device, characterized in that: include: one or more processors; A storage device for storing one or more programs, which, when executed by the one or more processors, enables the one or more processors to implement the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Spacecraft test system and spacecraft test method based on assemblies and scripts
CN102722437A
Interface test case generation method, apparatus and device, and storage medium
CN112597018A