CN115658476A - Automatic testing method and device, electronic equipment and storage medium - Google Patents

Automatic testing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115658476A
CN115658476A CN202211183021.2A CN202211183021A CN115658476A CN 115658476 A CN115658476 A CN 115658476A CN 202211183021 A CN202211183021 A CN 202211183021A CN 115658476 A CN115658476 A CN 115658476A
Authority
CN
China
Prior art keywords
simulation
response information
interface
target
function interface
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
CN202211183021.2A
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.)
Agricultural Bank of China
Original Assignee
Agricultural Bank of China
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 Agricultural Bank of China filed Critical Agricultural Bank of China
Priority to CN202211183021.2A priority Critical patent/CN115658476A/en
Publication of CN115658476A publication Critical patent/CN115658476A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The application provides an automatic testing method, an automatic testing device, electronic equipment and a storage medium, wherein a first function interface is called based on a first test case, and first response information returned by the first function interface is received, wherein the first function interface is an internal function interface, the first response information is used for calling a second function interface, and the second function interface is an external function interface; determining a corresponding target simulation database according to the information category of the first response information, wherein the target simulation database is used for storing response information returned by the external function interface of the target interface type; when the second function interface is called, second response information is obtained through the target simulation database and the first response information, a test result corresponding to the first test case is obtained based on the second response information, and the second response information is used for simulating response information returned by the second function interface, so that the test effect and the test efficiency are improved.

Description

Automatic testing method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to an automated testing method and apparatus, an electronic device, and a storage medium.
Background
Currently, in the development scenario for financial business systems and applications, the business system needs to rely on a large amount of external service support for its implementation, such as the service system in the central row. Unlike conventional external services, the external services relied on by financial business systems have very strict security requirements, and there are strict limitations on access to the external services, so that it is difficult to implement online testing of large data volumes in the business system development process.
In the prior art, in order to implement the functional test of the service system, an interface test is usually performed separately for an external service interface, and after the external service interface is verified separately, the external service interface is shielded to perform an overall system or functional test.
However, in the scheme in the prior art, since the internal interface and the external interface cannot be subjected to the integral joint debugging test, the problems of low test efficiency and poor test effect are caused, and the operation stability of the service system is affected.
Disclosure of Invention
The application provides an automatic testing method, an automatic testing device, electronic equipment and a storage medium, which are used for solving the problems of low testing efficiency and poor testing effect in the system testing process of a service system.
In a first aspect, the present application provides an automated testing method, including:
calling a first function interface based on a first test case, and receiving first response information returned by the first function interface, wherein the first function interface is an internal function interface, the first response information is used for calling a second function interface, and the second function interface is an external function interface; determining a corresponding target simulation database according to the information category of the first response information, wherein the target simulation database is used for storing response information returned by an external function interface of a target interface type; and when the second functional interface is called, obtaining second response information through the target simulation database and the first response information, and obtaining a test result corresponding to the first test case based on the second response information, wherein the second response information is used for simulating response information returned by the second functional interface.
In a possible implementation manner, the target simulation database stores simulation data corresponding to an external functional interface, the simulation data includes at least one simulation parameter, each simulation parameter corresponds to at least one response message, and the simulation parameter represents the content of a call request sent to the external functional interface; when the second functional interface is called, obtaining second response information through the target simulation database and the first response information, wherein the second response information comprises: generating target simulation parameters based on the first response information; and querying the target simulation database based on the target simulation parameters to obtain the second response information.
In a possible implementation manner, the second function interface corresponds to at least two external sub-functions, the first response information includes a target request parameter item and a parameter value corresponding to the target request parameter item, the target request parameter item is used to indicate a simulation parameter item of the simulation parameter, and the parameter value represents an input parameter used when the external sub-function is called; generating target simulation parameters based on the first response information comprises: determining a corresponding simulation parameter item based on the target request parameter item; inquiring simulation data corresponding to the second functional interface in the target simulation database based on the simulation parameter item to obtain a simulation parameter corresponding to the simulation parameter item; and generating target simulation parameters according to the simulation parameters corresponding to the simulation parameter items.
In a possible implementation manner, the querying, by the second functional interface, the target simulation database based on the target simulation parameter to obtain the second response information includes: acquiring a simulation mapping model of a simulation parameter item, wherein the simulation mapping model represents the mapping relation between input parameters and output parameters of the simulation parameter item; and generating the second response information based on the simulation mapping model of the simulation parameter item and the target simulation parameter.
In a possible implementation manner, before invoking the first functional interface based on the first test case, the method further includes: based on a second test case, sending a calling request to at least one external function interface, and receiving third response information returned by the external function interface; and constructing a simulation database corresponding to each interface type based on the interface type of the external function interface and the corresponding third response information.
In a possible implementation manner, the building a simulation database corresponding to each interface type based on the interface type of the external function interface and the corresponding third response information includes: sequentially constructing at least one data group aiming at each interface type, wherein the data group consists of a calling request and corresponding third response information; and constructing a corresponding simulation database based on the data group corresponding to each interface type.
In a possible implementation manner, the call request includes a request parameter item and a parameter value corresponding to the request parameter item, the request parameter item is used to indicate an external sub-function of the external function interface, and the parameter value represents an input parameter used when the external sub-function is called; the method further comprises the following steps: and training a preset neural network model by taking the calling request in the data set and the corresponding third response information as samples to obtain a simulation mapping model, wherein the simulation mapping model represents the mapping relation between the input parameters of the external subfunction of the external function interface and the third response information.
In a second aspect, the present application provides an automated testing apparatus, comprising:
the test system comprises a calling module, a test module and a control module, wherein the calling module is used for calling a first function interface based on a first test case and receiving first response information returned by the first function interface, the first function interface is an internal function interface, the first response information is used for calling a second function interface, and the second function interface is an external function interface;
the simulation module is used for determining a corresponding target simulation database according to the information category of the first response information, wherein the target simulation database is used for storing response information returned by an external function interface of a target interface type;
and the test module is used for obtaining second response information through the target simulation database and the first response information when the second functional interface is called, obtaining a test result corresponding to the first test case based on the second response information, and the second response information is used for simulating response information returned by the second functional interface.
In a possible implementation manner, the target simulation database stores simulation data corresponding to an external functional interface, the simulation data includes at least one simulation parameter, each simulation parameter corresponds to at least one response message, and the simulation parameter represents the content of a call request sent to the external functional interface; the test module is specifically configured to: generating target simulation parameters based on the first response information; and querying the target simulation database based on the target simulation parameters to obtain the second response information.
In one possible implementation manner, the simulation parameters include simulation parameter items and corresponding simulation parameter values; the first response information comprises a target request parameter item and a request parameter value corresponding to the target request parameter item, and the target request parameter item is used for indicating a simulation parameter item of the simulation parameter; when the test module generates a target simulation parameter based on the first response information, the test module is specifically configured to: determining a corresponding simulation parameter item based on the target request parameter item; inquiring simulation data corresponding to the second functional interface in the target simulation database based on the simulation parameter item to obtain a simulation parameter corresponding to the simulation parameter item; and if the simulation parameter corresponding to the simulation parameter item does not have the request parameter value corresponding to the target request parameter item, generating a target simulation parameter based on the simulation parameter corresponding to the simulation parameter item.
In a possible implementation manner, when the test module queries the target simulation database based on the target simulation parameter to obtain the second response information, the test module is specifically configured to: acquiring a simulation mapping model of the second functional interface, wherein the simulation mapping model represents a mapping rule between input parameters and output parameters of the second functional interface; generating the second response information based on the simulation mapping model and the target simulation parameters.
In a possible implementation manner, before the simulation module calls the first functional interface based on the first test case, the simulation module is further configured to: based on a second test case, sending a calling request to at least one external function interface, and receiving third response information returned by the external function interface; and constructing a simulation database corresponding to each interface type based on the interface type of the external function interface and the corresponding third response information.
In a possible implementation manner, when the simulation module constructs a simulation database corresponding to each interface type based on the interface type of the external functional interface and the corresponding third response information, the simulation module is specifically configured to: sequentially constructing at least one data group aiming at each interface type, wherein the data group consists of a calling request and corresponding third response information; and constructing a corresponding simulation database based on the data group corresponding to each interface type.
In a possible implementation manner, the invocation request includes a request parameter item and a parameter value corresponding to the request parameter item, where the request parameter item is used to indicate a simulation parameter item of the external function interface, and the simulation module is further configured to: and taking the calling request and the corresponding third response information in the data group as samples, training a preset neural network model to converge to obtain a simulation mapping model, wherein the simulation mapping model represents a mapping rule between input parameters and output parameters of the external function interface.
In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively coupled to the processor;
the memory stores computer-executable instructions;
the processor executes computer-executable instructions stored in the memory to implement the automated testing method according to any one of the first aspect of the embodiments of the present application.
In a fourth aspect, the present application provides a computer-readable storage medium having stored thereon computer-executable instructions for implementing the automated testing method according to any one of the first aspect of the embodiments of the present application when the computer-executable instructions are executed by a processor.
According to a fifth aspect of embodiments herein, there is provided a computer program product comprising a computer program which, when executed by a processor, implements an automated testing method as described in any one of the first aspects above.
According to the automatic testing method, the automatic testing device, the electronic equipment and the storage medium, a first function interface is called based on a first test case, and first response information returned by the first function interface is received, wherein the first function interface is an internal function interface, the first response information is used for calling a second function interface, and the second function interface is an external function interface; determining a corresponding target simulation database according to the information category of the first response information, wherein the target simulation database is used for storing response information returned by an external function interface of a target interface type; and when the second functional interface is called, obtaining second response information through the target simulation database and the first response information, and obtaining a test result corresponding to the first test case based on the second response information, wherein the second response information is used for simulating response information returned by the second functional interface. The purpose of executing the internal function interface and the external function interface for testing based on one test case is achieved, meanwhile, the simulation database corresponding to the external function interface is obtained, the test result is obtained under the condition that external services are not actually accessed, and the test effect and the test efficiency are improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and, together with the description, serve to explain the principles of the application.
Fig. 1 is an application scenario diagram of an automated testing method according to an embodiment of the present application;
FIG. 2 is a flow chart of an automated testing method provided in one embodiment of the present application;
fig. 3 is a schematic structural relationship diagram of a target simulation database according to an embodiment of the present disclosure;
FIG. 4 is a flowchart illustrating a specific implementation step of step S103 in the embodiment shown in FIG. 2;
fig. 5 is a flowchart illustrating a specific implementation step of step S1032 in the embodiment shown in fig. 4;
FIG. 6 is a flow chart of an automated testing method provided by another embodiment of the present application;
FIG. 7 is a flowchart illustrating a specific implementation step of step S202 in the embodiment shown in FIG. 6;
FIG. 8 is a schematic structural diagram of an automated testing apparatus according to an embodiment of the present application;
FIG. 9 is a schematic view of an electronic device provided by an embodiment of the present application;
fig. 10 is a block diagram of a terminal device according to an exemplary embodiment of the present application.
Specific embodiments of the present application have been shown by way of example in the drawings and will be described in more detail below. The drawings and written description are not intended to limit the scope of the inventive concepts in any manner, but rather to illustrate the concepts of the application by those skilled in the art with reference to specific embodiments.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary examples do not represent all implementations consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the application, as detailed in the appended claims.
In the technical scheme of the application, the collection, storage, use, processing, transmission, provision, disclosure and other processing of the personal information and the financial data of the related user are all in accordance with the regulations of related laws and regulations and do not violate the good customs of the public order.
The following explains an application scenario of the embodiment of the present application:
fig. 1 is an application scenario diagram of an automated testing method provided in an embodiment of the present application, where the automated testing method provided in the embodiment of the present application may be applied in an automated testing scenario of a system and an application, and more specifically, may be applied in an application scenario of joint debugging testing for an external functional interface and an internal functional interface, as shown in fig. 1, an execution main body of the method provided in the embodiment of the present application may be a testing server, and a code warehouse is disposed in the testing server, where on one hand, the testing server is in communication connection with a terminal device operated by a developer user, the developer user may send a testing instruction to the testing server by operating the terminal device, and the testing server tests a target program code in the code warehouse by running a test case, and returns a testing result to the terminal device; on the other hand, the test server is in communication connection with the external server, and when the external service needs to be called in the process of running the target program code by the test server, the test server communicates with the external server and sends a calling request by calling an external function interface in the target program code, so that response information returned by the external server is obtained, and calling of the external service is realized.
Of course, it can be understood that the method provided in this embodiment may also be applied to other electronic devices that perform similar functions to the test server, such as a general-purpose personal computer, a workstation, and the like, and details thereof are not repeated herein.
In the prior art, the function of the service system needs to be supported by a large amount of external services, and in order to implement the function test of the service system, an interface test is usually performed separately for an external service interface, and after the external service interface is verified separately, the external service interface is shielded to perform an overall system or function test. However, in the process of performing joint debugging test on the functional units of the service system, calls between the functional interfaces have a certain coupling relationship, and a test for each functional interface alone passes, which does not mean that the test can pass when a plurality of interfaces are jointly called. In the prior art, through a scheme of independently verifying an external function interface and shielding the external service interface for joint debugging test, after the external service interface is shielded, only one fixed value is returned no matter what kind of request is used for calling the external service interface, so that the real joint debugging test between an internal function interface and the external function interface cannot be realized, and the problems of low test efficiency and poor test effect are caused.
The following describes the technical solution of the present application and how to solve the above technical problems in detail by specific embodiments. These several specific embodiments may be combined with each other below, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
Fig. 2 is a flowchart of an automated testing method according to an embodiment of the present application, and as shown in fig. 2, the automated testing method according to the embodiment includes the following steps:
step S101, based on a first test case, calling a first function interface and receiving first response information returned by the first function interface, wherein the first function interface is an internal function interface, the first response information is used for calling a second function interface, and the second function interface is an external function interface.
The test case may be a script file for testing a functional unit in the business system, and after the test case is run, the corresponding program code is executed based on the test logic and the test parameters described in the test case, so as to test a target functional unit in the business system. Based on the execution of the first test case, the target program code is operated to sequentially call different functional interfaces so as to realize the functional test of a complete functional unit. Further, in the process of running the object program code, at least a first function interface and a second function interface are sequentially called, where the first function interface is an internal function interface, and the internal function interface refers to an interface provided by a server (i.e., an execution main body of the method provided in this embodiment) for implementing the function of the server, that is, a specific method executed by the server after the first function interface is called, where the method may be a method set in the object program code or a method provided by an operating system of the server, and is not specifically limited here; and the second function interface is an external function interface, the external function interface is an interface for realizing the functions of the server provided by other services running outside the server, after the server calls the external function interface, the external service executes a specific method, and then an execution result is returned to the server, so that the calling process of the external function interface is completed. Specifically, for example, the first test case is used for testing a function of user login in the service system, wherein the first functional interface is used for verifying the validity of a user name, and the specific process is executed locally at the server; the second functional interface is used for verifying whether the user name and the user password are correct or not, and the specific implementation process is executed by an external server.
Illustratively, after calling the first functional interface, the server executes the corresponding internal method function, and obtains a corresponding return value, i.e. first response information, where the first response information is a necessary input for calling the second functional interface, i.e. the first response information determines the subsequently called second functional interface, and simulation parameters used when calling the second functional interface.
And step S102, determining a corresponding target simulation database according to the information category of the first response information, wherein the target simulation database is used for storing the response information returned by the external function interface of the target interface type.
Illustratively, after the first response information returned by the first functional interface is obtained by calling the first functional interface, the corresponding target simulation database is determined based on the information category of the first response information. The information category represents a category to which first response information returned by the first functional interface belongs, the category can be preset, and different forms of first response information have different information types, for example, the first response information is a boolean value returned by the first functional interface and represents two states of "pass" or "fail"; in this case, the first response information corresponds to two information categories, namely, a first category representing "pass" and a second category representing "fail"; when the first response information is information such as character strings, numerical values and the like returned by the first functional interface, the first response information corresponds to different information categories based on different character strings and data; for example, the first functional interface is used to implement query keyword splitting of a query function, and the first response information returned by the first functional interface is a set of one or more character strings, and more specifically, for example, the first response information is: target = { search _ Comd, # bi, # td, # hr }, where search _ Comd identifies that a search task is performed, # bi identifies that a "birthday", # td identifies that a "transaction date", # hr identifies that a "history". Then, based on the content of the first response information, it is obtained that the information category of the first response information is info _ search. The information category may be a predefined category, which may be determined based on the search _ Comd identification.
Further, after the information category of the first response information is obtained, based on preset mapping information, a corresponding target simulation database is obtained and determined, and response information returned by an external function interface storing a target interface type is stored in the target simulation database, for example, the target simulation database is a simulation database a, and simulation information corresponding to an external function interface info _ api _1, an external function interface info _ api _2, and an external function interface info _ api _3 is stored in the simulation database a; the external function interfaces info _ api _1, info _ api _2, and info _ api _3 are external function interfaces for obtaining user information and transaction records, that is, external function interfaces of target interface types.
Further, the simulation data is data for performing interface response simulation on the external functional interface. When the external function interface is normally called, a calling request is sent to the external function interface, and response information can be obtained only after the external function interface is communicated with an external service. And through the simulation data in the simulation database, the corresponding output parameters can be obtained on the basis of the input parameters under the condition of not accessing the external service, and meanwhile, the changed output parameters can be obtained by inputting different input parameters, so that the simulation of the external service access is realized.
In a possible implementation manner, the target simulation database stores simulation data corresponding to the external functional interface, the simulation data includes at least one simulation parameter, each simulation parameter corresponds to at least one response message, and the simulation parameter represents the content of the call request sent to the external functional interface. Fig. 3 is a schematic structural relationship diagram of a target simulation database provided in the embodiment of the present disclosure, as shown in fig. 3, different information types correspond to different simulation databases, where an information type corresponding to a first response information is information type a, and a target simulation database corresponding to the first response information is simulation database DB _1 (simulation database DB _2, simulation database DB _3, and the like are also stored in a server), where the simulation database DB _1 includes simulation data corresponding to a plurality of external function interfaces, for example, external function interface API _1, corresponding simulation data SD _1, external function interface API _2, corresponding simulation data SD _2, external function interface API _3, and corresponding simulation data SD _3. The external function interface API _1 is used for realizing a data query function, the external function interface API _2 is used for realizing an information verification function, and the external function interface API _3 is used for realizing a data modification function. Further, taking the external functional interface API _1 and the corresponding simulation data SD _1 as an example, the simulation data SD _1 includes a plurality of simulation parameters, and each simulation parameter corresponds to a response message, for example, including: the simulation parameter p1 corresponds to the response information R1, such as the simulation parameter p2, and the response information R1 corresponds to the response information R2, such as the simulation parameter p 3. The response information is a response result obtained after calling the corresponding external function interface by taking the simulation parameter as an input parameter. The simulation data, which is the corresponding relationship between the simulation parameter and the response information, may be generated based on a real call record to the external function interface.
Step S103, when the second function interface is called, second response information is obtained through the target simulation database and the first response information, and a test result corresponding to the first test case is obtained based on the second response information, wherein the second response information is used for simulating response information returned by the second function interface.
For example, after the target simulation database is obtained, the target simulation database may implement functional simulation of the second functional interface, when the second functional interface is called, data query is performed through the target simulation database and the first response information, second response information for simulating a normal response result of the second functional interface may be obtained without accessing an external service (without actually calling the second functional interface), and then, a test result corresponding to the first test case may be obtained based on comparison between an expected response recorded in the first test case and the second response information.
Further, in a possible implementation manner, as shown in fig. 4, the specific implementation step of step S103 exemplarily includes:
step S1031: generating target simulation parameters based on the first response information;
step S1032: and querying a target simulation database based on the target simulation parameters to obtain second response information.
Illustratively, after the first response information is obtained, the target simulation parameter, that is, the input parameter when the second function parameter is called, is generated based on the specific content of the first response information. More specifically, for example, the first response information is a parameter required for indicating one query task (implemented by the second functional interface), and specifically includes: out _1= { search _ Comd, # num, # td }, wherein the search _ Comd identifier represents a query task, # num is a user number, # td represents a transaction date, and target simulation parameters generated based on the first response information are { # num, # td }. And then, using the target simulation parameter as input, inquiring a target simulation database determined by the search _ Comm identifier, and searching each simulation parameter in the target simulation database to obtain a response result corresponding to the target simulation parameter, namely second response information.
In the embodiment, the corresponding target simulation parameters are obtained through the first response information, the target simulation database is queried based on the target simulation parameters, the corresponding second response information is obtained, accurate query of the simulation data is achieved, and due to the fact that the step of determining the target simulation database exists, the query process is limited in the target simulation database only, query speed is improved, response errors caused by repeated simulation parameters are reduced, and accuracy of the obtained second response information is improved.
Further, if possible, because the simulation data stored in the target simulation database is limited, the target simulation database cannot provide response information corresponding to the target simulation parameter, for example, the target simulation parameter is used to characterize a transaction record with a user identification number of N0001 and a transaction date of 2022, 02, month and 01, but if the simulation data corresponding to the simulation parameter is not stored in the target simulation database, the target simulation parameter (request) cannot be responded, and the second response information cannot be obtained. That is, there is a problem that it is not guaranteed that the target simulation parameters are valid simulation parameters.
In view of the foregoing problem, this embodiment further provides a scheme, for example, the first response information includes a target request parameter item and a parameter value corresponding to the target request parameter item, where the target request parameter item is used to indicate a simulation parameter item of a simulation parameter, as shown in fig. 5, the specific implementation step of step S1032 includes:
step S1032A: determining a corresponding simulation parameter item based on the target request parameter item;
step S1032B: based on the simulation parameter item, querying simulation data corresponding to a second functional interface in the target simulation database to obtain a simulation parameter corresponding to the simulation parameter item;
step S1032C: and if the simulation parameters corresponding to the simulation parameter items do not have the request parameter values corresponding to the target request parameter items, generating the target simulation parameters based on the simulation parameters corresponding to the simulation parameter items.
Illustratively, the first response information includes a target request parameter item and a parameter value corresponding to the target request parameter item, for example, the first response information is { # num = N0001, # td = 20201}, the first response information characterizes that the user identification code is N0001, the transaction date is 2022 years, 2 months and 1 day, and is used for implementing a transaction record query for the above parameter after the second functional interface is called. Wherein, # num and # td are target request parameter items, and N0001 and 20220201 are corresponding parameter values; in the process of querying the target simulation database, the corresponding simulation parameter item is determined to be # td based on the target request parameter item, and then the simulation data is queried based on the simulation parameter item to obtain the simulation parameter corresponding to the simulation parameter item # td, wherein the simulation parameter item includes { # td = 20202}, { # td = 20203}, { # td = 20220220204 } and the like. In this case, if the simulation parameter corresponding to the simulation parameter item does not have the request parameter value corresponding to the target request parameter item, that is, does not have the simulation parameter { # td =20220201}, one of the simulation parameters included in the simulation data is selected as the target simulation parameter, and for example, { # td = 20202} is selected as the target simulation parameter. Therefore, the target simulation database can normally return response information, the inaccuracy of the response information on a specific numerical value cannot influence the function test process, and the problem is solved.
In this embodiment, a first function interface is called based on a first test case, and first response information returned by the first function interface is received, where the first function interface is an internal function interface, the first response information is used to call a second function interface, and the second function interface is an external function interface; determining a corresponding target simulation database according to the information category of the first response information, wherein the target simulation database is used for storing response information returned by the external function interface of the target interface type; and when the second functional interface is called, obtaining second response information through the target simulation database and the first response information, and obtaining a test result corresponding to the first test case based on the second response information, wherein the second response information is used for simulating response information returned by the second functional interface. The purpose of executing the internal function interface and the external function interface for testing based on one test case is achieved, meanwhile, the simulation database corresponding to the external function interface is obtained, the test result is obtained under the condition that external services are not actually accessed, and the test effect and the test efficiency are improved.
Fig. 6 is a flowchart of an automated testing method according to another embodiment of the present application, and as shown in fig. 6, the automated testing method according to this embodiment further refines step S103 on the basis of the automated testing method according to the embodiment shown in fig. 2, and adds a step of building a simulation database, so that the automated testing method according to this embodiment includes the following steps:
step S201, based on the second test case, sending a call request to at least one external function interface, and receiving third response information returned by the external function interface.
Step S202, based on the interface type of the external function interface and the corresponding third response information, a simulation database corresponding to each interface type is constructed.
Steps S201 to S202 are processes of creating a simulation database, where, for example, a call request is sent to at least one external function interface through a second test case to call the external function interface, so as to obtain third response information returned by each external function interface, and then grouping is performed based on the interface types of the external function interfaces, and the call request and the corresponding third response information are stored as paired data, so that a corresponding simulation database can be obtained.
Illustratively, as shown in fig. 7, the specific implementation steps of step S202 include:
step S2021: at least one data group is sequentially constructed for each interface type, and each data group consists of a calling request and corresponding third response information;
step S2022: and constructing a corresponding simulation database based on the data group corresponding to each interface type.
The data group can be a data structure constructed based on the structure body, and the calling process of different external function interfaces is covered by circularly executing different second test cases, so that the simulation database corresponding to each external function interface is constructed. The call request includes, for example, a request parameter item and a parameter value corresponding to the request parameter item. By constructing the corresponding data group, the simulation database can provide simulation data corresponding to different request parameter items and different parameter values.
Optionally, after step S2022, the method further includes:
step S2023, taking the calling request in the data set and the corresponding third response information as samples, training the preset neural network model to converge, and obtaining a simulation mapping model, where the simulation mapping model represents a mapping rule between the input parameter and the output parameter of the external functional interface.
Illustratively, the simulation database is composed of a data set, in the process of constructing the data set, a preset neural network model is trained based on a mapping relation between a calling request and corresponding third response information in the data set, a simulation mapping model for representing the mapping rule of input parameters and output parameters of an external functional interface can be obtained, output prediction of the external functional interface can be realized by using the simulation mapping model, and accordingly continuously-changed simulation data for the external functional interface is generated to be used as a part of the simulation database.
Step S203, based on the first test case, calling the first function interface, and receiving first response information returned by the first function interface, where the first function interface is an internal function interface, the first response information is used to call the second function interface, and the second function interface is an external function interface.
Step S204, according to the information category of the first response information, determining a corresponding target simulation database, wherein the target simulation database stores simulation data corresponding to the external functional interface, the simulation data comprises at least one simulation parameter, each simulation parameter corresponds to at least one response information, and the simulation parameter represents the content of the call request sent to the external functional interface.
Exemplarily, steps S203 to S204 are processes of calling the first functional interface based on the first test case and determining the target simulation database corresponding to the first functional interface, and the specific implementation manner is described in detail in the embodiment shown in fig. 2, which is not described herein again.
Step S205, generating target simulation parameters based on the first response information.
Step S206, a simulation mapping model of the second functional interface is obtained, and the simulation mapping model represents a mapping rule between input parameters and output parameters of the second functional interface.
And step S207, generating second response information based on the simulation mapping model and the target simulation parameters.
Illustratively, after obtaining the first response information output by the first functional interface, the content of the annotation request parameter in the first response information may be obtained to obtain the target simulation parameter, for example, the first response information out _1= { search _ Comd, # num, # td }, where search _ Comd represents the query task, # num is the user number, # td represents the transaction date, and the target simulation parameter generated based on the first response information is { # num, # td }.
And then, processing the target simulation parameters based on the simulation mapping model obtained in the previous step, and predicting corresponding response information, namely second response information. The specific implementation principle of the simulation mapping model is already introduced in the previous step, and is not described herein again. In the embodiment, the second response information is predicted by simulating the mapping model, so that the performance of the simulation database is not influenced by the quantity of the simulation data any more, the data coverage capability of the simulation database is improved, the second response information which is more accurate can be obtained through training, the occupation of the simulation database on storage resources is reduced, the time consumed by searching is reduced, and the testing efficiency is improved.
And S208, obtaining a test result corresponding to the first test case based on the second response information.
In this embodiment, the implementation manner of step S208 is already described in the embodiment shown in fig. 2, and is not described herein again.
Fig. 8 is a schematic structural diagram of an automated testing apparatus according to an embodiment of the present application, and as shown in fig. 8, an automated test 3 according to the embodiment includes:
the calling module 31 is configured to call a first function interface based on a first test case, and receive first response information returned by the first function interface, where the first function interface is an internal function interface, the first response information is used to call a second function interface, and the second function interface is an external function interface;
the simulation module 32 is configured to determine a corresponding target simulation database according to the information category of the first response information, where the target simulation database is used to store response information returned by the external function interface of the target interface type;
the test module 33 is configured to obtain second response information through the target simulation database and the first response information when the second functional interface is called, and obtain a test result corresponding to the first test case based on the second response information, where the second response information is used to simulate response information returned by the second functional interface.
In a possible implementation manner, the target simulation database stores simulation data corresponding to the external functional interface, the simulation data includes at least one simulation parameter, each simulation parameter corresponds to at least one response message, and the simulation parameter represents the content of the call request sent to the external functional interface; the test module 33 is specifically configured to: generating target simulation parameters based on the first response information; and querying a target simulation database based on the target simulation parameters to obtain second response information.
In one possible implementation, the simulation parameters include simulation parameter items and corresponding simulation parameter values; the first response information comprises a target request parameter item and a request parameter value corresponding to the target request parameter item, and the target request parameter item is used for indicating a simulation parameter item of the simulation parameter; when the test module 33 generates the target simulation parameter based on the first response information, it is specifically configured to: determining a corresponding simulation parameter item based on the target request parameter item; based on the simulation parameter item, querying simulation data corresponding to a second functional interface in the target simulation database to obtain a simulation parameter corresponding to the simulation parameter item; and if the simulation parameters corresponding to the simulation parameter items do not have the request parameter values corresponding to the target request parameter items, generating the target simulation parameters based on the simulation parameters corresponding to the simulation parameter items.
In a possible implementation manner, when querying the target simulation database based on the target simulation parameter to obtain the second response information, the testing module 33 is specifically configured to: acquiring a simulation mapping model of the second functional interface, wherein the simulation mapping model represents a mapping rule between input parameters and output parameters of the second functional interface; and generating second response information based on the simulation mapping model and the target simulation parameters.
In one possible implementation, before invoking the first functional interface based on the first test case, the simulation module 32 is further configured to: based on the second test case, sending a calling request to at least one external function interface, and receiving third response information returned by the external function interface; and constructing a simulation database corresponding to each interface type based on the interface type of the external function interface and the corresponding third response information.
In a possible implementation manner, when the simulation module 32 constructs the simulation database corresponding to each interface type based on the interface type of the external function interface and the corresponding third response information, the simulation module is specifically configured to: at least one data set is sequentially constructed aiming at each interface type, and each data set consists of a calling request and corresponding third response information; and constructing a corresponding simulation database based on the data group corresponding to each interface type.
In a possible implementation manner, the call request includes a request parameter item and a parameter value corresponding to the request parameter item, where the request parameter item is used to indicate a simulation parameter item of the external function interface, and the simulation module 32 is further configured to: and taking the calling request in the data group and the corresponding third response information as samples, training a preset neural network model to converge to obtain a simulation mapping model, and representing a mapping rule between input parameters and output parameters of the external function interface by the simulation mapping model.
The calling module 31, the simulation module 32 and the test module 33 are connected in sequence. The automatic testing device 3 provided in this embodiment may execute the technical solution of the method embodiment shown in any one of fig. 2 to 7, and the implementation principle and the technical effect are similar, and are not described herein again.
Fig. 9 is a schematic diagram of an electronic device according to an embodiment of the present application, and as shown in fig. 9, an electronic device 4 according to the embodiment includes: a processor 41, and a memory 42 communicatively coupled to the processor 41.
Wherein the memory 42 stores computer-executable instructions;
the processor 41 executes computer-executable instructions stored in the memory 42 to implement the automated testing method provided in any one of the embodiments corresponding to fig. 2-7 of the present application.
Wherein the memory 42 and the processor 41 are connected by a bus 43.
The relevant descriptions and effects corresponding to the steps in the embodiments corresponding to fig. 2 to fig. 7 can be understood, and are not described in detail herein.
One embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to implement the automated testing method provided in any one of the embodiments corresponding to fig. 2 to fig. 7 of the present application.
The computer readable storage medium may be, among others, ROM, random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, and the like.
An embodiment of the present application provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the computer program implements the automated testing method provided in any embodiment of fig. 2 to fig. 7 of the present application.
Fig. 10 is a block diagram of a terminal device 800, which may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc., according to an exemplary embodiment of the present application.
Terminal device 800 may include one or more of the following components: a processing component 802, a memory 804, a power component 806, a multimedia component 808, an audio component 810, an input/output (I/O) interface 812, a sensor component 814, and a communication component 816.
The processing component 802 generally controls overall operation of the terminal device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operation at the terminal device 800. Examples of such data include instructions for any application or method operating on terminal device 800, contact data, phonebook data, messages, pictures, videos, and the like. The memory 804 may be implemented by any type or combination of volatile or non-volatile memory devices, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
The power components 806 provide power to the various components of the terminal device 800. Power components 806 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for terminal device 800.
The multimedia component 808 includes a screen providing an output interface between the terminal device 800 and the user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the terminal device 800 is in an operation mode, such as a photographing mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive an external audio signal when the terminal device 800 is in an operation mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal may further be stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
Sensor component 814 includes one or more sensors for providing various aspects of state assessment for terminal device 800. For example, sensor assembly 814 can detect an open/closed state of terminal device 800, the relative positioning of components, such as a display and keypad of terminal device 800, sensor assembly 814 can also detect a change in position of terminal device 800 or a component of terminal device 800, the presence or absence of user contact with terminal device 800, orientation or acceleration/deceleration of terminal device 800, and a change in temperature of terminal device 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object in the absence of any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate communication between the terminal device 800 and other devices in a wired or wireless manner. The terminal device 800 may access a wireless network based on a communication standard, such as WiFi,3G, 4G, 5G, or other standard communication networks, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the terminal device 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), digital Signal Processors (DSPs), digital Signal Processing Devices (DSPDs), programmable Logic Devices (PLDs), field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the methods provided by any of the embodiments corresponding to fig. 2-7 of the present application as described above.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 804 comprising instructions, executable by the processor 820 of the terminal device 800 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
An embodiment of the present application further provides a non-transitory computer-readable storage medium, and when a processor of a terminal device executes instructions in the storage medium, the terminal device 800 is enabled to execute the method provided in any embodiment corresponding to fig. 2 to fig. 7 of the present application.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of modules is merely a division of logical functions, and an actual implementation may have another division, for example, a plurality of modules or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or modules, and may be in an electrical, mechanical or other form.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It will be understood that the present application is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (10)

1. An automated testing method, the method comprising:
calling a first function interface based on a first test case, and receiving first response information returned by the first function interface, wherein the first function interface is an internal function interface, the first response information is used for calling a second function interface, and the second function interface is an external function interface;
determining a corresponding target simulation database according to the information category of the first response information, wherein the target simulation database is used for storing response information returned by an external function interface of a target interface type;
and when the second functional interface is called, obtaining second response information through the target simulation database and the first response information, and obtaining a test result corresponding to the first test case based on the second response information, wherein the second response information is used for simulating response information returned by the second functional interface.
2. The method according to claim 1, wherein the target simulation database stores simulation data corresponding to an external functional interface, the simulation data includes at least one simulation parameter, each simulation parameter corresponds to at least one response message, and the simulation parameter represents the content of a call request sent to the external functional interface; when the second functional interface is called, obtaining second response information through the target simulation database and the first response information, wherein the second response information comprises:
generating target simulation parameters based on the first response information;
and querying the target simulation database based on the target simulation parameters to obtain the second response information.
3. The method of claim 2, wherein the simulation parameters include simulation parameter terms and corresponding simulation parameter values; the first response information comprises a target request parameter item and a request parameter value corresponding to the target request parameter item, wherein the target request parameter item is used for indicating a simulation parameter item of the simulation parameter; generating target simulation parameters based on the first response information comprises:
determining a corresponding simulation parameter item based on the target request parameter item;
inquiring simulation data corresponding to the second functional interface in the target simulation database based on the simulation parameter item to obtain a simulation parameter corresponding to the simulation parameter item;
and if the simulation parameter corresponding to the simulation parameter item does not have the request parameter value corresponding to the target request parameter item, generating a target simulation parameter based on the simulation parameter corresponding to the simulation parameter item.
4. The method of claim 2, wherein said querying said target simulation database based on said target simulation parameters to obtain said second response information comprises:
acquiring a simulation mapping model of the second functional interface, wherein the simulation mapping model represents a mapping rule between input parameters and output parameters of the second functional interface;
and generating the second response information based on the simulation mapping model and the target simulation parameters.
5. The method of claim 1, prior to invoking the first functional interface based on the first test case, further comprising:
based on a second test case, sending a calling request to at least one external function interface, and receiving third response information returned by the external function interface;
and constructing a simulation database corresponding to each interface type based on the interface type of the external function interface and the corresponding third response information.
6. The method of claim 5, wherein constructing a simulation database corresponding to each interface type based on the interface type of the external function interface and the corresponding third response information comprises:
sequentially constructing at least one data group aiming at each interface type, wherein the data group consists of a calling request and corresponding third response information;
and constructing a corresponding simulation database based on the data group corresponding to each interface type.
7. The method according to claim 6, wherein the invocation request includes a request parameter item and a parameter value corresponding to the request parameter item, the request parameter item is used for indicating an emulation parameter item of the external functional interface, and the method further includes:
and taking the calling request in the data set and the corresponding third response information as samples, training a preset neural network model to converge to obtain a simulation mapping model, wherein the simulation mapping model represents a mapping rule between input parameters and output parameters of the external function interface.
8. An automated testing device, comprising:
the test system comprises a calling module, a test module and a control module, wherein the calling module is used for calling a first function interface based on a first test case and receiving first response information returned by the first function interface, the first function interface is an internal function interface, the first response information is used for calling a second function interface, and the second function interface is an external function interface;
the simulation module is used for determining a corresponding target simulation database according to the information category of the first response information, wherein the target simulation database is used for storing response information returned by an external function interface of a target interface type;
and the test module is used for obtaining second response information through the target simulation database and the first response information when the second functional interface is called, obtaining a test result corresponding to the first test case based on the second response information, and the second response information is used for simulating response information returned by the second functional interface.
9. An electronic device, comprising: a processor, and a memory communicatively coupled to the processor;
the memory stores computer execution instructions;
the processor executes computer-executable instructions stored by the memory to implement the automated testing method of any of claims 1-7.
10. A computer-readable storage medium having computer-executable instructions stored thereon for implementing the automated testing method of any one of claims 1 to 7 when executed by a processor.
CN202211183021.2A 2022-09-27 2022-09-27 Automatic testing method and device, electronic equipment and storage medium Pending CN115658476A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211183021.2A CN115658476A (en) 2022-09-27 2022-09-27 Automatic testing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211183021.2A CN115658476A (en) 2022-09-27 2022-09-27 Automatic testing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115658476A true CN115658476A (en) 2023-01-31

Family

ID=84985226

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211183021.2A Pending CN115658476A (en) 2022-09-27 2022-09-27 Automatic testing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115658476A (en)

Similar Documents

Publication Publication Date Title
CN111274131A (en) Interface testing method and device, electronic equipment and storage medium
CN106990989B (en) Method and device for controlling application program installation
CN106126592B (en) Processing method and device for search data
CN111461304A (en) Training method for classifying neural network, text classification method, text classification device and equipment
CN110704030A (en) Interface configuration information generation method and device, electronic equipment and storage medium
CN114428737A (en) Communication method, device, equipment and storage medium based on micro service system
CN115658476A (en) Automatic testing method and device, electronic equipment and storage medium
CN114186894A (en) Project risk detection method and device, electronic equipment and storage medium
CN114372043A (en) Data migration method and device, electronic equipment and storage medium
CN114237784A (en) User interface generation method and device, electronic equipment and storage medium
CN113206772B (en) Method, device, equipment, medium and product for judging correctness of response message
CN115408277B (en) Interface testing method and device
CN112733141B (en) Information processing method and device
CN116015991B (en) Method, device and equipment for testing charging result of charging system
CN116881104A (en) Baffle generation method and device based on transaction, electronic equipment and storage medium
CN109947640B (en) Regression test-based core function coverage statistical method and device
CN114896165A (en) Testing method and device of conversation robot system, electronic equipment and storage medium
CN117149649A (en) Transaction testing method and device and electronic equipment
CN115408277A (en) Interface testing method and device
CN117093486A (en) Interface testing method, device, equipment and storage medium
CN117035973A (en) Method, device, computer equipment and storage medium for identifying public clients
CN116628726A (en) Data testing method, device, equipment and storage medium based on encrypted data
CN115391187A (en) Application testing method, device, system, electronic equipment and storage medium
CN117493460A (en) Data processing method, device and equipment applied to long-protection fund
CN117149742A (en) Data migration testing method and electronic equipment

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