CN115309657A - Method, device, medium and program product for providing test case - Google Patents

Method, device, medium and program product for providing test case Download PDF

Info

Publication number
CN115309657A
CN115309657A CN202211055524.1A CN202211055524A CN115309657A CN 115309657 A CN115309657 A CN 115309657A CN 202211055524 A CN202211055524 A CN 202211055524A CN 115309657 A CN115309657 A CN 115309657A
Authority
CN
China
Prior art keywords
interface
request
test case
network
name
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211055524.1A
Other languages
Chinese (zh)
Inventor
李朋娟
曹卫娟
高艳
王瑞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Haende Technology Development Co ltd
Original Assignee
Shanghai Haende Technology Development Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Haende Technology Development Co ltd filed Critical Shanghai Haende Technology Development Co ltd
Priority to CN202211055524.1A priority Critical patent/CN115309657A/en
Publication of CN115309657A publication Critical patent/CN115309657A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases

Abstract

An object of the present application is to provide a method, an apparatus, a medium, and a program product for providing a test case, the method including: analyzing a description language document corresponding to at least one network service, and assembling interface request entities corresponding to one or more interfaces in at least one network service; and generating a test case file corresponding to at least one network service according to the interface request entity, and providing the test case file for a user. The assembled interface request entity is contained in the test case file, so that the test case file can be directly used as an interface request for a tester without any additional configuration, the test case file is quicker and more convenient, the test case file for the interface request response test is automatically generated based on the specification of the network request library, the time for the tester to analyze the interface request and the parameter type can be saved, the time for knowing the step of writing the test case in the network request library can be saved, and the tester can directly focus on the interface logic verification part.

Description

Method, device, medium and program product for providing test case
Technical Field
The present application relates to the field of communications, and in particular, to a technique for providing test cases.
Background
In the prior art, in the quality assurance process, interface testing is a key and core testing link for testing a back-end service API after UI interface testing, and the current interface testing has the testing requirements of a wsdl service interface besides a common Restful interface. For wsdl service interface, the common test mode is that the interface test tool (SoapUI, postman, etc.) supporting the soap protocol is used to make interface request and response acceptance and check the interface logic, and the separation test tool is used to make interface test through the maintenance automation script, which is relatively independent, flexible and highly extensible, so that the maintenance automation script is more and more popular at present.
Disclosure of Invention
It is an object of the present application to provide a method, apparatus, medium, and program product for providing test cases.
According to an aspect of the present application, there is provided a method for providing test cases, the method comprising:
analyzing a description language document corresponding to at least one network service, and assembling an interface request entity corresponding to one or more interfaces in the at least one network service;
and generating a test case file corresponding to the at least one network service according to the interface request entity, and providing the test case file for a user.
According to an aspect of the present application, there is provided a computer apparatus for providing test cases, the apparatus comprising:
a module for parsing a description language document corresponding to at least one network service and assembling interface request entities corresponding to one or more interfaces in the at least one network service;
and the second module is used for generating a test case file corresponding to the at least one network service according to the interface request entity and providing the test case file for a user.
According to an aspect of the present application, there is provided a computer device for providing test cases, comprising a memory, a processor and a computer program stored on the memory, wherein the processor executes the computer program to implement the operations of any of the methods described above.
According to an aspect of the application, there is provided a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, performs the operations of any of the methods described above.
According to an aspect of the application, a computer program product is provided, comprising a computer program which, when executed by a processor, carries out the steps of any of the methods as described above.
Compared with the prior art, the method and the device have the advantages that the description language document corresponding to at least one network service is analyzed, the interface request entity corresponding to one or more interfaces in at least one network service is assembled, the test case file corresponding to at least one network service is generated according to the interface request entity, and the test case file is provided for a user, so that the assembled interface request entity is contained in the test case file and provided for a tester to directly make an interface request without any additional configuration, the test case file is more convenient and rapid, the assembled interface request entity is of a dictionary data type, the tester can visually see which parameters are available, the tester can modify parameter values as required to make specific logic interface verification, the format of xml data is more visual and concise, the time for analyzing the interface request and the parameter types of the test case file for the interface request response test automatically generated based on the specification of the network request library can be saved, the time for writing the test case of the network request library can be saved, and the tester can directly pay attention to the interface logic part.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 illustrates a flow diagram of a method for providing test cases according to one embodiment of the present application;
FIG. 2 illustrates a block diagram of a computer device for providing test cases according to one embodiment of the present application;
FIG. 3 illustrates a presentation diagram for providing test cases according to one embodiment of the present application;
FIG. 4 illustrates a presentation diagram for providing test cases according to one embodiment of the present application;
FIG. 5 illustrates a presentation diagram for providing test cases according to one embodiment of the present application;
FIG. 6 illustrates a presentation diagram for providing test cases according to one embodiment of the present application;
FIG. 7 illustrates a presentation diagram for providing test cases according to one embodiment of the present application;
FIG. 8 illustrates a presentation diagram for providing test cases according to one embodiment of the present application;
FIG. 9 illustrates an exemplary system that can be used to implement the various embodiments described in this application.
The same or similar reference numbers in the drawings identify the same or similar elements.
Detailed Description
The present application is described in further detail below with reference to the attached figures.
In a typical configuration of the present application, the terminal, the device serving the network, and the trusted party each include one or more processors (e.g., central Processing Units (CPUs)), input/output interfaces, network interfaces, and memory.
The Memory may include forms of volatile Memory, random Access Memory (RAM), and/or non-volatile Memory in a computer-readable medium, such as Read Only Memory (ROM) or Flash Memory. Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase-Change Memory (PCM), programmable Random Access Memory (PRAM), static Random-Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash Memory or other Memory technology, compact Disc Read Only Memory (CD-ROM), digital Versatile Disc (DVD) or other optical storage, magnetic tape storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device.
The device referred to in the present application includes, but is not limited to, a terminal, a network device, or a device formed by integrating a terminal and a network device through a network. The terminal includes, but is not limited to, any mobile electronic product, such as a smart phone, a tablet computer, etc., capable of performing human-computer interaction with a user (e.g., human-computer interaction through a touch panel), and the mobile electronic product may employ any operating system, such as an Android operating system, an iOS operating system, etc. The network Device includes an electronic Device capable of automatically performing numerical calculation and information processing according to a preset or stored instruction, and the hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded Device, and the like. The network device includes but is not limited to a computer, a network host, a single network server, a plurality of network server sets or a cloud of a plurality of servers; here, the Cloud is composed of a large number of computers or network servers based on Cloud Computing (Cloud Computing), which is a kind of distributed Computing, one virtual supercomputer consisting of a collection of loosely coupled computers. Including, but not limited to, the internet, a wide area network, a metropolitan area network, a local area network, a VPN network, a wireless Ad Hoc network (Ad Hoc network), etc. Preferably, the device may also be a program running on the terminal, the network device, or a device formed by integrating the terminal and the network device, the touch terminal, or the network device and the touch terminal through a network.
Of course, those skilled in the art will appreciate that the foregoing is by way of example only, and that other existing or future devices, which may be suitable for use in the present application, are also encompassed within the scope of the present application and are hereby incorporated by reference.
In the description of the present application, "a plurality" means two or more unless specifically defined otherwise.
Fig. 1 shows a flowchart of a method for providing test cases according to an embodiment of the present application, where the method includes step S11 and step S12. In step S11, the computer device parses a description language document corresponding to at least one network service, and assembles an interface request entity corresponding to one or more interfaces in the at least one network service; in step S12, the computer device generates a test case file corresponding to the at least one network service according to the interface request entity, and provides the test case file to the user.
In step S11, the computer device parses a description language document corresponding to at least one network service, and assembles an interface request entity corresponding to one or more interfaces in the at least one network service. In some embodiments, a Web Services Description Language (wsdl) document is a document written in XML, and each Web Services Description Language document corresponds to a Web service, and the Web Services Description Language document is used for describing the Web service and how to access the Web service, and can describe an interface provided by the Web service, a location of the interface, and how to access (call) the interface. In some embodiments, the web services description language document includes a plurality of nodes of different types, the nodes being organized in a tree data structure, and the web services description language describing a web service using the nodes. In some embodiments, a link address of a web service description language document is obtained, the web service description language document is loaded according to the link address and a node tree structure in the web service description language document is parsed by using a predetermined parsing library (e.g., zeep is available in a library for parsing the web service description language document based on python 3), an interface request entity corresponding to each interface defined in the at least one web service is determined according to one or more nodes in the node tree structure, for example, an interface request entity corresponding to a certain interface is assembled according to node content and/or node attributes of one or more nodes in the node tree structure, for example, one or more nodes related to a certain interface are determined in the node tree structure, and an interface request entity corresponding to a certain interface is assembled according to node content and/or node attributes of the one or more nodes, wherein each interface request entity includes, but is not limited to, an interface request parameter body, an interface response parameter body, interface name information, and interface request path information corresponding to the certain interface. In some embodiments, the assembled interface request entity is a Dict dictionary data type of python, the service name of each web service is referred to as key data, the corresponding value data is a nested Dict dictionary data type, the nested Dict dictionary data type is the interface name of each interface in the web service is referred to as key data, and the corresponding value data is an interface request entity corresponding to the interface, so that a tester can visually see which parameters are available, and can modify parameter values as needed to perform specific logical interface verification, which is more visual and concise compared with an xml data format.
In step S12, the computer device generates a test case file corresponding to the at least one network service according to the interface request entity, and provides the test case file to the user. In some embodiments, according to the interface request entity corresponding to each of the one or more interfaces, a corresponding test case file (e.g., python file) for interface request response test is automatically generated based on a specification of a predetermined network request library, where the test case file includes interface test case scripts, each interface test case script corresponds to one interface and is used for request response test of the interface, where each network service may correspond to one test case file, that is, each test case file includes only one interface test case script corresponding to each interface defined by one network service, respectively, or at least one network service may correspond to one test case file, that is, the test case file includes interface test case scripts corresponding to each interface defined by the at least one network service, respectively. In some embodiments, a download link for the test case file may be presented to the user, and the user may download the test case file based on the download link. In some embodiments, the downloaded test case file may be used as an independent script, and the user may input or modify a request parameter value of the interface test in the independent script as needed, and then directly execute the independent script locally to verify the interface response (either executing the independent script in a cmd window or a python tool), or the user may also select to refer the test case file to a place where the existing test item (e.g., unittest/pytest automation test item) needs to be used for a logic test of the interface request response. The assembled interface request entity is contained in the test case file, the interface request can be directly made for a tester without any additional configuration, the test case file is more rapid and convenient, the assembled interface request entity is of a dictionary data type, the tester can conveniently and visually see which parameters exist, accordingly, parameter values are modified as required to make specific logic interface verification, the test case file is more visual and concise compared with an xml data format, the test case file for interface request response test automatically generated based on the specification of a network request library can save the time for the tester to analyze the interface request and the parameter type, the time for the tester to write the test case step familiar to the network request library can be saved, and the tester can directly focus on the interface logic verification part.
In some embodiments, the method further comprises: and responding to the module identification information input by the user by the computer equipment, and providing a description page of one or more network services corresponding to the module identification information to the user. In some embodiments, each module corresponds to one or more web services, and in response to the module identification information input by the user, a description page (e.g., html page) of the one or more web services corresponding to the module identification information is presented for the user to access, where the description page includes a set of link addresses of one or more description language documents corresponding to the one or more web services, and the user opens a link address of a certain description language document and can view specific document content of the description language document in xml data format. In some embodiments, the one or more network services are the at least one network service described above, or the user needs to select the test case file corresponding to the at least one network service generator in the one or more network devices. As one example, as shown in FIG. 3, a user enters a payment number identifier (module identification information) and then clicks a "view interface" button, and the page loads a link address of a description page of one or more network services corresponding to the identifier for the user to view and access.
In some embodiments, the description page includes a service name of each web service, an interface name of at least one interface defined by each web service, and a link address of a description language document corresponding to each web service. As an example, as shown in fig. 4, the description page presents, in a list form, a service name of each web service, an interface name of each interface defined by the web service, and a link address of a description language document corresponding to the web service.
In some embodiments, the method further comprises: the computer device obtains at least one network service selected by the user from the one or more network services. In some embodiments, the service name of the one or more network services is first presented to the user, the service name is a unique identifier for each network service, and the user can select at least one network service in the one or more network services for which the corresponding test case file needs to be generated. As an example, as shown in fig. 5, clicking a "view interface" button after the user inputs a payment number (module identification information) may show the service name of each of the one or more web services in a drop-down list of "please select the interface", where the loaded service name is given by "? The wsdl "suffix end identifier is a descriptive language document parsing corresponding to the wsdl web service, and the user may select at least one of the one or more web services, with ALL of the one or more web services being selected as" ALL "by default.
In some embodiments, the test case file includes an interface test case script corresponding to each interface in the at least one web service. In some embodiments, only one test case file may be generated for the at least one web service, that is, the test case file includes an interface test case script corresponding to each interface defined by the at least one web service. As an example, as shown in fig. 6, when the user selects only one web service, selects the output file type to be "python", and then clicks the "create file" button, a link address of a test case file corresponding to the web service is output, where the test case file only includes an interface test case script corresponding to each interface in the web service. As an example, as shown in fig. 7, when the user selects all the web services "AL L", selects the output file type to be "python", and then clicks the "create file" button, a link address of a test case file corresponding to all the web services is output, where the test case file only includes an interface test case script corresponding to each interface in all the web services.
In some embodiments, the test case files are multiple, each test case file corresponds to one web service, and each test case file includes an interface test case script corresponding to each interface in the one web service. In some embodiments, the test case file corresponding to each web service generator may be respectively used, that is, each test case file only includes an interface test case script corresponding to each interface defined by its corresponding web service. As an example, as shown in fig. 8, when the user selects ALL web services "ALL" and selects the output file type to be "ZIP", and then clicks the "create file" button, the link address of a compressed package file (e.g., a ZIP file) is output, the compressed package file after being decompressed contains a plurality of test case files, each test case file corresponds to one web service, and each test case file includes an interface test case script corresponding to each interface in its corresponding web service.
In some embodiments, the interface requesting entity comprises at least one of: interface name information; an interface request parameter body; an interface response parameter body; the interface requests path information. In some embodiments, each interface corresponds to a different, unique interface name information. In some embodiments, the interface request parameter body corresponding to each interface includes, but is not limited to, a request parameter name, a request parameter type, a request parameter default value, and the like corresponding to the interface. In some embodiments, the interface response parameter body corresponding to each interface includes, but is not limited to, a response parameter name, a response parameter type, and the like corresponding to the interface.
In some embodiments, the interface request entity comprises an interface request parameter body; wherein the step S11 includes: the method comprises the steps that computer equipment analyzes a description language document corresponding to at least one network service to obtain interface nodes corresponding to one or more interfaces in the description language document and enumeration value sequences corresponding to limiting child nodes under one or more simple type nodes; for each interface in the one or more interfaces, according to a request element in an interface node corresponding to the interface, at least one enumeration value matched with a type name corresponding to the request element is searched in the enumeration value sequence, and according to an element name of the request element and the at least one enumeration value, an interface request parameter body corresponding to the interface is assembled. In some embodiments, an interface node, i.e., an operation node, under a root node in a node tree structure of the web service description language document is obtained, each interface node corresponds to an interface, one or more simple type nodes, i.e., simpleType nodes, under the root node are obtained, if a child node exists under a certain simpleType node and is a constraint node, i.e., a restart node, all enumeration nodes, i.e., enumeration nodes, under the restart node are traversed, and the node name of the simpleType node and the node value of each enumeration node under the simpleType node are placed in a value sequence. In some embodiments, the enumeration value sequence stores a mapping relationship between a node name and a node value, and one or more node values corresponding to a certain node name may be found in the enumeration value sequence, for example, the enumeration value sequence includes one or more key value pairs (e.g., a ditt dictionary data structure), key data (key) of each key value pair is a node name of a simple type node, and value data (value) of the key value pair is a list data structure or an array data structure composed of node values of one or more enumeration nodes under the simple type node. In some embodiments, for each interface, according to a request element (input element) in an interface node corresponding to the interface, at least one enumeration value corresponding to a type name corresponding to the request element (i.e., a node value of an enumeration node) is searched in the enumeration value sequence, and then, according to the element name of the request element and the at least one enumeration value, an interface request parameter body corresponding to the interface is assembled, for example, according to the element name of the request element, an enumeration value arranged at the head in the at least one enumeration value is assigned to the request element, and thus, the interface request parameter body corresponding to the interface is assembled.
In some embodiments, for each interface of the one or more interfaces, according to a request element in an interface node corresponding to the interface, at least one enumeration value matched with a type name corresponding to the request element is searched in the enumeration value sequence, and according to an element name of the request element and the at least one enumeration value, an interface request parameter body corresponding to the interface is assembled, including: for each interface in the at least one network service, if the element type corresponding to the request element in the interface node corresponding to the interface is a first simple type, searching at least one first enumeration value matched with the type name of the first simple type in the enumeration value sequence, and assembling an interface request parameter body corresponding to the interface according to the element name of the request element and the at least one first enumeration value. In some embodiments, for each interface, if an element type corresponding to a request element in an interface node corresponding to the interface is a simple type, at least one enumeration value corresponding to a type name of the simple type is searched in the enumeration value sequence, and then an interface request parameter body corresponding to the interface is assembled according to the element name of the request element and the at least one enumeration value.
In some embodiments, the method further comprises: if the element type corresponding to the request element is a complex type, acquiring at least one sub-request element, nested in the request element, of which the corresponding element type is a second simple type, searching at least one second enumeration value matched with the type name of the second simple type in the enumeration value sequence, and assembling an interface request parameter body corresponding to the interface according to the element name of the request element, the element name of the sub-request element and the at least one second enumeration value. In some embodiments, for each interface, if an element type corresponding to a request element in an interface node corresponding to the interface is a complex type, obtaining at least one sub-request element, of which a corresponding element type nested by the request element is a simple type, where the element type corresponding to the request element is a simple type (for example, according to a type name of the complex type, obtaining a complex type node corresponding to a root node, and if a sequence node, that is, a sequence node, exists below the complex type node, obtaining at least one sub-request element, of which a corresponding element type is a simple type, for a certain sub-request element, if the element type corresponding to the sub-request element is a target simple type, searching at least one enumeration value corresponding to the type name of the target simple type in the enumeration value sequence, and then assembling an interface request parameter body corresponding to the interface according to the element name of the request element, the element name of the at least one sub-request element, and the at least one enumeration value, for example, assigning an enumeration value arranged at the head in the at least one enumeration value to the sub-request element.
In some embodiments, the interface requesting entity further comprises interface name information; wherein the method further comprises: and for each interface in the one or more interfaces, the computer equipment determines the interface name information corresponding to the interface according to the node name of the interface node corresponding to the interface. In some embodiments, for each interface, the node name of the interface node corresponding to the interface may be used as the interface name information corresponding to the interface.
In some embodiments, the interface request entity includes interface name information and an interface request parameter body; generating a test case file corresponding to the at least one network service according to the interface request entity includes: and calling a preset network request method in the test case file corresponding to the at least one network service, and transmitting the interface name information and the interface request parameter body to the network request method. In some embodiments, the test case file includes an interface test case script corresponding to each interface defined in the at least one network service, and for the interface test case script corresponding to each interface, a predetermined network request method is called in the script, and interface name information and an interface request parameter body corresponding to the interface are transmitted into the network request method as method transmission parameters, so as to complete a network request and an acquisition response of the interface.
In some embodiments, the invoking a predetermined network request method in the test case file corresponding to the at least one network service, and transferring the interface name information and the interface request parameter body to the network request method includes: in the test case file corresponding to the at least one network service, acquiring an initialization object corresponding to the description language document based on the link address of the description language document; and calling a preset network request method through the initialization object, and transmitting the interface name information and the interface request parameter body into the network request method. In some embodiments, an initialization object corresponding to the description language document is instantiated in the test case file based on the link address of the description language document, for example, the initialization object is a wsdlInit object based on zeep secondary encapsulation, the instantiation object needs the link address of the description language document, or a Settings entry parameter (the Settings parameter is a parameter about kwards type, and if necessary, a parameter about Settings is), the initialization object includes a predetermined network request method (for example, a call method), the network request method is called through the initialization object, and the interface name information and the interface request parameter body corresponding to the interface are transmitted to the network request method as method incoming parameters, so as to complete the network request and the acquisition response of the interface.
In some embodiments, the interface request entity comprises an interface request parameter body; wherein the method further comprises: the computer equipment obtains a client object corresponding to the description language document based on the link address of the description language document; and based on the client object, generating corresponding xml format request data according to the interface request parameter body, and providing the xml format request data for the user. In some embodiments, a client object (e.g., zeep) corresponding to the description language document may be initialized first based on a link address of the description language document, and then the interface request parameter body is transmitted to the predetermined method as a method transmission parameter by calling a predetermined method (e.g., object _ zeep _ soap request msg method) encapsulated in the client object, so as to obtain xml format request data, which is an output result of the predetermined method, where the xml format request data is generally applicable to a scenario requiring secondary confirmation of a request body to assist in tracking a location interface anomaly, so that a tester may selectively use the xml format request data as needed, and the xml format request data is flexible in use, and then a download link of the xml format request data is presented to a user, and the user may download the xml format request data based on the download link.
Fig. 2 is a block diagram of a computer device for providing test cases according to an embodiment of the present application, the device including a one-module 11 and a two-module 12. A module 11, configured to parse a description language document corresponding to at least one network service, and assemble an interface request entity corresponding to one or more interfaces in the at least one network service; and a secondary module 12, configured to generate a test case file corresponding to the at least one network service according to the interface request entity, and provide the test case file to a user.
A module 11, configured to parse a description language document corresponding to at least one network service, and assemble an interface request entity corresponding to one or more interfaces in the at least one network service. In some embodiments, a Web Services Description Language (wsdl) document is a document written in XML, and each Web Services Description Language document corresponds to a Web service, and the Web Services Description Language document is used for describing the Web service and how to access the Web service, and can describe an interface provided by the Web service, a location of the interface, and how to access (call) the interface. In some embodiments, the web services description language document includes a plurality of nodes of different types, the nodes being organized in a tree data structure, and the web services description language describing a web service using the nodes. In some embodiments, a link address of a web service description language document is obtained, the web service description language document is loaded according to the link address and a node tree structure in the web service description language document is parsed by using a predetermined parsing library (e.g., zeep is available in a library for parsing the web service description language document based on python 3), an interface request entity corresponding to each interface defined in the at least one web service is determined according to one or more nodes in the node tree structure, for example, an interface request entity corresponding to a certain interface is assembled according to node content and/or node attributes of one or more nodes in the node tree structure, for example, one or more nodes related to a certain interface are determined in the node tree structure, and an interface request entity corresponding to a certain interface is assembled according to node content and/or node attributes of the one or more nodes, wherein each interface request entity includes, but is not limited to, an interface request parameter body, an interface response parameter body, interface name information, and interface request path information corresponding to the certain interface. In some embodiments, the assembled interface request entity is a Dict dictionary data type of python, the service name of each web service is referred to as key data, the corresponding value data is a nested Dict dictionary data type, the nested Dict dictionary data type is the interface name of each interface in the web service is referred to as key data, and the corresponding value data is an interface request entity corresponding to the interface, so that a tester can visually see which parameters are available, and can modify parameter values as needed to perform specific logical interface verification, which is more visual and concise compared with an xml data format.
And a second module 12, configured to generate a test case file corresponding to the at least one network service according to the interface request entity, and provide the test case file to a user. In some embodiments, according to the interface request entity corresponding to each of the one or more interfaces, a corresponding test case file (e.g., python file) for interface request response test is automatically generated based on a specification of a predetermined network request library, where the test case file includes interface test case scripts, each interface test case script corresponds to one interface and is used for request response test of the interface, where each network service may correspond to one test case file, that is, each test case file includes only one interface test case script corresponding to each interface defined by one network service, respectively, or at least one network service may correspond to one test case file, that is, the test case file includes interface test case scripts corresponding to each interface defined by the at least one network service, respectively. In some embodiments, a download link for the test case file may be presented to the user, and the user may download the test case file based on the download link. In some embodiments, the downloaded test case file may be used as an independent script, and the user may input or modify a request parameter value of the interface test in the independent script as needed, and then directly execute the independent script locally to verify the interface response (either executing the independent script in a cmd window or a python tool), or the user may also select to refer the test case file to a place where the existing test item (e.g., unittest/pytest automation test item) needs to be used for a logic test of the interface request response. The assembled interface request entity is contained in the test case file, the interface request can be directly made for a tester without any additional configuration, the test case file is more rapid and convenient, the assembled interface request entity is of a dictionary data type, the tester can conveniently and visually see which parameters exist, accordingly, parameter values are modified as required to make specific logic interface verification, the test case file is more visual and concise compared with an xml data format, the test case file for interface request response test automatically generated based on the specification of a network request library can save the time for the tester to analyze the interface request and the parameter type, the time for the tester to write the test case step familiar to the network request library can be saved, and the tester can directly focus on the interface logic verification part.
In some embodiments, the apparatus is further configured to: and responding to the module identification information input by the user, and providing a description page of one or more network services corresponding to the module identification information to the user. Here, the related operations are the same as or similar to those of the embodiment shown in fig. 1, and therefore are not described again, and are included herein by reference.
In some embodiments, the description page includes a service name of each web service, an interface name of at least one interface defined by each web service, and a link address of a description language document corresponding to each web service. Here, the related operations are the same as or similar to those of the embodiment shown in fig. 1, and therefore are not described again, and are included herein by reference.
In some embodiments, the apparatus is further configured to: and acquiring at least one network service selected by the user from the one or more network services. Here, the related operations are the same as or similar to those of the embodiment shown in fig. 1, and thus are not described again, and are included herein by reference.
In some embodiments, the test case file includes an interface test case script corresponding to each interface in the at least one web service. Here, the related operations are the same as or similar to those of the embodiment shown in fig. 1, and therefore are not described again, and are included herein by reference.
In some embodiments, the test case files are multiple, each test case file corresponds to one web service, and each test case file includes an interface test case script corresponding to each interface in the one web service. Here, the related operations are the same as or similar to those of the embodiment shown in fig. 1, and thus are not described again, and are included herein by reference.
In some embodiments, the interface requesting entity comprises at least one of: interface name information; an interface request parameter body; an interface response parameter body; the interface requests path information. Here, the related operations are the same as or similar to those of the embodiment shown in fig. 1, and therefore are not described again, and are included herein by reference.
In some embodiments, the interface request entity comprises an interface request parameter body; wherein, the one-to-one module 11 is configured to: analyzing a description language document corresponding to at least one network service to obtain interface nodes corresponding to one or more interfaces in the description language document and enumeration value sequences corresponding to limiting child nodes under one or more simple type nodes; for each interface in the one or more interfaces, according to a request element in an interface node corresponding to the interface, at least one enumeration value matched with a type name corresponding to the request element is searched in the enumeration value sequence, and according to an element name of the request element and the at least one enumeration value, an interface request parameter body corresponding to the interface is assembled. Here, the related operations are the same as or similar to those of the embodiment shown in fig. 1, and therefore are not described again, and are included herein by reference.
In some embodiments, for each interface of the one or more interfaces, according to a request element in an interface node corresponding to the interface, at least one enumeration value matched with a type name corresponding to the request element is searched in the enumeration value sequence, and according to an element name of the request element and the at least one enumeration value, an interface request parameter body corresponding to the interface is assembled, including: for each interface in the at least one network service, if the element type corresponding to the request element in the interface node corresponding to the interface is a first simple type, at least one first enumeration value matched with the type name of the first simple type is searched in the enumeration value sequence, and an interface request parameter body corresponding to the interface is assembled according to the element name of the request element and the at least one first enumeration value. Here, the related operations are the same as or similar to those of the embodiment shown in fig. 1, and therefore are not described again, and are included herein by reference.
In some embodiments, the apparatus is further configured to: if the element type corresponding to the request element is a complex type, acquiring at least one sub-request element, nested in the request element, of which the corresponding element type is a second simple type, searching at least one second enumeration value matched with the type name of the second simple type in the enumeration value sequence, and assembling an interface request parameter body corresponding to the interface according to the element name of the request element, the element name of the sub-request element and the at least one second enumeration value. Here, the related operations are the same as or similar to those of the embodiment shown in fig. 1, and therefore are not described again, and are included herein by reference.
In some embodiments, the interface requesting entity further comprises interface name information; wherein the device is further configured to: and for each interface in the one or more interfaces, determining the interface name information corresponding to the interface according to the node name of the interface node corresponding to the interface. Here, the related operations are the same as or similar to those of the embodiment shown in fig. 1, and therefore are not described again, and are included herein by reference.
In some embodiments, the interface request entity includes interface name information and an interface request parameter body; generating a test case file corresponding to the at least one network service according to the interface request entity includes: and calling a preset network request method in the test case file corresponding to the at least one network service, and transmitting the interface name information and the interface request parameter body to the network request method. Here, the related operations are the same as or similar to those of the embodiment shown in fig. 1, and thus are not described again, and are included herein by reference.
In some embodiments, the invoking a predetermined network request method in the test case file corresponding to the at least one network service, and transferring the interface name information and the interface request parameter body to the network request method includes: in the test case file corresponding to the at least one network service, acquiring an initialization object corresponding to the description language document based on the link address of the description language document; and calling a preset network request method through the initialization object, and transmitting the interface name information and the interface request parameter body into the network request method. Here, the related operations are the same as or similar to those of the embodiment shown in fig. 1, and thus are not described again, and are included herein by reference.
In some embodiments, the interface request entity comprises an interface request parameter body; wherein the device is further configured to: obtaining a client object corresponding to the description language document based on the link address of the description language document; and based on the client object, generating corresponding xml format request data according to the interface request parameter body, and providing the xml format request data for the user. Here, the related operations are the same as or similar to those of the embodiment shown in fig. 1, and therefore are not described again, and are included herein by reference.
In addition to the methods and apparatus described in the embodiments above, the present application also provides a computer readable storage medium storing computer code that, when executed, performs the method as described in any of the preceding claims.
The present application also provides a computer program product, which when executed by a computer device, performs the method of any of the preceding claims.
The present application further provides a computer device, comprising:
one or more processors;
a memory for storing one or more computer programs;
the one or more computer programs, when executed by the one or more processors, cause the one or more processors to implement the method of any preceding claim.
FIG. 9 illustrates an exemplary system that can be used to implement the various embodiments described herein;
in some embodiments, as shown in FIG. 9, the system 300 can be implemented as any of the devices in the various embodiments described. In some embodiments, system 300 may include one or more computer-readable media (e.g., system memory or NVM/storage 320) having instructions and one or more processors (e.g., processor(s) 305) coupled with the one or more computer-readable media and configured to execute the instructions to implement modules to perform the actions described herein.
For one embodiment, system control module 310 may include any suitable interface controllers to provide any suitable interface to at least one of processor(s) 305 and/or any suitable device or component in communication with system control module 310.
The system control module 310 may include a memory controller module 330 to provide an interface to the system memory 315. Memory controller module 330 may be a hardware module, a software module, and/or a firmware module.
System memory 315 may be used, for example, to load and store data and/or instructions for system 300. For one embodiment, system memory 315 may include any suitable volatile memory, such as suitable DRAM. In some embodiments, the system memory 315 may include a double data rate type four synchronous dynamic random access memory (DDR 4 SDRAM).
For one embodiment, system control module 310 may include one or more input/output (I/O) controllers to provide an interface to NVM/storage 320 and communication interface(s) 325.
For example, NVM/storage 320 may be used to store data and/or instructions. NVM/storage 320 may include any suitable non-volatile memory (e.g., flash memory) and/or may include any suitable non-volatile storage device(s) (e.g., one or more Hard Disk Drives (HDDs), one or more Compact Disc (CD) drives, and/or one or more Digital Versatile Disc (DVD) drives).
NVM/storage 320 may include storage resources that are physically part of the device on which system 300 is installed or may be accessed by the device and not necessarily part of the device. For example, NVM/storage 320 may be accessible over a network via communication interface(s) 325.
Communication interface(s) 325 may provide an interface for system 300 to communicate over one or more networks and/or with any other suitable device. System 300 may wirelessly communicate with one or more components of a wireless network according to any of one or more wireless network standards and/or protocols.
For one embodiment, at least one of the processor(s) 305 may be assembled with logic of one or more controllers (e.g., memory controller module 330) of the system control module 310. For one embodiment, at least one of the processor(s) 305 may be assembled with logic of one or more controllers of the system control module 310 to form a System In Package (SiP). For one embodiment, at least one of the processor(s) 305 may be integrated on the same die with logic for one or more controller(s) of the system control module 310. For one embodiment, at least one of the processor(s) 305 may be integrated on the same die with logic for one or more controller(s) of the system control module 310 to form a system on a chip (SoC).
In various embodiments, system 300 may be, but is not limited to being: a server, a workstation, a desktop computing device, or a mobile computing device (e.g., a laptop computing device, a handheld computing device, a tablet, a netbook, etc.). In various embodiments, system 300 may have more or fewer components and/or different architectures. For example, in some embodiments, system 300 includes one or more cameras, a keyboard, a Liquid Crystal Display (LCD) screen (including a touch screen display), a non-volatile memory port, multiple antennas, a graphics chip, an Application Specific Integrated Circuit (ASIC), and speakers.
It should be noted that the present application may be implemented in software and/or a combination of software and hardware, for example, implemented using Application Specific Integrated Circuits (ASICs), general purpose computers or any other similar hardware devices. In one embodiment, the software programs of the present application may be executed by a processor to implement the steps or functions described above. Likewise, the software programs (including associated data structures) of the present application may be stored in a computer readable recording medium, such as RAM memory, magnetic or optical drive or diskette and the like. Additionally, some of the steps or functions of the present application may be implemented in hardware, for example, as circuitry that cooperates with the processor to perform various steps or functions.
In addition, some of the present application may be implemented as a computer program product, such as computer program instructions, which when executed by a computer, may invoke or provide methods and/or techniques in accordance with the present application through the operation of the computer. Those skilled in the art will appreciate that the form in which the computer program instructions reside on a computer-readable medium includes, but is not limited to, source files, executable files, installation package files, and the like, and that the manner in which the computer program instructions are executed by a computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. In this regard, computer readable media can be any available computer readable storage media or communication media that can be accessed by a computer.
Communication media includes media by which communication signals, including, for example, computer readable instructions, data structures, program modules, or other data, are transmitted from one system to another. Communication media may include conductive transmission media such as cables and wires (e.g., fiber optics, coaxial, etc.) and wireless (non-conductive transmission) media capable of propagating energy waves such as acoustic, electromagnetic, RF, microwave, and infrared. Computer readable instructions, data structures, program modules, or other data may be embodied in a modulated data signal, for example, in a wireless medium such as a carrier wave or similar mechanism such as is embodied as part of spread spectrum techniques. The term "modulated data signal" means a signal that has one or more of its characteristics set or changed in such a manner as to encode information in the signal. The modulation may be analog, digital, or hybrid modulation techniques.
By way of example, and not limitation, computer-readable storage media may include volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer-readable instructions, data structures, program modules or other data. For example, computer-readable storage media include, but are not limited to, volatile memory such as random access memory (RAM, DRAM, SRAM); and non-volatile memory such as flash memory, various read-only memories (ROM, PROM, EPROM, EEPROM), magnetic and ferromagnetic/ferroelectric memories (MRAM, feRAM); and magnetic and optical storage devices (hard disk, tape, CD, DVD); or other now known media or later developed that can store computer-readable information/data for use by a computer system.
An embodiment according to the present application comprises an apparatus comprising a memory for storing computer program instructions and a processor for executing the program instructions, wherein the computer program instructions, when executed by the processor, trigger the apparatus to perform a method and/or a solution according to the aforementioned embodiments of the present application.
It will be evident to those skilled in the art that the present application is not limited to the details of the foregoing illustrative embodiments, and that the present application may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the apparatus claims may also be implemented by one unit or means in software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.

Claims (17)

1. A method for providing test cases, wherein the method comprises:
analyzing a description language document corresponding to at least one network service, and assembling interface request entities corresponding to one or more interfaces in the at least one network service;
and generating a test case file corresponding to the at least one network service according to the interface request entity, and providing the test case file for a user.
2. The method of claim 1, wherein the method further comprises:
and responding to the module identification information input by the user, and providing a description page of one or more network services corresponding to the module identification information to the user.
3. The method of claim 2, wherein the description page comprises a service name of each web service, an interface name of at least one interface defined by each web service, and a link address of a description language document corresponding to each web service.
4. The method of claim 2, wherein the method further comprises:
and acquiring at least one network service selected by the user from the one or more network services.
5. The method of claim 2, wherein the test case file comprises an interface test case script corresponding to each interface in the at least one web service.
6. The method according to claim 2, wherein the number of the test case files is multiple, each test case file corresponds to one web service, and each test case file includes an interface test case script corresponding to each interface in the one web service.
7. The method of claim 1, wherein the interface requesting entity comprises at least one of:
interface name information;
an interface request parameter body;
an interface response parameter body;
the interface requests path information.
8. The method of claim 7, wherein the interface request entity comprises an interface request parameter body;
the parsing a description language document corresponding to at least one network service, and assembling an interface request entity corresponding to one or more interfaces in the at least one network service includes:
analyzing a description language document corresponding to at least one network service to obtain interface nodes corresponding to one or more interfaces in the description language document and enumeration value sequences corresponding to limiting child nodes under one or more simple type nodes;
for each interface in the one or more interfaces, according to a request element in an interface node corresponding to the interface, at least one enumeration value matched with a type name corresponding to the request element is searched in the enumeration value sequence, and according to an element name of the request element and the at least one enumeration value, an interface request parameter body corresponding to the interface is assembled.
9. The method according to claim 8, wherein for each of the one or more interfaces, according to a request element in an interface node corresponding to the interface, at least one enumeration value matching a type name corresponding to the request element is searched in the enumeration value sequence, and according to an element name of the request element and the at least one enumeration value, an interface request parameter body corresponding to the interface is assembled, including:
for each interface in the at least one network service, if the element type corresponding to the request element in the interface node corresponding to the interface is a first simple type, at least one first enumeration value matched with the type name of the first simple type is searched in the enumeration value sequence, and an interface request parameter body corresponding to the interface is assembled according to the element name of the request element and the at least one first enumeration value.
10. The method of claim 9, wherein the method further comprises:
if the element type corresponding to the request element is a complex type, acquiring at least one sub-request element, nested in the request element, of which the corresponding element type is a second simple type, searching at least one second enumeration value matched with the type name of the second simple type in the enumeration value sequence, and assembling an interface request parameter body corresponding to the interface according to the element name of the request element, the element name of the sub-request element and the at least one second enumeration value.
11. The method of claim 8, wherein the interface requesting entity further comprises interface name information;
wherein the method further comprises:
and for each interface in the one or more interfaces, determining the interface name information corresponding to the interface according to the node name of the interface node corresponding to the interface.
12. The method of claim 7, wherein the interface request entity comprises interface name information and an interface request parameter body;
generating a test case file corresponding to the at least one network service according to the interface request entity includes:
and calling a preset network request method in the test case file corresponding to the at least one network service, and transmitting the interface name information and the interface request parameter body to the network request method.
13. The method according to claim 12, wherein the invoking a predetermined network request method in the test case file corresponding to the at least one network service, and transferring the interface name information and the interface request parameter body to the network request method comprises:
in the test case file corresponding to the at least one network service, acquiring an initialization object corresponding to the description language document based on the link address of the description language document;
and calling a preset network request method through the initialization object, and transmitting the interface name information and the interface request parameter body into the network request method.
14. The method of claim 7, wherein the interface request entity comprises an interface request parameter body;
wherein the method further comprises:
obtaining a client object corresponding to the description language document based on the link address of the description language document;
and based on the client object, generating corresponding xml format request data according to the interface request parameter body, and providing the xml format request data for the user.
15. A computer device for providing test cases, comprising a memory, a processor and a computer program stored on the memory, characterized in that the processor executes the computer program to implement the steps of the method according to any of claims 1 to 14.
16. A computer-readable storage medium, on which a computer program/instructions are stored, which, when being executed by a processor, carry out the steps of the method according to any one of claims 1 to 14.
17. A computer program product comprising a computer program, characterized in that the computer program realizes the steps of the method according to any one of claims 1 to 14 when executed by a processor.
CN202211055524.1A 2022-08-31 2022-08-31 Method, device, medium and program product for providing test case Pending CN115309657A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211055524.1A CN115309657A (en) 2022-08-31 2022-08-31 Method, device, medium and program product for providing test case

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211055524.1A CN115309657A (en) 2022-08-31 2022-08-31 Method, device, medium and program product for providing test case

Publications (1)

Publication Number Publication Date
CN115309657A true CN115309657A (en) 2022-11-08

Family

ID=83864559

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211055524.1A Pending CN115309657A (en) 2022-08-31 2022-08-31 Method, device, medium and program product for providing test case

Country Status (1)

Country Link
CN (1) CN115309657A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117520210A (en) * 2024-01-05 2024-02-06 芯瞳半导体技术(山东)有限公司 System software testing method, target machine and remote testing central control machine

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117520210A (en) * 2024-01-05 2024-02-06 芯瞳半导体技术(山东)有限公司 System software testing method, target machine and remote testing central control machine
CN117520210B (en) * 2024-01-05 2024-04-16 芯瞳半导体技术(山东)有限公司 System software testing method, target machine and remote testing central control machine

Similar Documents

Publication Publication Date Title
WO2018223717A1 (en) Webpage front-end testing method, device, system, apparatus and readable storage medium
CN106874174B (en) Method and device for realizing interface test and function test
CN109062563B (en) Method and device for generating page
CN109359237B (en) Method and equipment for searching hosted program
CN110290557B (en) Method and equipment for loading page tags in application
CN111212183B (en) Method, device and computer readable medium for running hosted application
CN111427650A (en) Method and equipment for providing presence information
CN113254813B (en) Short link generation method, device, server and computer readable medium
CN110519250B (en) Method and equipment for providing information flow
CN109710832B (en) Method and equipment for searching hosted program
CN115309657A (en) Method, device, medium and program product for providing test case
CN116561013B (en) Testing method and device based on target service framework, electronic equipment and medium
CN109144864B (en) Method and device for testing window
KR20180076020A (en) Apparatus and method for application test automation
CN107247661B (en) Method and system for supporting automatic verification of installation package of application
CN114661593A (en) Method, device, medium and program product for automated testing
CN110554892A (en) Information acquisition method and device
CN110333914B (en) Method and device for executing target operation
CN109245938B (en) Method and equipment for executing resource configuration operation of user
CN111078654A (en) Method and equipment for sharing information
CN115269440A (en) Method, apparatus, medium, and program product for providing interface test case
CN113821430A (en) Multi-service testing method and device
CN113704079A (en) Interface testing method and device based on Protobuf
CN112241499A (en) Native rendering method and device based on information flow
CN113505036B (en) Application monitoring method, client and server

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination