CN113407444B - Interface test case generation method, device, equipment and storage medium - Google Patents

Interface test case generation method, device, equipment and storage medium Download PDF

Info

Publication number
CN113407444B
CN113407444B CN202110619074.3A CN202110619074A CN113407444B CN 113407444 B CN113407444 B CN 113407444B CN 202110619074 A CN202110619074 A CN 202110619074A CN 113407444 B CN113407444 B CN 113407444B
Authority
CN
China
Prior art keywords
input parameter
input
interface
test case
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.)
Active
Application number
CN202110619074.3A
Other languages
Chinese (zh)
Other versions
CN113407444A (en
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.)
Zhongke Shuguang International Information Industry Co ltd
Original Assignee
Zhongke Shuguang International Information Industry 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 Zhongke Shuguang International Information Industry Co ltd filed Critical Zhongke Shuguang International Information Industry Co ltd
Priority to CN202110619074.3A priority Critical patent/CN113407444B/en
Publication of CN113407444A publication Critical patent/CN113407444A/en
Application granted granted Critical
Publication of CN113407444B publication Critical patent/CN113407444B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the invention discloses a test case generation method, a device, equipment and a storage medium of an interface, wherein the method comprises the steps of receiving an interface description document and setting a corresponding number for an interface in the interface description document; reading necessary description information of an interface in an interface description document, and generating the name of a test case based on the interface number, the interface name in the necessary description information and the type information of the test case or the attribute information of an input parameter; generating an input parameter value of the test case based on the request type, the content type, the input parameter name, whether the input parameter is a necessary input parameter, the value range of the input parameter and the value type in the necessary description information; based on the response time and the output parameters in the necessary description information, the expected result of the test case is generated, the batch of interface test cases can be generated quickly, the time and labor cost are saved, the test efficiency is improved, and the accuracy of the test cases can be ensured.

Description

Interface test case generation method, device, equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of interface testing, in particular to a method, a device, equipment and a storage medium for generating a test case of an interface.
Background
The interface test is a test for testing interfaces among system components, and is an important component of the test, and the key point of the test is to check the correctness of interface parameter transmission, the correctness of interface function realization, the correctness of output results and the integrity and the reasonability of fault-tolerant processing of various abnormal conditions.
At present, in the process of realizing interface testing, a large number of test cases need to be compiled manually, a large amount of time is consumed, and the requirement for testing a rapid and efficient software project cannot be met.
Disclosure of Invention
The embodiment of the invention provides a method, a device, equipment and a storage medium for generating interface test cases, which can be used for quickly generating batch interface test cases, saving time and labor cost, improving test efficiency, avoiding misoperation in the process of manually compiling the test cases and ensuring the accuracy of the test cases.
In a first aspect, an embodiment of the present invention provides a method for generating a test case of an interface, where the method includes:
receiving an interface description document, and setting a corresponding number for an interface in the interface description document;
reading necessary description information of an interface in the interface description document, and generating the name of a test case based on an interface number, the name of the interface in the necessary description information, and type information of the test case or attribute information of an input parameter;
generating an input parameter value of the test case based on the request type, the content type, the input parameter name, whether the input parameter is a necessary input parameter, the value range of the input parameter and the value type in the necessary description information;
and generating an expected result of the test case based on the response time and the output parameters in the necessary description information.
Optionally, the test case is a forward test case;
the generating of the input parameter value of the test case based on the request type, the content type, the input parameter name, whether the input parameter is a necessary input parameter, the value range of the input parameter and the value type in the necessary description information includes:
determining an input format of an input parameter based on the request type and the content type; the input format comprises the input parameter name and a format of a corresponding input parameter;
generating first test data based on the value range and the value type of the input parameter;
and if the input parameters are the necessary input parameters, assigning the first test data to the input parameters according to the input format to generate the input parameter values of the test case.
Optionally, the test case is a reverse test case;
the generating of the input parameter value of the test case based on the request type, the content type, the input parameter name, whether the input parameter is a necessary input parameter, the value range of the input parameter and the value type in the necessary description information includes:
determining an input format of an input parameter based on the request type and the content type; the input format comprises the input parameter name and a format of a corresponding input parameter;
if the first input parameter of the interface is the mandatory input parameter, assigning the first input parameter as a null value according to the input format, and generating a first input parameter value of the test case;
determining second test data based on the corresponding value range and the value type aiming at second input parameters except the first input parameters;
and if the second input parameter is the mandatory input parameter, assigning the second input parameter to the second test data according to the input format to generate a second input parameter value of the test case.
Optionally, generating a name of the test case based on the interface number, the interface name in the necessary description information, and the attribute information of the input parameter includes:
if the first input parameter is a necessary filling input parameter and the sequence number of the first input parameter is less than or equal to the total number of the necessary filling input parameters, generating the name of the test case based on the interface number, the interface name, the name of the first input parameter and the actual unnecessary information of the first input parameter;
correspondingly, the encoding type in the output parameter corresponding to the first input parameter in the expected result is that the parameter is null.
Optionally, the test case is a reverse test case;
the generating of the input parameter value of the test case based on the request type, the content type, the input parameter name, whether the input parameter is the mandatory input parameter, the value range of the input parameter and the value type in the necessary description information includes:
determining an input format of an input parameter based on the request type and the content type; the input format comprises an input parameter name and a format of a corresponding input parameter;
determining third test data which exceed the value range of a third input parameter and accord with the value type of the third input parameter;
if the third input parameter is a filling input parameter, assigning the third input parameter to the third test data according to the input format to generate a third input parameter value of the test case;
determining fourth test data based on the corresponding value range and the value type aiming at fourth input parameters except the third input parameters;
and if the fourth input parameter is a mandatory input parameter, assigning the fourth input parameter to the fourth test data according to the input format to generate a fourth input parameter value of the test case.
Optionally, generating the name of the test case based on the interface number, the interface name in the necessary description information, and the attribute information of the input parameter includes:
if the third input parameter is a necessary input parameter and the sequence number of the third input parameter is less than or equal to the total number of the necessary input parameters, generating the name of the test case based on the interface number, the interface name, the name of the third input parameter and the invalid attribute information of the third input parameter;
correspondingly, the encoding type in the output parameter corresponding to the third input parameter in the expected result is invalid.
Optionally, generating the name of the test case based on the interface number, the interface name in the necessary description information, and the type information of the test case includes:
and generating the name of the test case based on the interface number, the interface name and the forward type of the test case.
In a second aspect, an embodiment of the present invention provides an interface test case generation apparatus, including:
the receiving/setting module is used for receiving the interface description document and setting a corresponding number for the interface in the interface description document;
the first generation module is used for reading necessary description information of the interface in the interface description document and generating the name of the test case based on the interface number, the interface name in the necessary description information and the type information of the test case or the attribute information of the input parameter;
the second generation module is used for generating an input parameter value of the test case based on the request type, the content type, the input parameter name, whether the input parameter is a necessary filling input parameter, the value range of the input parameter and the value type in the necessary description information;
and the third generation module is used for generating an expected result of the test case based on the response time and the output parameters in the necessary description information.
In a third aspect, an embodiment of the present invention provides an electronic device, including:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the methods provided by the embodiments of the present invention.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program is used to implement a method provided by an embodiment of the present invention when executed by a processor.
According to the technical scheme provided by the embodiment of the invention, the corresponding serial number is set for the interface in the interface description document, the necessary description information of the interface in the interface description document is read, and the name of the test case is generated based on the interface serial number, the interface name in the necessary description information, and the type information or the attribute information of the input parameter of the test case, so that the information of the test case can be conveniently known and distinguished; the method comprises the steps of reading necessary description information in an interface description document, generating input parameter values of test cases according to request type content types, input parameter names and input parameters in the necessary description information, determining whether the input parameters are necessary to be filled, the value range of the input parameters and the numerical value types, and generating expected results of the test cases according to output parameters and response time in the necessary description information, so that batch interface test cases can be generated quickly, time and labor cost are saved, test efficiency is improved, misoperation in the process of manually compiling the test cases is avoided, accuracy of the test cases is guaranteed, comprehensive test cases can be covered, and therefore comprehensive testing of interfaces is conducted. Under the condition that the test case is a forward test case, the name of the test case is generated through the interface number, the interface name and the forward type of the test case, so that a tester can conveniently and quickly know the information of the test case, the test case can be distinguished conveniently, and the input format of the input parameters is determined through the request type and the content type in the interface description file; the method comprises the steps of generating first test data through the value range and the value type of input parameters, if the input parameters are input parameters which must be filled, assigning the input parameters according to an input format to the first test data to generate input parameter values of test cases, and generating expected results of the test cases based on response time and output parameters in interface description documents. Under the condition that the test case is a reverse test case, the name of the test case is generated based on the interface number, the interface name, the name of the first input parameter and the actual unnecessary information of the first input parameter, so that the information of the test case can be conveniently known, the verification attribute of the test case can be conveniently distinguished, the efficiency of interface test is improved, and the input format of the input parameter is determined through the request type and the content type; if the first input parameter of the interface is the mandatory input parameter, assigning the first input parameter as a null value according to the input format, and generating a first input parameter value of the test case; determining second test data according to the corresponding value range and the value type aiming at second input parameters except the first input parameters; and if the second input parameter is the mandatory input parameter, assigning the second input parameter to the second test data according to the input format to generate a second input parameter value of the test case, and generating an input parameter value of the reverse test case, so that the non-empty verification is performed on the input parameter of the mandatory input parameter of the interface, and the comprehensive test is performed on the interface. And under the condition that the test case is a reverse test case, obtaining a third input parameter value of the test case by determining third test data which exceeds the value range and accords with the value type and assigning the test data to a third input parameter, namely obtaining the third input parameter value of the test case by assigning the third input parameter as an invalid parameter value, and verifying the validity of the input parameter which belongs to the necessary input parameter by using the coding type in the output parameter corresponding to the third input parameter in the expected result as the invalid parameter to generate the test case, so that the interface can be comprehensively tested.
Drawings
Fig. 1a is a flowchart of a test case generation method for an interface according to an embodiment of the present invention;
fig. 1b is a flowchart of a test case generation method for an interface according to an embodiment of the present invention;
fig. 2 is a flowchart of a test case generation method for an interface according to an embodiment of the present invention;
fig. 3 is a flowchart of a test case generation method for an interface according to an embodiment of the present invention;
fig. 4 is a flowchart of a test case generation method for an interface according to an embodiment of the present invention;
fig. 5 is a block diagram of a test case generating device of an interface according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
In the related art, a test case is a case of a set of test inputs, execution conditions, and expected results written for a particular target to verify whether a particular software requirement is met. The interface may be an application program interface, and may be a predefined interface, such as a function interface, a HyperText Transfer Protocol (HTTP) interface, and the like.
In the related art, the interface test is a test for testing interfaces between components of a system, and is mainly used for testing interfaces between the test system and other external systems and testing interfaces between sub-modules in the system. The interface test mainly checks the correctness of interface parameter transmission, the correctness of interface function realization, the correctness of output results, and the integrity and the reasonableness of fault-tolerant processing of various abnormal conditions. Errors (bugs) in computer programs can be discovered in advance through interface testing, which has the advantage of being cost-effective as the interface testing can be automated and is continuously integrated.
In the interface test process, a test case of the interface needs to be compiled, and the test case is executed to complete the test of the interface. The design of the test case of the interface has similarities with the design of the unit test case, and basic test methods such as a boundary value method and an equivalence method need to be adopted. The starting point of the test case for designing the interface is to verify the consistency of the functions and performance indexes realized by the interface and the interface description document.
At present, the test case compiling of the interface is mainly carried out in a manual mode, and the implementation process is as follows: firstly, an interface description document is needed to be referred to, the name of input parameters, the numerical type, the value range, whether the input parameters need to be filled and the like of each interface are determined, wherein the combination of the input parameters needs to follow the design methods of test cases such as an equivalence class method, a boundary value method and the like, all typical input parameter combinations are covered by the minimum number of the test cases, each test case covers different test points, and each test case can not be replaced. Secondly, according to the interface description document, all possible returned output results of each interface are determined, corresponding expected results are added into the response interrupt of the test case respectively, and whether the interface function is correct is judged by judging the consistency of the actual output result of the interface and the expected result of the interface test case. And finally, adding an expected result of the response time into the response assertion of the test case, and judging whether the performance of the interface meets the requirement by judging whether the actual response time of the interface reaches the expected result.
When the input parameters and the output results of a certain interface are too many, in order to ensure the coverage rate of the test, various tests need to be performed on each input parameter, and corresponding input parameters need to be constructed for the possibility of outputting the results, so as to generate a test case for verifying whether the actual output results of the interface meet the expected results. The more complex the interface is, the more test points are, the more the number of test cases written for the interface is, in a conventional software test project, the more the test cases of one interface may be, the time consumed by a mode of manually writing the test cases cannot meet the test requirements of a fast and efficient software project, and in the process of manually writing the test cases, problems that the input parameters are wrongly written or the test cases cannot pass due to other operations may exist, and the time is wasted when the problems are checked.
In order to solve the above problem, an embodiment of the present invention provides a method for generating a test case of an interface, and fig. 1a is a flowchart of the method for generating a test case of an interface, where the method may be executed by a device for generating a test case of an interface, the device may be implemented by software and/or hardware, the device may be configured in an electronic device, and the method may be applied in a scenario of interface testing.
As shown in fig. 1a, the technical solution provided by the embodiment of the present invention includes:
s110: receiving an interface description document, and setting a corresponding number for an interface in the interface description document.
In the embodiment of the present invention, the interface description document may be written in advance by a developer according to a function to be tested of the interface, and the interface description document may be a normalized interface description document. The interface description document comprises necessary description information of one or more interfaces, wherein the necessary description information comprises a request type, an interface path, a content-type input parameter name, whether the input parameter is a necessary input parameter, a value range of the input parameter, a value type of the input parameter, response time and an output parameter.
For example, table 1 is an example of an interface description document, and as shown in table 1, the interface description document includes a request type, an interface path, a content-type, an input parameter name, whether the input parameter is a must-fill input parameter, a value range of the input parameter, a value type of the input parameter, a response time, and an output parameter. For example, the interface name is user login, the request type is post, the response time is 3s, and the input parameter names include username, password, age, birthday, and the like.
TABLE 1
Figure BDA0003098975360000061
Figure BDA0003098975360000071
In the embodiment of the present invention, optionally, the interface description document is received, the total number of interfaces in the interface description document may be read, and a corresponding number is set for the interface in the interface description document. The interfaces are provided with corresponding numbers, for example, the interfaces can be numbered in sequence, and the number of the interface can be 01,02 … … N. The serial number is set for the interface, and the serial number can be used for generating the name of the test case.
S120: reading necessary description information of the interface in the interface description document, and generating the name of the test case based on the interface number, the interface name in the necessary description information, and the type information of the test case or the attribute information of the input parameter.
In the embodiment of the present invention, a limitation may be set for reading the necessary description information of the interface in the interface specification document, or the limitation may not be set. Alternatively, in the case where a limiting condition is set for reading the necessary description information of the interfaces in the interface specification document, for example, it may be that the necessary information of the interfaces in the interface specification document is read in the case where the number of the interfaces is smaller than the total number of the interfaces in the interface specification document. The method is characterized in that a limiting condition is set for reading the interface description document, so that the necessary description information of the interfaces in the interface description document can be conveniently and sequentially read in a circulating mode, and a plurality of test cases are generated by only one section of code program.
In the embodiment of the present invention, the type information of the test case may include a forward type of the test case and a reverse type of the test case. The attribute information of the input parameter may include attribute information of whether the input parameter is valid, whether the input parameter is a padding parameter, and the like.
In the embodiment of the present invention, the test case may include a forward test case and a reverse test case. The forward test case can be understood as inputting correct input parameters, and whether the interface can return correct output parameters is verified. The reverse test case can be understood as inputting wrong input parameters, and whether the interface feeds back corresponding output parameters is verified. Under the condition that the test case is a forward test case, the name of the test case can be generated based on the interface name, the interface number and the type information of the test case, so that testers can conveniently know and distinguish the information of the test case. Under the condition that the test case is a reverse test case, the name of the test case can be generated based on the interface name, the interface number and the attribute information of the input parameter, so that testers can conveniently know and distinguish the information of the test case, and the interface test is facilitated.
And S130, generating an input parameter value of the test case based on the request type, the content type, the input parameter name, whether the input parameter is a necessary input parameter, the value range of the input parameter and the value type in the necessary description information.
In an embodiment of the present invention, the request types of the interface may include a post request and a get request, a content type (content-type), a Multipurpose Internet Mail Extensions (MIME) for indicating resources in an entity header, and in response, the content-type header may notify the client of the content type of the content actually returned, and in the request, the client may notify the server of the data type actually sent. The input parameter name and whether the input parameter is a fill-necessary input parameter may refer to the examples in table 1. The value range of the input parameter can be understood as the length range of the input parameter, and the numerical type can include a character string type, an integer value type, and the like.
In the embodiment of the present invention, optionally, an input format of the input parameter may be generated based on the request type and the content type, where the input format may include an input parameter name and a format of the input parameter. For example, the format of the input parameters may be { "mandatory input parameter 1": a, "must fill input parameter 2": b, "must fill in parameter 3": c. Optionally, test data may be generated based on "whether the input parameter is a must-fill input parameter, a value range of the input parameter, and a value type", so that the test data is assigned to the corresponding input parameter, and an input parameter value of the test case is generated.
Therefore, the test case can be generated to cover more comprehensively and test the interface more comprehensively by generating the input parameter value of the test case based on the request type, the content type, the input parameter name, whether the input parameter is necessary to fill the input parameter, the value range of the input parameter and the value type.
S140: and generating an expected result of the test case based on the response time and the output parameters in the necessary description information.
In an embodiment of the present invention, the response time may be used to verify the performance of the interface, and the output parameters may include a code type (code), data (data), and a message type (msg). For example, as shown in table 1, codes of the output parameters may include 0, 1001, 1002, etc., which respectively represent normal, empty, invalid, etc., and msg may include tune, false, etc.
In the embodiment of the invention, the expected result of the test case can be generated through the response time and the output parameters of the interface in the interface description document, the test case can be formed through the input parameter values and the expected result, the test case is executed, and the expected result and the actual output result of the test case can be compared, so that the correctness of the test case is verified.
FIG. 1b is a flowchart of a test case generation method for an interface according to an embodiment of the present invention, and as shown in FIG. 1b, the method includes the steps of starting, receiving an interface description document; reading the total number of interfaces in the interface description document, and setting a corresponding number for each interface; judging whether the number of the interfaces is less than or equal to the total number of the interfaces, if not, ending the process; if yes, reading necessary description information in the interface description document, and generating a test case of the interface based on the necessary description information and the interface number. The step of generating the test case of the interface based on the necessary description information of the interface includes steps S120 to S140 in the above embodiment. Specific description may be found in the above embodiments.
According to the technical scheme provided by the embodiment of the invention, the corresponding number is set for the interface in the interface description document, the necessary description information of the interface in the interface description document is read, and the name of the test case is generated based on the interface number, the interface name in the necessary description information, and the type information or the attribute information of the input parameter of the test case, so that the information of the test case can be conveniently known and distinguished; the method comprises the steps of reading necessary description information in an interface description document, generating input parameter values of test cases according to request type content types, input parameter names and input parameters in the necessary description information, determining whether the input parameters are necessary to be filled, the value range of the input parameters and the numerical value types, and generating expected results of the test cases according to output parameters and response time in the necessary description information, so that batch interface test cases can be generated quickly, time and labor cost are saved, test efficiency is improved, misoperation in the process of manually compiling the test cases is avoided, accuracy of the test cases is guaranteed, comprehensive test cases can be covered, and therefore comprehensive testing of interfaces is conducted.
Fig. 2 is a flowchart of a method for generating a test case of an interface according to an embodiment of the present invention, where in this embodiment, the test case is a forward test case.
Optionally, the generating of the input parameter value of the test case based on the request type, the content type, the name of the input parameter, whether the input parameter is a mandatory input parameter, the value range of the input parameter, and the value type in the necessary description information includes:
determining an input format of an input parameter based on the request type and the content type; the input format comprises the input parameter name and a format of a corresponding input parameter;
generating first test data based on the value range and the value type of the input parameter;
and if the input parameters are the necessary input parameters, assigning the first test data to the input parameters according to the input format to generate the input parameter values of the test case.
Optionally, the name of the test case is generated based on the interface number, the interface name, and the forward type of the test case.
As shown in fig. 2, the technical solution provided by the embodiment of the present invention includes:
s210: receiving an interface description document, and setting a corresponding number for an interface in the interface description document.
S220: reading the necessary description information of the interface in the interface specification document.
In the embodiment of the present invention, reference may be made to the description of the above embodiment for S210-S220.
S230: and generating the name of the test case based on the interface number, the interface name and the forward type of the test case.
In the embodiment of the present invention, the name of the test case includes an interface number, an interface name, and a forward type of the test case, for example, the name of the generated test case may be interface number _ interface name _ forward. The name format for generating the test case is not limited to the above format, and may be other formats.
Therefore, the name of the test case is generated through the interface number, the interface name and the forward type of the test case, so that a tester can conveniently and quickly know the information of the test case, and the test case can be conveniently distinguished.
S240: determining an input format of an input parameter based on the request type and the content type; wherein the input format comprises the input parameter name and the format of the corresponding input parameter.
In the embodiment of the present invention, the input format of the input parameter may be determined by a request type and a content-type, wherein the request type may be a post request and the content-type may be json. Wherein, the input format of the input parameter may be { "fill input parameter 1": a, "must fill input parameter 2": b, "must fill in parameter 3": c.
S250: and generating first test data based on the value range and the value type of the input parameters.
In the embodiment of the invention, the length range of the input parameter can be determined based on the value range of the input parameter, whether the input parameter is a character string or an integer value can be determined through the value type, and first test data meeting requirements can be generated by calling a random generation function based on the value range and the value type. For example, the numerical type of the mandatory input parameter 1 is int, and the numeric range is [0, 100], and test data meeting requirements can be generated by calling a random function, and the test data can be used as first test data.
S260: and if the input parameters are the necessary input parameters, assigning the first test data to the input parameters according to the input format to generate the input parameter values of the test case.
In the embodiment of the invention, if the input parameter is the mandatory input parameter, the first test data is assigned to the input parameter according to the input format to obtain the input parameter value of the test case. For example, if the input format is { "must fill input parameter 1": a, "must fill input parameter 2": b, "must fill input parameter 3": c. }, the numerical type of the input parameter 1 is int, the value range is [0, 100], first test data is generated by calling a random generation function, and the first test data is assigned to the input parameter a to obtain an input parameter value of the test case.
S270: and generating an expected result of the test case based on the response time and the output parameters in the necessary description information.
In an embodiment of the invention, the expected result includes two parts, including response time and output parameters, respectively. Wherein, the output parameter of the forward test case can be { "code":0; "msg" means false; the data is as follows: ...}. And if the code type of the expected result of the forward test case is 0, the representation is normal.
For other descriptions of S270, reference may be made to the descriptions of the above embodiments.
Therefore, if the test case is a forward test case, determining the input format of the input parameters through the request type and the content type in the interface description file; the method comprises the steps of generating first test data through the value range and the value type of input parameters, if the input parameters are input parameters which must be filled, assigning the input parameters according to an input format to the first test data to generate input parameter values of test cases, and generating expected results of the test cases based on response time and output parameters in interface description documents.
Fig. 3 is a flowchart of a method for generating a test case of an interface according to an embodiment of the present invention, where in this embodiment, the test case is a reverse test case, and the test case may perform non-null verification on input parameters belonging to a must-fill input parameter.
Optionally, the generating an input parameter value of the test case based on the request type, the content type, the name of the input parameter, whether the input parameter is a must-fill input parameter, the value range of the input parameter, and the value type in the necessary description information includes:
determining an input format of an input parameter based on the request type and the content type; the input format comprises the input parameter name and a format of a corresponding input parameter;
if the first input parameter of the interface is the mandatory input parameter, assigning the first input parameter as a null value according to the input format, and generating a first input parameter value of the test case;
for second input parameters except the first input parameters, determining second test data based on the corresponding value range and the value type;
and if the second input parameter is the mandatory input parameter, assigning the second input parameter to the second test data according to the input format to generate a second input parameter value of the test case.
Optionally, generating the name of the test case based on the interface number, the interface name in the necessary description information, and the attribute information of the input parameter includes:
and if the first input parameter is a necessary filling input parameter and the sequence number of the first input parameter is less than the total number of the necessary filling input parameters, generating the name of the test case based on the interface number, the interface name, the first input parameter name and the actual unnecessary information of the first input parameter.
As shown in fig. 3, the technical solution provided by the embodiment of the present invention includes:
s310: receiving an interface description document, and setting a corresponding number for an interface in the interface description document.
S320: reading the necessary description information of the interface in the interface specification document.
In the embodiment of the present invention, reference may be made to the above-mentioned embodiments for the introduction of S310 to S320.
S330: and if the first input parameter is a necessary filling input parameter and the sequence number of the first input parameter is less than or equal to the total number of the necessary filling input parameters, generating the name of the test case based on the interface number, the interface name, the name of the first input parameter and the actual unnecessary information of the first input parameter.
In the embodiment of the present invention, the total number of input parameters belonging to the fill-necessary input parameters in the interface description document may be determined, and the sorting order may be set for the input parameters belonging to the fill-necessary input parameters. If the first input parameter is the necessary input parameter and the sequence number of the first input parameter is less than or equal to the total number of the necessary input parameters, generating the name of the test case; otherwise, the flow ends.
In the embodiment of the present invention, optionally, the name of the test case may be generated based on the interface number, the interface name, the name of the first input parameter belonging to the mandatory input parameter, and the actual optional information of the first input parameter. For example, if the first input parameter is X and is a padding parameter, the name of the generated test case may be the interface number _ interface name _ padding input parameter X _ padding.
Therefore, if the first input parameter is the mandatory input parameter and the sequence number of the first input parameter is less than or equal to the total number of the mandatory input parameters, the name of the test case is generated based on the interface number, the interface name, the name of the first input parameter and the actual unnecessary information of the first input parameter, so that the information of the test case can be conveniently known, the verification attribute of the test case can be conveniently distinguished, and the efficiency of interface testing is improved.
S340: determining an input format of an input parameter based on the request type and the content type; wherein the input format comprises the input parameter name and the format of the corresponding input parameter.
In the embodiment of the present invention, reference may be made to the corresponding descriptions in the above embodiments for the description of S340.
S350: and if the first input parameter of the interface is the mandatory input parameter, assigning the first input parameter to a null value according to the input format by the first input parameter, and generating a first input parameter value of the test case.
In the embodiment of the invention, if the first input parameter is the mandatory input parameter, the first input parameter can be assigned as a null value according to the input format, and then the first input parameter value of the test case is generated. For example, the input format is { "must fill input parameter 1": a, "must fill input parameter 2": b, "must fill in parameter 3": c., the first input parameter is a fill-necessary input parameter 1, and a corresponding to the fill-necessary input parameter 1 can be assigned as a null value.
S360: and determining second test data based on the corresponding value range and the value type aiming at second input parameters except the first input parameters.
In an embodiment of the present invention, each interface has a plurality of corresponding input parameters. In addition to the first input parameter, the input parameters of the interface are second input parameters, wherein the number of the second input parameters including the parameters can be at least one. The generation of the second test data is the same as the method of the first test data in the above embodiment, and the description is not repeated.
S370: and if the second input parameter is the mandatory input parameter, assigning the second input parameter to the second test data according to the input format to generate a second input parameter value of the test case.
In the embodiment of the present invention, a method for generating the second input parameter value of the test case is the same as the method for generating the input parameter value introduced in S260 in the foregoing embodiment, and a description thereof is not repeated.
S380: and generating an expected result of the test case based on the response time and the output parameters in the necessary description information, wherein the encoding type in the output parameters corresponding to the first input parameters in the expected result is null.
In the embodiment of the present invention, since the first input parameter is a mandatory input parameter, but the first input parameter is assigned as a null value, a code in the output parameter corresponding to the first input parameter in the expected result is 1001, and the characterization parameter is null, thereby implementing the correspondence between the input parameter value of the test case and the expected result.
It should be noted that the execution sequence of S350-S370 is not limited to the execution sequence in the above embodiment, and may also be other execution sequences, for example, the two steps of S360 and S370 are executed before S350, or the execution sequence may also be adjusted according to actual situations.
Thus, the input format of the input parameters is determined by the request type and the content type; if the first input parameter of the interface is the mandatory input parameter, assigning the first input parameter as a null value according to the input format, and generating a first input parameter value of the test case; aiming at second input parameters except the first input parameters, determining second test data through the corresponding value range and the corresponding value type; and if the second input parameter is the mandatory fill input parameter, assigning the second input parameter to the second test data according to the input format to generate a second input parameter value of the test case, and generating an input parameter value of the reverse test case, so that the non-empty verification is performed on the input parameter of the mandatory fill input parameter of the interface, and the comprehensive test is performed on the interface.
Fig. 4 is a flowchart of a method for generating a test case of an interface according to an embodiment of the present invention, where in this embodiment, optionally, the test case is a reverse test case, and the test case may perform validity verification on input parameters belonging to a must-fill input parameter.
Optionally, the generating of the input parameter value of the test case based on the request type, the content type, the name of the input parameter, whether the input parameter is a mandatory input parameter, the value range of the input parameter, and the value type in the necessary description information includes:
determining an input format of an input parameter based on the request type and the content type; the input format comprises an input parameter name and a format of a corresponding input parameter;
determining third test data which exceed the value range of a third input parameter and accord with the value type of the third input parameter;
if the third input parameter is a mandatory input parameter, assigning the third input parameter to the third test data according to the input format to generate a third input parameter value of the test case;
determining fourth test data based on the corresponding value range and the value type aiming at fourth input parameters except the third input parameters;
and if the fourth input parameter is a mandatory input parameter, assigning the fourth input parameter to the fourth test data according to the input format to generate a fourth input parameter value of the test case.
Optionally, generating a name of the test case based on the interface number, the interface name in the necessary description information, and the attribute information of the input parameter includes:
and if the third input parameter is a fill-in input parameter and the sequence number of the third input parameter is less than the total number of the fill-in input parameters, generating the name of the test case based on the interface number, the interface name, the name of the third input parameter and the invalid attribute information of the third input parameter.
As shown in fig. 4, the technical solution provided by the embodiment of the present invention includes:
s410: receiving an interface description document, and setting a corresponding number for an interface in the interface description document.
S420: reading the necessary description information of the interface in the interface specification document.
In the present embodiment, reference may be made to the description of the above embodiments for the description of S410-S420.
S430: and if the third input parameter is a necessary input parameter and the sequence number of the third input parameter is less than the total number of the necessary input parameters, generating the name of the test case based on the interface number, the interface name, the name of the third input parameter and the invalid attribute information of the third input parameter.
In the embodiment of the invention, the total number of the input parameters belonging to the necessary input parameters in the interface description document can be determined, and the sorting sequence number is set for the input parameters belonging to the necessary input parameters. If the first input parameter is the necessary input parameter and the sequence number of the first input parameter is less than or equal to the total number of the necessary input parameters, generating the name of the test case; otherwise, the flow ends.
In the embodiment of the invention, the name of the test case can be generated based on the interface number, the interface name, the name of the third input parameter belonging to the required input parameter and the invalid attribute information of the third input parameter. For example, the third input parameter may be the input parameter Y, and the name of the generated test case may be the interface number _ interface name _ input parameter Y _ invalid.
Therefore, the name of the test case is generated through the interface number, the interface name, the name of the third input parameter and the invalid attribute information of the third input parameter, so that the verification attribute of the test case can be conveniently known, the test case can be conveniently distinguished, and the efficiency of interface testing is improved.
S440: determining an input format of an input parameter based on the request type and the content type; the input format comprises an input parameter name and a format of a corresponding input parameter.
In the embodiment of the present invention, reference may be made to the corresponding descriptions in the above embodiments for the description of S440.
S450: and determining third test data which exceed the value range of the third input parameter and accord with the value type of the third input parameter.
In the embodiment of the invention, the random generation function can be called to generate the third test data which exceeds the value range and accords with the value type through the value range and the value type of the third input parameter. For example, if the value range of the third input parameter is [1,100], the value type is int, and the generated third test data may be 120, where 120 is not in the value range of the third input parameter but conforms to the value type. If the value range of the third input parameter is [5,10], the numerical type is str, the length of the characterization character string is [5,10], and a random generation function can be called to generate a character string whose length is not in the range of [5,10], for example, third test data abc can be generated, and the value range of the abc exceeds the value range of the third input parameter and conforms to the numerical type of the third input parameter.
S460: and if the third input parameter is a mandatory input parameter, assigning the third input parameter to the third test data according to the input format to generate a third input parameter value of the test case.
In the embodiment of the invention, the third test data is assigned to the third input parameter to obtain the third input parameter value of the test case, and the third input parameter value is invalid because the third test data exceeds the value range of the third input parameter, so that the validity verification of the input parameters belonging to the necessary input parameters can be carried out by inputting the invalid input parameter values.
S470: and determining fourth test data based on the corresponding value range and the value type aiming at fourth input parameters except the third input parameters.
In an embodiment of the present invention, each interface has a plurality of corresponding input parameters. In addition to the third input parameter, the input parameters of the interface are fourth input parameters, wherein the number of the fourth input parameters including the parameter may be at least one. The generation of the fourth test data is the same as the method of the first test data in the above embodiment, and the description is not repeated.
S480: and if the fourth input parameter is a mandatory input parameter, assigning the fourth input parameter to the fourth test data according to the input format to generate a fourth input parameter value of the test case.
In the embodiment of the present invention, a method for generating the fourth input parameter value of the test case is the same as the method for generating the input parameter value described in S260 in the foregoing embodiment, and a description thereof will not be repeated.
S490: generating an expected result of the test case based on the response time and the output parameters in the necessary description information; and the encoding type in the output parameter corresponding to the third input parameter in the expected result is invalid.
In the embodiment of the invention, the value range of the third test data is taken out, the third test data is assigned to the third input parameter, the third input parameter value is an invalid parameter value, the code in the output parameter corresponding to the third input parameter in the expected result is 1002, and the characterization parameter is invalid, so that the input parameter value of the test case is corresponding to the expected result, a correct test case is generated, and the interface is correctly tested.
Therefore, the third input parameter value of the test case is obtained by determining the third test data which exceeds the value range and accords with the value type, assigning the test data to the third input parameter, namely, assigning the third input parameter as an invalid parameter value to obtain the third input parameter value of the test case, and the generated test case can carry out validity verification on the input parameter which belongs to the necessary input parameter by taking the coding type in the output parameter corresponding to the third input parameter in the expected result as the parameter invalid, so that the interface can be comprehensively and correctly tested.
Fig. 5 is a block diagram of a structure of a test case generation apparatus for an interface according to an embodiment of the present invention, and as shown in fig. 5, the apparatus includes: a receiving/setting module 510, a first generating module 520, a second generating module 530, and a third generating module 540.
The receiving/setting module 510 is configured to receive an interface description document, and set a corresponding number for an interface in the interface description document;
a first generating module 520, configured to read necessary description information of an interface in the interface specification document, and generate a name of a test case based on an interface number, an interface name in the necessary description information, and type information of the test case or attribute information of an input parameter;
a second generating module 530, configured to generate an input parameter value of the test case based on the request type, the content type, the name of the input parameter, whether the input parameter is a mandatory input parameter, a value range of the input parameter, and a value type in the necessary description information;
and a third generating module 540, configured to generate an expected result of the test case based on the response time and the output parameter in the necessary description information.
Optionally, the test case is a forward test case;
the generating of the input parameter value of the test case based on the request type, the content type, the input parameter name, whether the input parameter is the mandatory input parameter, the value range of the input parameter and the value type in the necessary description information includes:
determining an input format of an input parameter based on the request type and the content type; the input format comprises the input parameter name and a format corresponding to the input parameter;
generating first test data based on the value range and the value type of the input parameter;
and if the input parameters are the necessary input parameters, assigning the first test data to the input parameters according to the input format to generate the input parameter values of the test case.
Optionally, the test case is a reverse test case;
the generating of the input parameter value of the test case based on the request type, the content type, the input parameter name, whether the input parameter is a necessary input parameter, the value range of the input parameter and the value type in the necessary description information includes:
determining an input format of an input parameter based on the request type and the content type; the input format comprises the input parameter name and a format of a corresponding input parameter;
if the first input parameter of the interface is the mandatory input parameter, assigning the first input parameter as a null value according to the input format, and generating a first input parameter value of the test case;
determining second test data based on the corresponding value range and the value type aiming at second input parameters except the first input parameters;
and if the second input parameter is the mandatory input parameter, assigning the second input parameter to the second test data according to the input format to generate a second input parameter value of the test case.
Optionally, generating the name of the test case based on the interface number, the interface name in the necessary description information, and the attribute information of the input parameter includes:
if the first input parameter is a necessary filling input parameter and the sequence number of the first input parameter is less than or equal to the total number of the necessary filling input parameters, generating the name of the test case based on the interface number, the interface name, the name of the first input parameter and the actual unnecessary information of the first input parameter;
correspondingly, the encoding type in the output parameter corresponding to the first input parameter in the expected result is that the parameter is null.
Optionally, the test case is a reverse test case;
the generating of the input parameter value of the test case based on the request type, the content type, the input parameter name, whether the input parameter is the mandatory input parameter, the value range of the input parameter and the value type in the necessary description information includes:
determining an input format of an input parameter based on the request type and the content type; the input format comprises an input parameter name and a format of a corresponding input parameter;
determining third test data which exceed the value range of a third input parameter and accord with the value type of the third input parameter;
if the third input parameter is a filling input parameter, assigning the third input parameter to the third test data according to the input format to generate a third input parameter value of the test case;
determining fourth test data based on the corresponding value range and the value type aiming at fourth input parameters except the third input parameters;
and if the fourth input parameter is the filling input parameter, assigning the fourth input parameter to the fourth test data according to the input format to generate a fourth input parameter value of the test case.
Optionally, generating the name of the test case based on the interface number, the interface name in the necessary description information, and the attribute information of the input parameter includes:
if the third input parameter is a necessary input parameter and the sequence number of the third input parameter is less than or equal to the total number of the necessary input parameters, generating the name of the test case based on the interface number, the interface name, the name of the third input parameter and the invalid attribute information of the third input parameter;
correspondingly, the encoding type in the output parameter corresponding to the third input parameter in the expected result is invalid.
Optionally, generating the name of the test case based on the interface number, the interface name in the necessary description information, and the type information of the test case includes:
and generating the name of the test case based on the interface number, the interface name and the forward type of the test case.
The device can execute the method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Fig. 6 is a schematic structural diagram of an apparatus provided in an embodiment of the present invention, and as shown in fig. 6, the apparatus includes:
one or more processors 610, one processor 610 being exemplified in fig. 6;
a memory 620;
the apparatus may further include: an input device 630 and an output device 640.
The processor 610, the memory 620, the input device 630 and the output device 640 of the apparatus may be connected by a bus or other means, and fig. 6 illustrates the example of connection by a bus.
The memory 620, which is a non-transitory computer-readable storage medium, may be used to store software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to a test case generation method of an interface in an embodiment of the present invention (for example, the receiving/setting module 510, the first generation module 520, the second generation module 530, and the third generation module 540 shown in fig. 5). The processor 610 executes various functional applications and data processing of the computer device by running the software programs, instructions and modules stored in the memory 620, namely, a test case generation method for implementing an interface of the above method embodiment, that is:
receiving an interface description document, and setting a corresponding number for an interface in the interface description document;
reading necessary description information of an interface in the interface description document, and generating a name of a test case based on an interface number, an interface name in the necessary description information, and type information of the test case or attribute information of an input parameter;
generating an input parameter value of the test case based on the request type, the content type, the input parameter name, whether the input parameter is a necessary input parameter, the value range of the input parameter and the value type in the necessary description information;
and generating an expected result of the test case based on the response time and the output parameters in the necessary description information.
The memory 620 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to use of the computer device, and the like. Further, the memory 620 may include high speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, memory 620 optionally includes memory located remotely from processor 610, which may be connected to the terminal device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input means 630 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the computer apparatus. The output device 640 may include a display device such as a display screen.
An embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements a test case generation method for an interface according to an embodiment of the present invention:
receiving an interface description document, and setting a corresponding number for an interface in the interface description document;
reading necessary description information of an interface in the interface description document, and generating a name of a test case based on an interface number, an interface name in the necessary description information, and type information of the test case or attribute information of an input parameter;
generating an input parameter value of the test case based on the request type, the content type, the input parameter name, whether the input parameter is a necessary input parameter, the value range of the input parameter and the value type in the necessary description information;
and generating an expected result of the test case based on the response time and the output parameters in the necessary description information.
Any combination of one or more computer-readable media may be employed. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. Those skilled in the art will appreciate that the present invention is not limited to the particular embodiments described herein, and that various obvious changes, rearrangements and substitutions will now be apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (9)

1. A test case generation method of an interface is characterized by comprising the following steps:
receiving an interface description document, and setting a corresponding number for an interface in the interface description document;
reading necessary description information of an interface in the interface description document, and generating a name of a test case based on an interface number, an interface name in the necessary description information and type information of the test case, or generating the name of the test case based on the interface number, the interface name in the necessary description information and attribute information of an input parameter;
generating an input parameter value of the test case based on the request type, the content type, the input parameter name, whether the input parameter is a necessary input parameter, the value range of the input parameter and the value type in the necessary description information;
if the test case is a reverse test case, generating input parameter values of the test case based on the request type, the content type, the input parameter name, whether the input parameters are the mandatory input parameters, the value range of the input parameters and the value type in the necessary description information, wherein the method comprises the following steps:
determining an input format of an input parameter based on the request type and the content type; the input format comprises the input parameter name and a format of a corresponding input parameter;
if the first input parameter of the interface is a mandatory input parameter, assigning the first input parameter as a null value according to the input format, and generating a first input parameter value of the test case;
determining second test data based on the corresponding value range and the value type aiming at second input parameters except the first input parameters;
if the second input parameter is a mandatory input parameter, assigning the second input parameter to the second test data according to the input format to generate a second input parameter value of the test case;
and generating an expected result of the test case based on the response time and the output parameters in the necessary description information.
2. The method of claim 1, wherein the test case is a forward test case;
the generating of the input parameter value of the test case based on the request type, the content type, the input parameter name, whether the input parameter is a necessary input parameter, the value range of the input parameter and the value type in the necessary description information includes:
determining an input format of an input parameter based on the request type and the content type; the input format comprises the input parameter name and a format of a corresponding input parameter;
generating first test data based on the value range and the value type of the input parameters;
and if the input parameters are the necessary input parameters, assigning the first test data to the input parameters according to the input format to generate the input parameter values of the test case.
3. The method according to claim 1, wherein generating the name of the test case based on the interface number, the interface name in the necessary description information, and the attribute information of the input parameter comprises:
if the first input parameter is a necessary filling input parameter and the sequence number of the first input parameter is less than or equal to the total number of the necessary filling input parameters, generating the name of the test case based on the interface number, the interface name, the name of the first input parameter and the actual unnecessary information of the first input parameter;
correspondingly, the encoding type in the output parameter corresponding to the first input parameter in the expected result is null.
4. The method of claim 1, wherein the test case is a reverse test case;
the generating of the input parameter value of the test case based on the request type, the content type, the input parameter name, whether the input parameter is a necessary input parameter, the value range of the input parameter and the value type in the necessary description information includes:
determining an input format of an input parameter based on the request type and the content type; the input format comprises an input parameter name and a format of a corresponding input parameter;
determining third test data which exceed the value range of a third input parameter and accord with the value type of the third input parameter;
if the third input parameter is a filling input parameter, assigning the third input parameter to the third test data according to the input format to generate a third input parameter value of the test case;
determining fourth test data based on the corresponding value range and the value type aiming at fourth input parameters except the third input parameters;
and if the fourth input parameter is a mandatory input parameter, assigning the fourth input parameter to the fourth test data according to the input format to generate a fourth input parameter value of the test case.
5. The method according to claim 4, wherein generating the name of the test case based on the interface number, the interface name in the necessary description information, and the attribute information of the input parameter comprises:
if the third input parameter is a necessary input parameter and the sequence number of the third input parameter is less than or equal to the total number of the necessary input parameters, generating the name of the test case based on the interface number, the interface name, the name of the third input parameter and the invalid attribute information of the third input parameter;
correspondingly, the encoding type in the output parameter corresponding to the third input parameter in the expected result is invalid.
6. The method of claim 2, wherein generating the name of the test case based on the interface number, the interface name in the necessary description information, and the type information of the test case comprises:
and generating the name of the test case based on the interface number, the interface name and the forward type of the test case.
7. An interface test case generation device, comprising:
the receiving/setting module is used for receiving the interface description document and setting a corresponding number for an interface in the interface description document;
the first generation module is used for reading necessary description information of an interface in the interface description document, and generating the name of a test case based on the interface number, the interface name in the necessary description information and the type information of the test case, or generating the name of the test case based on the interface number, the interface name in the necessary description information and the attribute information of an input parameter;
the second generation module is used for generating an input parameter value of the test case based on the request type, the content type, the input parameter name, whether the input parameter is a necessary filling input parameter, the value range of the input parameter and the value type in the necessary description information;
if the test case is a reverse test case, generating input parameter values of the test case based on the request type, the content type, the input parameter name, whether the input parameters are the mandatory filling input parameters, the value range of the input parameters and the value type in the necessary description information, including:
determining an input format of an input parameter based on the request type and the content type; the input format comprises the input parameter name and a format of a corresponding input parameter;
if the first input parameter of the interface is a mandatory input parameter, assigning the first input parameter as a null value according to the input format, and generating a first input parameter value of the test case;
determining second test data based on the corresponding value range and the value type aiming at second input parameters except the first input parameters;
if the second input parameter is the filling input parameter, assigning the second input parameter to the second test data according to the input format to generate a second input parameter value of the test case; and the third generation module is used for generating an expected result of the test case based on the response time and the output parameters in the necessary description information.
8. An electronic device, comprising:
one or more processors;
a storage device to store one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-6.
9. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-6.
CN202110619074.3A 2021-06-03 2021-06-03 Interface test case generation method, device, equipment and storage medium Active CN113407444B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110619074.3A CN113407444B (en) 2021-06-03 2021-06-03 Interface test case generation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110619074.3A CN113407444B (en) 2021-06-03 2021-06-03 Interface test case generation method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113407444A CN113407444A (en) 2021-09-17
CN113407444B true CN113407444B (en) 2022-11-25

Family

ID=77676142

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110619074.3A Active CN113407444B (en) 2021-06-03 2021-06-03 Interface test case generation method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113407444B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117687893B (en) * 2024-02-04 2024-05-10 深圳市冠群电子有限公司 Mobile phone APP port testing method and system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106933741A (en) * 2017-03-16 2017-07-07 东软集团股份有限公司 The method and device of joint debugging test
CN108984388A (en) * 2018-06-01 2018-12-11 平安壹钱包电子商务有限公司 A kind of method and terminal device generating automatic test cases
CN111061645A (en) * 2019-12-26 2020-04-24 中科曙光国际信息产业有限公司 Automatic interface testing method and device for application program interface
CN111221743A (en) * 2020-03-18 2020-06-02 时时同云科技(成都)有限责任公司 Automatic testing method and system
WO2020119434A1 (en) * 2018-12-15 2020-06-18 深圳壹账通智能科技有限公司 Method and apparatus for interface data processing, method and apparatus for automated testing, device, and medium
CN111506498A (en) * 2020-03-16 2020-08-07 平安科技(深圳)有限公司 Automatic generation method and device of test case, computer equipment and storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11099973B2 (en) * 2019-01-28 2021-08-24 Salesforce.Com, Inc. Automated test case management systems and methods
CN109947646A (en) * 2019-03-13 2019-06-28 平安信托有限责任公司 Interface test method, device, computer equipment and storage medium
CN110134584A (en) * 2019-04-12 2019-08-16 深圳壹账通智能科技有限公司 A kind of generation method, device, storage medium and the server of interface testing use-case
CN110321283B (en) * 2019-05-24 2024-05-10 平安银行股份有限公司 Interface test case generation method and device, computer device and storage medium
CN111949520A (en) * 2020-07-31 2020-11-17 上海中通吉网络技术有限公司 Automatic interface test method and equipment
CN112597018A (en) * 2020-12-22 2021-04-02 未来电视有限公司 Interface test case generation method, device, equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106933741A (en) * 2017-03-16 2017-07-07 东软集团股份有限公司 The method and device of joint debugging test
CN108984388A (en) * 2018-06-01 2018-12-11 平安壹钱包电子商务有限公司 A kind of method and terminal device generating automatic test cases
WO2020119434A1 (en) * 2018-12-15 2020-06-18 深圳壹账通智能科技有限公司 Method and apparatus for interface data processing, method and apparatus for automated testing, device, and medium
CN111061645A (en) * 2019-12-26 2020-04-24 中科曙光国际信息产业有限公司 Automatic interface testing method and device for application program interface
CN111506498A (en) * 2020-03-16 2020-08-07 平安科技(深圳)有限公司 Automatic generation method and device of test case, computer equipment and storage medium
CN111221743A (en) * 2020-03-18 2020-06-02 时时同云科技(成都)有限责任公司 Automatic testing method and system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于接口参数的列控中心测试用例生成算法;张盛等;《计算机工程》(第01期);全文 *

Also Published As

Publication number Publication date
CN113407444A (en) 2021-09-17

Similar Documents

Publication Publication Date Title
CN111177005A (en) Service application testing method, device, server and storage medium
CN108628748B (en) Automatic test management method and automatic test management system
CN112380046B (en) Calculation result verification method, system, device, equipment and storage medium
CN111756697B (en) API safety detection method and device, storage medium and computer equipment
CN113806037A (en) Service calling method and device, storage medium and electronic equipment
CN112631924A (en) Automatic testing method and device, computer equipment and storage medium
CN113407444B (en) Interface test case generation method, device, equipment and storage medium
CN110570293A (en) method, device, server and storage medium for reimbursing collected invoices
CN114185808A (en) Automatic testing method and device, electronic equipment and computer readable storage medium
CN111459509A (en) Container mirror image construction method and device and server
CN113064816A (en) Testing device and testing method for programmable logic device software
CN111897833A (en) Data processing method and device
CN111949537A (en) Interface test method, device, equipment and medium
CN115202949A (en) Chip signal monitoring device and method, computer equipment and storage medium
CN111736917B (en) Data verification method and device, computer equipment and storage medium
CN109491699B (en) Resource checking method, device, equipment and storage medium of application program
CN109348305B (en) Bullet screen data verification method and device, terminal and storage medium
CN113128848A (en) Data quality monitoring method for full-service index, electronic equipment and storage medium
CN111459819A (en) Software testing method and device, electronic equipment and computer readable medium
CN110333897A (en) A kind of interface allocation method, device, medium and electronic equipment
CN111585844B (en) Test method, system, server and storage medium based on verification code
CN112131091B (en) Test method and device and electronic equipment
CN113141366B (en) Message submitting method and device, storage medium and electronic equipment
CN115827350A (en) Business process testing method, device, server and storage medium
CN115391210A (en) Data testing method, equipment and related device

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
GR01 Patent grant
GR01 Patent grant