CN113238939A - Test case generation method, device, equipment, storage medium and program - Google Patents

Test case generation method, device, equipment, storage medium and program Download PDF

Info

Publication number
CN113238939A
CN113238939A CN202110512111.0A CN202110512111A CN113238939A CN 113238939 A CN113238939 A CN 113238939A CN 202110512111 A CN202110512111 A CN 202110512111A CN 113238939 A CN113238939 A CN 113238939A
Authority
CN
China
Prior art keywords
access
historical
parameter
group
test values
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
CN202110512111.0A
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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology 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 Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202110512111.0A priority Critical patent/CN113238939A/en
Publication of CN113238939A publication Critical patent/CN113238939A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • 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/3676Test management for coverage analysis

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 application provides a method, a device, equipment, a storage medium and a program for generating a test case, wherein the method comprises the following steps: obtaining a plurality of historical access requests corresponding to an interface to be tested and a historical return result corresponding to each historical access request, wherein each historical access request comprises: determining a plurality of groups of test values according to the historical values of the access parameters in a plurality of historical access requests, wherein each group of test values comprises the test values of the access parameters, and determining an expected return result corresponding to each group of test values according to each group of test values and the historical return results corresponding to the plurality of historical access requests; and determining a plurality of test cases corresponding to the interface to be tested according to the plurality of groups of test values and the expected return result corresponding to each group of test values. The process can improve the generation efficiency of the test case and improve the accuracy of the test case.

Description

Test case generation method, device, equipment, storage medium and program
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a method, an apparatus, a device, a storage medium, and a program for generating a test case.
Background
Generally, a business system includes a plurality of functional modules. Different functional modules can communicate with each other through an interface. In some test scenarios, it is necessary to test the interfaces between different functional modules.
In the prior art, a professional tester manually generates a test case by adopting a plurality of analysis methods according to an interface design document and a test requirement. Wherein, the analysis method may include: an equivalence class classification method, a boundary value analysis method, an orthogonal test method, an error estimation method, a decision table method, and the like.
However, the inventor finds that the method is labor-consuming, time-consuming and inefficient in the process of implementing the application. Moreover, due to different professional degrees of different testers, the accuracy or comprehensiveness of the generated test case cannot be guaranteed.
Disclosure of Invention
The application provides a test case generation method, a test case generation device, a test case generation storage medium and a test case generation program, which are used for improving the test case generation efficiency and improving the test case accuracy.
In a first aspect, the present application provides a method for generating a test case, including:
acquiring a plurality of historical access requests corresponding to an interface to be tested and a historical return result corresponding to each historical access request; wherein each historical access request comprises: historical dereferencing of at least one access parameter corresponding to the interface to be tested;
determining a plurality of groups of test values according to the historical values of the access parameters in the plurality of historical access requests, wherein each group of test values comprises the test values of the access parameters;
determining an expected return result corresponding to each group of test values according to each group of test values and the history return results corresponding to the plurality of history access requests;
and determining a plurality of test cases corresponding to the interface to be tested according to the plurality of groups of test values and the expected return result corresponding to each group of test values, wherein each test case comprises a group of test values and the expected return result corresponding to the group of test values.
In a possible implementation manner, determining multiple groups of test values according to the historical values of each access parameter in the multiple historical access requests includes:
for each access parameter, determining at least one parameter value corresponding to the access parameter according to the historical values of the access parameter in the plurality of historical access requests;
and determining the multiple groups of test values according to the association relationship between the at least one access parameter and the at least one parameter value corresponding to each access parameter.
In a possible implementation manner, determining at least one parameter value corresponding to the access parameter according to the historical value of the access parameter in the multiple historical access requests includes:
determining distance information between any two historical access requests according to the historical values of the access parameters in any two historical access requests;
clustering the plurality of historical access requests according to the distance information to obtain at least one cluster, wherein each cluster comprises at least one historical access request;
and determining at least one parameter value corresponding to the access parameter according to the at least one cluster.
In a possible implementation manner, determining at least one parameter value corresponding to the access parameter according to the at least one cluster includes:
determining a first historical access request corresponding to a cluster center of each cluster;
determining the historical value of the access parameter in the first historical access request as a parameter value corresponding to the cluster;
and determining the parameter value corresponding to each of the at least one cluster as the at least one parameter value corresponding to the access parameter.
In a possible implementation manner, determining distance information between any two historical access requests according to historical values of the access parameter in the any two historical access requests includes:
if the value type of the access parameter is an ordered type, determining distance information between any two historical access requests according to the Euclidean distance between the historical values of the access parameter in any two historical access requests; alternatively, the first and second electrodes may be,
and if the value type of the access parameter is an unordered type, determining distance information between any two historical access requests according to the VDM distance measured by the value difference between the historical values of the access parameter in any two historical access requests.
In a possible implementation manner, determining the plurality of groups of test values according to the association relationship between the at least one access parameter and the at least one parameter value corresponding to each access parameter includes:
determining M groups of access parameters in the at least one access parameter according to the association relationship between the at least one access parameter, wherein each group of access parameters comprises one access parameter or a plurality of access parameters with the association relationship, and M is an integer greater than or equal to 1;
determining at least one group of test values corresponding to each group of access parameters according to each parameter value corresponding to each access parameter in each group of access parameters;
and obtaining the multiple groups of test values according to at least one group of test values corresponding to the M groups of access parameters.
In one possible implementation manner, determining at least one set of test values corresponding to each set of access parameters according to each parameter value corresponding to each access parameter in each set of access parameters includes:
if the group of access parameters comprises one access parameter, respectively generating a group of test values according to each parameter value corresponding to the access parameter in the group of access parameters; alternatively, the first and second electrodes may be,
if the group of access parameters comprises a plurality of access parameters, different parameter values corresponding to the access parameters in the group of access parameters are combined to obtain a plurality of combined results, and a group of test values are respectively generated according to each combined result.
In a possible implementation manner, determining an expected return result corresponding to each group of test values according to each group of test values and a history return result corresponding to the plurality of history access requests includes:
determining whether a target historical access request exists in the plurality of historical access requests, wherein the historical values of the access parameters in the target historical access request are matched with the test values of the access parameters in the group of test values;
and if so, determining the historical return result corresponding to the target historical access request as the expected return result corresponding to the group of test values.
In a possible implementation manner, obtaining a plurality of historical access requests corresponding to an interface to be tested and a historical return result corresponding to each historical access request includes:
acquiring a historical log file corresponding to a service system to which the interface to be tested belongs;
and acquiring a plurality of historical access requests corresponding to the interface to be tested and a historical return result corresponding to each historical access request from the historical log file.
In a second aspect, the present application provides an apparatus for generating a test case, including:
the acquisition module is used for acquiring a plurality of historical access requests corresponding to the interfaces to be tested and historical return results corresponding to each historical access request; wherein each historical access request comprises: historical dereferencing of at least one access parameter corresponding to the interface to be tested;
the first determining module is used for determining a plurality of groups of test values according to the historical values of the access parameters in the historical access requests, wherein each group of test values comprises the test values of the access parameters;
the second determining module is used for determining an expected return result corresponding to each group of test values according to each group of test values and the history return results corresponding to the plurality of history access requests;
and the third determining module is used for determining a plurality of test cases corresponding to the interface to be tested according to the plurality of groups of test values and the expected return result corresponding to each group of test values, wherein each test case comprises a group of test values and the expected return result corresponding to the group of test values.
In a possible implementation manner, the first determining module is specifically configured to:
for each access parameter, determining at least one parameter value corresponding to the access parameter according to the historical values of the access parameter in the plurality of historical access requests;
and determining the multiple groups of test values according to the association relationship between the at least one access parameter and the at least one parameter value corresponding to each access parameter.
In a possible implementation manner, the first determining module is specifically configured to:
determining distance information between any two historical access requests according to the historical values of the access parameters in any two historical access requests;
clustering the plurality of historical access requests according to the distance information to obtain at least one cluster, wherein each cluster comprises at least one historical access request;
and determining at least one parameter value corresponding to the access parameter according to the at least one cluster.
In a possible implementation manner, the first determining module is specifically configured to:
determining a first historical access request corresponding to a cluster center of each cluster;
determining the historical value of the access parameter in the first historical access request as a parameter value corresponding to the cluster;
and determining the parameter value corresponding to each of the at least one cluster as the at least one parameter value corresponding to the access parameter.
In a possible implementation manner, the first determining module is specifically configured to:
if the value type of the access parameter is an ordered type, determining distance information between any two historical access requests according to the Euclidean distance between the historical values of the access parameter in any two historical access requests; alternatively, the first and second electrodes may be,
and if the value type of the access parameter is an unordered type, determining distance information between any two historical access requests according to the VDM distance measured by the value difference between the historical values of the access parameter in any two historical access requests.
In a possible implementation manner, the first determining module is specifically configured to:
determining M groups of access parameters in the at least one access parameter according to the association relationship between the at least one access parameter, wherein each group of access parameters comprises one access parameter or a plurality of access parameters with the association relationship, and M is an integer greater than or equal to 1;
determining at least one group of test values corresponding to each group of access parameters according to each parameter value corresponding to each access parameter in each group of access parameters;
and obtaining the multiple groups of test values according to at least one group of test values corresponding to the M groups of access parameters.
In a possible implementation manner, the first determining module is specifically configured to:
if the group of access parameters comprises one access parameter, respectively generating a group of test values according to each parameter value corresponding to the access parameter in the group of access parameters; alternatively, the first and second electrodes may be,
if the group of access parameters comprises a plurality of access parameters, different parameter values corresponding to the access parameters in the group of access parameters are combined to obtain a plurality of combined results, and a group of test values are respectively generated according to each combined result.
In a possible implementation manner, the second determining module is specifically configured to:
determining whether a target historical access request exists in the plurality of historical access requests, wherein the historical values of the access parameters in the target historical access request are matched with the test values of the access parameters in the group of test values;
and if so, determining the historical return result corresponding to the target historical access request as the expected return result corresponding to the group of test values.
In a possible implementation manner, the obtaining module is specifically configured to:
acquiring a historical log file corresponding to a service system to which the interface to be tested belongs;
and acquiring a plurality of historical access requests corresponding to the interface to be tested and a historical return result corresponding to each historical access request from the historical log file.
In a third aspect, the present application provides an electronic device, comprising: a memory for storing a computer program and a processor for executing the computer program to implement the method according to any of the first aspect.
In a fourth aspect, the present application provides a computer-readable storage medium comprising: a computer program implementing the method according to any one of the first aspect when executed by a processor.
In a fifth aspect, the present application provides a computer program product comprising: a computer program implementing the method according to any one of the first aspect when executed by a processor.
The application provides a method, a device, equipment, a storage medium and a program for generating a test case, wherein the method comprises the following steps: obtaining a plurality of historical access requests corresponding to an interface to be tested and a historical return result corresponding to each historical access request, wherein each historical access request comprises: determining a plurality of groups of test values according to the historical values of the access parameters in the historical access requests, wherein each group of test values comprises the test values of the access parameters, and determining an expected return result corresponding to each group of test values according to each group of test values and the historical return results corresponding to the historical access requests; and determining a plurality of test cases corresponding to the interface to be tested according to the plurality of groups of test values and the expected return result corresponding to each group of test values, wherein each test case comprises a group of test values and the expected return result corresponding to the group of test values. Through the process, on one hand, the test case is automatically generated according to the historical access information corresponding to the interface to be tested, and the generation efficiency of the test case is improved. On the other hand, the test case is generated according to the historical access information of the interface to be tested, so that the test case can cover the real access condition of the interface, and the accuracy of the test case is ensured.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
Fig. 1 is a schematic diagram of an application scenario provided in an embodiment of the present application;
fig. 2 is a schematic flowchart of a method for generating a test case according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a process for determining multiple sets of test values in the embodiment shown in FIG. 2;
fig. 4 is a schematic diagram of a clustering result provided in an embodiment of the present application;
fig. 5 is a schematic diagram of a test case generation process provided in an embodiment of the present application;
fig. 6 is a schematic diagram of another test case generation process provided in the embodiment of the present application;
fig. 7 is a schematic structural diagram of a device for generating a test case according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims of the present application and in the above-described drawings (if any) are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
As described above, in the prior art, when testing each interface in the business system, a professional tester needs to manually generate a test case. Illustratively, professional testers manually generate test cases by using an analysis method such as an equivalence class division method, a boundary value analysis method, an orthogonal test method, an error inference method and a decision table method according to interface design documents and test requirements.
However, the inventor finds that the method is labor-consuming, time-consuming and inefficient in the process of implementing the application. Moreover, the accuracy of the generated test case cannot be guaranteed due to different professional degrees of different testers.
In order to solve at least one of the above technical problems, the present application provides a method, an apparatus, a device, a storage medium, and a program for generating a test case. According to the technical scheme, the historical access request of the interface to be tested and the historical return result corresponding to the historical access request can be obtained, and the test case corresponding to the interface to be tested is automatically generated, so that the generation efficiency of the test case is improved, and the accuracy of the test case is improved.
For ease of understanding, an application scenario of the embodiment of the present application is first described with reference to fig. 1.
Fig. 1 is a schematic diagram of an application scenario provided in an embodiment of the present application. As shown in fig. 1, the application scenario includes a service system and a test case generation apparatus. The service system may be an online service system. The service system comprises a plurality of functional units, and different functional units can communicate with each other through interfaces. For example, as shown in connection with fig. 1, the functional unit 1 may communicate with the functional unit 2 via the interface 1. The functional unit 2 may communicate with the functional unit 3 via the interface 3. The functional unit 1 may also communicate with the functional unit 3 via the interface 2.
During the operation process of the service system, a history log is generated. History information of communications between different functional units may be recorded in the history log. The log file may be stored in a database.
For example, a plurality of historical access requests corresponding to each interface and a historical return result corresponding to each historical access request may be recorded in the log file. Taking interface 1 as an example, if functional unit 1 communicates with functional unit 2 once through interface 1, one history access request and corresponding history return result corresponding to interface 1 are correspondingly generated. The history access request may include a history value of at least one access parameter sent by the functional unit 1 to the functional unit 2. The access result returned by the functional unit 2 to the functional unit 1 may be included in the history return result.
It should be understood that the service system in the embodiment of the present application may be any service system, including but not limited to: e-commerce systems, search systems, financial systems, social systems, and the like.
It should be noted that the interface in this embodiment may be a hardware interface, and may also be a software interface, which is not limited in this embodiment.
In the embodiment of the application, the test case can be automatically generated by the test case generation device. Specifically, when one or more interfaces in the service system need to be tested, the test case generation device may obtain, according to the history log in the database, a plurality of history access requests corresponding to the interfaces to be tested and a history return result corresponding to each history access request, and automatically generate, according to the history access requests and the history return results, the test case corresponding to the interfaces to be tested.
Through the process, on one hand, the automatic generation of the test case is realized, and the generation efficiency of the test case is improved. On the other hand, the test case is generated according to the historical access information of the interface to be tested, so that the test case can cover the real access condition of the interface, and the accuracy of the test case is ensured.
The technical solution of the present application will be described in detail below with specific examples. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments.
Fig. 2 is a flowchart illustrating a method for generating a test case according to an embodiment of the present application. As shown in fig. 2, the method of the present embodiment includes:
s201: acquiring a plurality of historical access requests corresponding to an interface to be tested and a historical return result corresponding to each historical access request; wherein each historical access request comprises: and historical values of at least one access parameter corresponding to the interface to be tested.
As an example, assume that the interface to be tested is a communication interface where the functional unit 1 sends information to the functional unit 2. The history access request may be a request message sent by the functional unit 1 to the functional unit 2 via the interface to be tested. The history return result may be result information that the functional unit 2 returns to the functional unit 1.
In a possible implementation manner, a history log file corresponding to a service system to which an interface to be tested belongs may be obtained, and a plurality of history access requests corresponding to the interface to be tested and a history return result corresponding to each history access request may be obtained from the history log file.
Each historical access request may include a historical value of at least one access parameter corresponding to the interface to be tested. For example, table 1 illustrates historical access requests and historical return results corresponding to the interfaces to be tested. As shown in table 1, it is assumed that the interface to be tested has 3 corresponding access parameters, which are access parameter a, access parameter B, and access parameter C. One historical access request may include: historical values of the access parameter a, historical values of the access parameter B, and historical values of the access parameter C. It should be understood that the historical values of the access parameter a in different historical access requests may be the same or different, the historical values of the access parameter B in different historical access requests may be the same or different, and the historical values of the access parameter C in different historical access requests may be the same or different.
TABLE 1
Access parameter a Access parameter B Access parameter C Historical return results
History access request 1 A1 B1 C1 R1
History access request 1 A2 B2 C2 R2
History access request 1 A3 B3 C3 R3
History access request 1 A4 B4 C4 R4
History access request 1 A5 B5 C5 R5
The at least one access parameter corresponding to the interface to be tested in this embodiment may be an access parameter having code logic. For example, assuming that an interface has 5 access parameters, and only 3 access parameters have code logic in the processing logic of the interface, the subsequent processing may be performed on only the 3 access parameters in this embodiment.
S202: and determining a plurality of groups of test values according to the historical values of the access parameters in the plurality of historical access requests, wherein each group of test values comprises the test values of the access parameters.
In this embodiment, one test case may include: a set of test values and expected return results. Wherein, a group of test values refers to the test values of each access parameter which needs to be input to the interface to be tested. For example, when the interface to be tested corresponds to the access parameter a, the access parameter B, and the access parameter C, a set of test values may include: the test value of the access parameter a, the test value of the access parameter B, and the test value of the access parameter C. The expected return result refers to a result expected to be returned by the interface to be tested.
In this embodiment, a plurality of groups of test values may be determined according to the historical values of the access parameters in the plurality of historical access requests, where each group of test values includes the test value of each access parameter. How to determine the multiple sets of test values is described below in connection with several possible examples.
For example, in conjunction with table 1, the historical values of the access parameters in each historical access request in table 1 may be determined as a set of test values. For example, the sets of test values obtained according to table 1 are:
{ access parameter a ═ a1, access parameter B ═ B1, access parameter C ═ C1}
{ access parameter a ═ a2, access parameter B ═ B2, access parameter C ═ C2}
{ access parameter a ═ a3, access parameter B ═ B3, access parameter C ═ C3}
{ access parameter a ═ a4, access parameter B ═ B4, access parameter C ═ C4}
{ access parameter a ═ a5, access parameter B ═ B5, access parameter C ═ C5}
……
Example two, in some scenarios, duplicate data may be stored in the plurality of obtained historical access requests. For example, as shown in table 1, the historical values of the access parameters in the historical access request 1 and the historical access request 2 are the same (i.e., a1 ═ a2, B1 ═ B2, and C1 ═ C2). In this case, the multiple historical access requests in table 1 may be subjected to deduplication processing, and the historical values of the access parameters in each remaining historical access request may be determined as a group of test values.
In some scenarios, the number of acquired historical access requests may be large, and according to the two manners of the above examples, multiple sets of test values may be generated and compared, and different sets of test values may be similar. It can be understood that if two sets of test values are similar, the two sets of test values are usually repeated tests, which may affect the test efficiency.
In this case, a clustering manner may be first adopted to determine a plurality of representative historical access requests from the plurality of historical access requests, and determine the historical values of the access parameters in each representative historical access request as a group of test values. Therefore, the number of the test cases can be reduced and the test efficiency can be improved while the test cases are ensured to cover the comprehensiveness.
S203: and determining an expected return result corresponding to each group of test values according to each group of test values and the history return results corresponding to the plurality of history access requests.
For each group of test values, the expected return result corresponding to the group of test values can be determined by adopting the following possible implementation manners.
In one possible implementation, it may be determined whether a target historical access request exists in the plurality of historical access requests, and the historical values of the access parameters in the target historical access request are matched with the test values of the access parameters in the set of test values. And if so, determining the historical return result corresponding to the target historical access request as the expected return result corresponding to the group of test values.
For example, in combination with table 1, assuming that a set of test values is { access parameter a is a4, access parameter B is B4, and access parameter C is C4}, since the test value of each access parameter in the set of test values matches the history value of each access parameter in the history access request 4 in table 1, the history access request 4 is determined as the target history access request, and the history return result R4 corresponding to the history access request 4 is determined as the expected return result of the set of test values.
It should be understood that the accuracy of the determined expected return result can be ensured by determining the expected return result corresponding to each group of test values according to the historical return results corresponding to the plurality of historical access requests.
In another possible implementation manner, if there is no target historical access request in the plurality of historical access requests, an expected return result corresponding to the group of test values may be determined according to the group of test values. Illustratively, the set of test values may be analyzed by a professional tester according to the code logic to determine an expected return result corresponding to the set of test values.
S204: and determining a plurality of test cases corresponding to the interface to be tested according to the plurality of groups of test values and the expected return result corresponding to each group of test values, wherein each test case comprises a group of test values and the expected return result corresponding to the group of test values.
Specifically, a test case can be generated according to each group of test values and the expected return result corresponding to the group of test values. For example, assuming that a set of test values is { access parameter a ═ a4, access parameter B ═ B4, and access parameter C ═ C4}, and the expected return result corresponding to the set of test values is R4, the generated test case is as follows:
{ access parameter a ═ a4, access parameter B ═ B4, access parameter C ═ C4, expected return result ═ R4}
In the above manner, a plurality of test cases may be generated. These test cases may be used to test the interface to be tested.
The method for generating the test case provided by the embodiment comprises the following steps: obtaining a plurality of historical access requests corresponding to an interface to be tested and a historical return result corresponding to each historical access request, wherein each historical access request comprises: determining a plurality of groups of test values according to the historical values of the access parameters in the historical access requests, wherein each group of test values comprises the test values of the access parameters, and determining an expected return result corresponding to each group of test values according to each group of test values and the historical return results corresponding to the historical access requests; and determining a plurality of test cases corresponding to the interface to be tested according to the plurality of groups of test values and the expected return result corresponding to each group of test values, wherein each test case comprises a group of test values and the expected return result corresponding to the group of test values. Through the process, on one hand, the test case is automatically generated according to the historical access information corresponding to the interface to be tested, and the generation efficiency of the test case is improved. On the other hand, the test case is generated according to the historical access information of the interface to be tested, so that the test case can cover the real access condition of the interface, and the accuracy of the test case is ensured.
On the basis of the above embodiment, how to determine the plurality of sets of test values is described below with reference to one embodiment. This embodiment may be implemented as one possible implementation manner of S202 in fig. 2.
Fig. 3 is a schematic flow chart of determining multiple sets of test values in the embodiment shown in fig. 2. As shown in fig. 3, the method of the present embodiment includes:
s301: and for each access parameter, determining at least one parameter value corresponding to the access parameter according to the historical values of the access parameter in the plurality of historical access requests.
Assume that the interface to be tested has 3 access parameters, access parameter a, access parameter B, and access parameter C, respectively. Taking the access parameter a as an example, at least one parameter value corresponding to the access parameter a may be determined according to the historical value of the access parameter a in the multiple historical access requests.
In a possible implementation manner, a history value that the access parameter a has taken in the plurality of history access requests may be used as at least one parameter value corresponding to the access parameter a. For example, as shown in table 1, the parameter values corresponding to the access parameter a may include a1, a2, A3, a4, and a 5.
In another possible implementation manner, the following steps (1) to (3) may be adopted to determine at least one parameter value corresponding to the access parameter a.
(1) And determining distance information between any two historical access requests according to the historical values of the access parameter A in any two historical access requests.
Optionally, if the value type of the access parameter a is an ordered type, determining distance information between any two historical access requests according to an euclidean distance between the historical values of the access parameter a in any two historical access requests.
Illustratively, the ordered type of access parameter may be, for example: payment price, weight of goods, purchase amount, etc. When the value type of the access parameter a is an ordered type, the following formula can be used to calculate and obtain the euclidean distance between the history values of the access parameter a in any two history access requests.
Figure BDA0003060679720000131
Wherein p isiRepresenting the historical value, p, of the access parameter A in the historical access request ijShows the historical value, dist (p), of the access parameter A in the historical access request ji,pj) Indicating distance information between the historical access request i and the historical access request j.
Optionally, if the value type of the access parameter a is an unordered type, determining distance information between any two historical access requests according to a Value Difference Measure (VDM) distance between historical values of the access parameter in any two historical access requests.
Illustratively, the unordered type of access parameter may be, for example: commodity type, payment type, distribution mode, etc. When the value type of the access parameter a is an unordered type, the following formula can be used to calculate and obtain the VDM distance between the history values of the access parameter a in any two history access requests.
Figure BDA0003060679720000132
Wherein m isu,aThe number of history access requests with the access parameter A of a in a plurality of history access requests, mu,bFor the number of the historical access requests with the access parameter A taking the value b in the plurality of historical access requests, the plurality of historical access requests can be divided into k groups, mu,a,iNumber of historical access requests with access parameter A in the ith group having value a, mu,b,iThe number of historical access requests with the access parameter A of the ith group being b, p can be 1 or 2, and VDMpAnd (a, b) is the distance between the values a and b of the access parameter A.
(2) And clustering the plurality of historical access requests according to the distance information to obtain at least one cluster. One or more historical access requests are included in each cluster.
It should be understood that a variety of clustering algorithms may be employed to cluster the plurality of historical access requests, including but not limited to: a Density-Based Noise-containing application space Clustering (DBSCAN) algorithm, a K-means Clustering algorithm, a mean shift Clustering algorithm, and the like.
The following describes a process of clustering a plurality of historical access requests by taking a DBSCAN clustering algorithm as an example:
(a) determining a dataset to be clustered D ═ { p1,p2,p3,...,pm},p1To pmAnd (4) historical access requests. A domain radius parameter r is determined, as well as a domain density threshold MinPts.
(b) P in the data set D1To pmThe flag is not accessed.
(c) Randomly selecting an unaccessed historical access request pxA1 is to pxMarked as accessed.
If p isxHas at least MinPts historical access requests in the r field, a new cluster C is created and p is addedxAdding to C; let N be pxR field of (1) a set of historical access requests. For each historical access request p in NyIf p isyNot accessing, then p will beyMarking as accessed, if pyIf there are at least MinPts historical access requests in the r field, adding the historical access requests to N; if p isyIf not, then p isyIs added to the cluster C.
(d) Repeating the step (c) until all the historical access requests in the data set D are accessed.
Through the above steps (a) to (D), the data set D is clustered into k cluster clusters.
Fig. 4 is a schematic diagram of a clustering result provided in an embodiment of the present application. Clustering is performed on the plurality of historical access requests according to the access parameter A, so that a clustering result shown in FIG. 4 is obtained. As shown in fig. 4, taking the example of obtaining 3 cluster clusters, each cluster includes at least one historical access request. The historical values of the access parameter A in the historical access requests in the same cluster are closer to each other.
(3) And determining at least one parameter value corresponding to the access parameter A according to the at least one cluster.
Specifically, a parameter value corresponding to the access parameter a may be determined according to each cluster. Thus, when k cluster clusters are obtained by clustering, k parameter values corresponding to the access parameter A can be determined.
Optionally, for each cluster, a first historical access request corresponding to a cluster center of the cluster is determined, and a historical value of an access parameter a in the first historical access request is determined as a parameter value corresponding to the cluster. In this way, the parameter values corresponding to the k clusters are determined as k parameter values corresponding to the access parameter a.
For example, referring to fig. 4, if the history value of the access parameter a in the first history access request corresponding to the cluster center of the cluster 1 is a1, a1 is used as a parameter value of the access parameter a. Similarly, if the history value of the access parameter a in the first history access request corresponding to the cluster center of the cluster 2 is a2, a2 is used as a parameter value of the access parameter a. And if the historical value of the access parameter A in the first historical access request corresponding to the cluster center of the cluster 3 is A3, taking A3 as a parameter value of the access parameter A. Thus, three parameter values of the access parameter a are determined as follows: a1, a2 and A3.
It should be understood that the above description is made by taking the determination process of the parameter value of the access parameter a as an example. The determination process of the parameter values corresponding to the access parameter B and the access parameter C is similar, and is not described herein again.
S302: and determining a plurality of groups of test values according to the association relationship between the at least one access parameter and the at least one parameter value corresponding to each access parameter.
In this embodiment, in some scenarios, when the interface to be tested corresponds to multiple access parameters, there may be an association relationship between some access parameters in the multiple access parameters. Therefore, when the test case is generated, the test case can be generated according to the incidence relation among the access parameters, and the completeness of the test case is ensured.
In a possible implementation manner, M groups of access parameters may be determined in the at least one access parameter according to an association relationship between the at least one access parameter, where each group of access parameters includes one access parameter, or multiple access parameters having an association relationship, and M is an integer greater than or equal to 1.
In an example, it is assumed that the interface to be tested has 3 access parameters, namely an access parameter a, an access parameter B and an access parameter C. If the access parameter B and the access parameter C have an association relationship, and the access parameter a and the other two access parameters do not have an association relationship, the 3 access parameters may be divided into M-2 groups, where the first group of access parameters includes the access parameter a, and the second group of access parameters includes the access parameter B and the access parameter C.
In the second example, it is assumed that the interface to be tested has 3 access parameters, namely access parameter a, access parameter B and access parameter C. Any two of the 3 access parameters do not have an association relationship, and then the 3 access parameters may be divided into 3 groups, where the first group of access parameters includes an access parameter a, the second group of access parameters includes an access parameter B, and the third group of access parameters includes an access parameter C.
Example three, it is assumed that the interface to be tested has 5 access parameters, which are access parameter a, access parameter B, access parameter C, access parameter D, and access parameter E, respectively. In the above 5 access parameters, the access parameter a has no association with other access parameters, the access parameter B has an association with the access parameter C, and the access parameter D has an association with the access parameter E. The 5 access parameters may be divided into M-3 groups, where the first group includes access parameter a, the second group includes access parameter B and access parameter C, and the third group includes access parameter D and access parameter E.
Further, at least one group of test values corresponding to each group of access parameters is determined according to each parameter value corresponding to each access parameter in each group of access parameters.
And aiming at each group of access parameters, if the group of access parameters comprises one access parameter, respectively generating a group of test values according to each parameter value corresponding to the access parameter in the group of access parameters. If the group of access parameters comprises a plurality of access parameters, different parameter values corresponding to the access parameters in the group of access parameters are combined to obtain a plurality of combined results, and a group of test values are respectively generated according to each combined result.
Thus, according to at least one group of test values corresponding to the M groups of access parameters, a plurality of groups of test values are obtained.
The following is an example in conjunction with the first example described above. The first set of access parameters includes an access parameter a, and the parameter values corresponding to the access parameter a are assumed to include: a1, a2, and A3, three sets of test values may be generated as follows:
{ access parameter a ═ a1, access parameter B ═ arbitrary value, access parameter C ═ arbitrary value }
{ access parameter a ═ a2, access parameter B ═ arbitrary value, access parameter C ═ arbitrary value }
{ access parameter a ═ a3, access parameter B ═ arbitrary value, access parameter C ═ arbitrary value }
It should be understood that, since the access parameter a has no relationship with other access parameters, the access parameter B and the access parameter C may take any values in the above 3 sets of test values.
The second group of access parameters includes an access parameter B and an access parameter C, and it is assumed that the parameter values corresponding to the access parameter B include: b1, B2 and B3, and the access parameter C corresponds to parameter values including: c1, C2, C3. Then, according to the combination result of the parameter value corresponding to the access parameter B and the parameter value corresponding to the access parameter C, 9 sets of test values can be generated, as follows:
{ access parameter a ═ arbitrary value, access parameter B ═ B1, access parameter C ═ C1}
{ access parameter a ═ arbitrary value, access parameter B ═ B2, access parameter C ═ C1}
{ access parameter a ═ arbitrary value, access parameter B ═ B3, access parameter C ═ C1}
{ access parameter a ═ arbitrary value, access parameter B ═ B1, access parameter C ═ C2}
{ access parameter a ═ arbitrary value, access parameter B ═ B2, access parameter C ═ C2}
{ access parameter a ═ arbitrary value, access parameter B ═ B3, access parameter C ═ C2}
{ access parameter a ═ arbitrary value, access parameter B ═ B1, access parameter C ═ C3}
{ access parameter a ═ arbitrary value, access parameter B ═ B2, access parameter C ═ C3}
{ access parameter a ═ arbitrary value, access parameter B ═ B3, access parameter C ═ C3}
Therefore, the two sets of access parameters in the first example finally obtain 12 sets of test values.
In the embodiment, the parameter value corresponding to each access parameter is determined by clustering a plurality of historical access requests, and then a plurality of groups of test values are determined according to the incidence relation among the access parameters and the parameter value corresponding to each access parameter, so that excessive test cases are prevented from being generated, and the accuracy of the test cases is ensured.
On the basis of the above embodiments, the following describes an example of a test case generation process with reference to a specific embodiment.
Fig. 5 is a schematic diagram of a test case generation process provided in an embodiment of the present application. As shown in fig. 5, it is assumed that the interface to be tested has two access parameters, access parameter a and access parameter B. The historical access request and the historical return result corresponding to the interface to be tested, which are obtained from the historical log, are shown in table 2.
TABLE 2
Access parameter a Access parameter B Historical access results
History access request 1 A1 B1 R1
Historical access request 2 A2 B2 R2
Historical access request 3 A3 B3 R3
Historical access request 4 A4 B4 R4
Historical access request 5 A5 B5 R5
Referring to fig. 5, according to each history value of the access parameter a in the history access request, clustering is performed on each history access request, so as to obtain a clustering result corresponding to the access parameter a. Assuming that 3 clustering clusters are obtained by clustering, determining the parameter values of the access parameter A to be A1, A2 and A3 respectively according to the clustering centers of the 3 clustering clusters.
Continuing with fig. 5, according to each history value of the access parameter B in the history access request, clustering is performed on each history access request to obtain a clustering result corresponding to the access parameter B. Assuming that 3 clustering clusters are obtained by clustering, determining the parameter values of the access parameter B as B1, B2 and B3 according to the clustering centers of the 3 clustering clusters.
Assuming that the access parameter A and the access parameter B do not have an association relationship, respectively generating a group of test values according to each parameter value of the access parameter A; and respectively generating a group of test values according to each parameter value of the access parameter B. Wherein, the following 1 st to 3 rd groups of test values are generated according to the parameter value of the access parameter A. The following test values of groups 4 to 6 are generated according to the parameter value of the access parameter B.
Test values in group 1: { access parameter a ═ a1, access parameter B ═ X }
Test values in group 2: { access parameter a ═ a2, access parameter B ═ X }
Test values in group 3: { access parameter a ═ a3, access parameter B ═ X }
Test values in group 4: { access parameter a ═ X, access parameter B ═ B1}
Test values in group 5: { access parameter a ═ X, access parameter B ═ B2}
Test values in group 6: { access parameter a ═ X, access parameter B ═ B3}
In each group of test values, X represents any value.
Further, for each group of test values, an expected return result corresponding to the group of test values may be determined in a manner of matching with each historical access request in table 2, as follows:
the expected return result corresponding to the 1 st group of test values is R1
The expected return result corresponding to the 2 nd group of test values is R2
The expected return result corresponding to the 3 rd group of test values is R3
The expected return result corresponding to the 4 th group of test values is R1
The expected return result corresponding to the 5 th group of test values is R2
The expected return result corresponding to the 6 th group of test values is R3
With continued reference to fig. 5, 6 test cases, which are respectively the test case 1 to the test case 6 in fig. 5, can be generated according to the 6 sets of test values and the expected return results corresponding to the test values.
Fig. 6 is a schematic diagram of another test case generation process provided in the embodiment of the present application. As shown in fig. 6, in this embodiment, the clustering result corresponding to the access parameter a and the clustering result corresponding to the access parameter B are similar to those in fig. 5, and are not described herein again.
In this embodiment, assuming that the access parameter a and the access parameter B have an association relationship, the parameter value of the access parameter a and the parameter value of the access parameter B may be combined, and a group of test values is generated according to each combination result. Because there are 9 possible combination modes, 9 sets of test values can be generated, which are:
test values in group 1: { access parameter a ═ a1, access parameter B ═ B1}
Test values in group 2: { access parameter a ═ a2, access parameter B ═ B1}
Test values in group 3: { access parameter a ═ a3, access parameter B ═ B1}
Test values in group 4: { access parameter a ═ a1, access parameter B ═ B2}
Test values in group 5: { access parameter a ═ a2, access parameter B ═ B2}
Test values in group 6: { access parameter a ═ a3, access parameter B ═ B2}
Test values in group 7: { access parameter a ═ a1, access parameter B ═ B3}
Test values in group 8: { access parameter a ═ a2, access parameter B ═ B3}
Test values in group 9: { access parameter a ═ a3, access parameter B ═ B3}
Further, for each group of test values, an expected return result corresponding to the group of test values may be determined in a manner of matching with each historical access request in table 2, as follows:
the expected return result corresponding to the 1 st group of test values is R1
The expected return result corresponding to the 2 nd group of test values is unknown
The expected return result corresponding to the 3 rd group of test values is unknown
The expected return result corresponding to the 4 th group of test values is unknown
The expected return result corresponding to the 5 th group of test values is R2
The expected return result corresponding to the 6 th group of test values is unknown
The expected return result corresponding to the 7 th group of test values is unknown
The expected return result corresponding to the 8 th group of test values is unknown
The expected return result corresponding to the 9 th group of test values is R3
It should be understood that "unknown" as described above means that the corresponding history return result was not matched in fig. 2. Therefore, for the test values of the groups 2, 3, 4, 6, 7 and 8, the expected return result can be determined through the analysis of professional testers. Assume that the determined expected returns are all RX.
With continued reference to fig. 6, 9 test cases, which are respectively the test case 1 to the test case 9 in fig. 6, can be generated according to the 9 sets of test values and their respective expected return results.
In the test case generation process of the embodiment, on one hand, the test case is automatically generated according to the historical access information corresponding to the interface to be tested, and the generation efficiency of the test case is improved. On the other hand, the test case is generated according to the historical access information of the interface to be tested, so that the test case can cover the real access condition of the interface, and the accuracy of the test case is ensured.
Fig. 7 is a schematic structural diagram of a device for generating a test case according to an embodiment of the present application. The means may be in the form of software and/or hardware. As shown in fig. 7, the apparatus 700 for generating a test case according to this embodiment includes: an obtaining module 701, a first determining module 702, a second determining module 703 and a third determining module 704.
The obtaining module 701 is configured to obtain a plurality of historical access requests corresponding to interfaces to be tested and a historical return result corresponding to each historical access request; wherein each historical access request comprises: historical dereferencing of at least one access parameter corresponding to the interface to be tested;
a first determining module 702, configured to determine multiple groups of test values according to the history values of the access parameters in the multiple history access requests, where each group of test values includes the test value of each access parameter;
a second determining module 703, configured to determine, according to each group of test values and the history return result corresponding to the multiple history access requests, an expected return result corresponding to the group of test values;
a third determining module 704, configured to determine, according to the multiple groups of test values and the expected return result corresponding to each group of test values, multiple test cases corresponding to the interface to be tested, where each test case includes a group of test values and an expected return result corresponding to the group of test values.
In a possible implementation manner, the first determining module 702 is specifically configured to:
for each access parameter, determining at least one parameter value corresponding to the access parameter according to the historical values of the access parameter in the plurality of historical access requests;
and determining the multiple groups of test values according to the association relationship between the at least one access parameter and the at least one parameter value corresponding to each access parameter.
In a possible implementation manner, the first determining module 702 is specifically configured to:
determining distance information between any two historical access requests according to the historical values of the access parameters in any two historical access requests;
clustering the plurality of historical access requests according to the distance information to obtain at least one cluster, wherein each cluster comprises at least one historical access request;
and determining at least one parameter value corresponding to the access parameter according to the at least one cluster.
In a possible implementation manner, the first determining module 702 is specifically configured to:
determining a first historical access request corresponding to a cluster center of each cluster;
determining the historical value of the access parameter in the first historical access request as a parameter value corresponding to the cluster;
and determining the parameter value corresponding to each of the at least one cluster as the at least one parameter value corresponding to the access parameter.
In a possible implementation manner, the first determining module 702 is specifically configured to:
if the value type of the access parameter is an ordered type, determining distance information between any two historical access requests according to the Euclidean distance between the historical values of the access parameter in any two historical access requests; alternatively, the first and second electrodes may be,
and if the value type of the access parameter is an unordered type, determining distance information between any two historical access requests according to the VDM distance measured by the value difference between the historical values of the access parameter in any two historical access requests.
In a possible implementation manner, the first determining module 702 is specifically configured to:
determining M groups of access parameters in the at least one access parameter according to the association relationship between the at least one access parameter, wherein each group of access parameters comprises one access parameter or a plurality of access parameters with the association relationship, and M is an integer greater than or equal to 1;
determining at least one group of test values corresponding to each group of access parameters according to each parameter value corresponding to each access parameter in each group of access parameters;
and obtaining the multiple groups of test values according to at least one group of test values corresponding to the M groups of access parameters.
In a possible implementation manner, the first determining module 702 is specifically configured to:
if the group of access parameters comprises one access parameter, respectively generating a group of test values according to each parameter value corresponding to the access parameter in the group of access parameters; alternatively, the first and second electrodes may be,
if the group of access parameters comprises a plurality of access parameters, different parameter values corresponding to the access parameters in the group of access parameters are combined to obtain a plurality of combined results, and a group of test values are respectively generated according to each combined result.
In a possible implementation manner, the second determining module 703 is specifically configured to:
determining whether a target historical access request exists in the plurality of historical access requests, wherein the historical values of the access parameters in the target historical access request are matched with the test values of the access parameters in the group of test values;
and if so, determining the historical return result corresponding to the target historical access request as the expected return result corresponding to the group of test values.
In a possible implementation manner, the obtaining module 701 is specifically configured to:
acquiring a historical log file corresponding to a service system to which the interface to be tested belongs;
and acquiring a plurality of historical access requests corresponding to the interface to be tested and a historical return result corresponding to each historical access request from the historical log file.
The device for generating a test case provided in this embodiment may be configured to execute the technical solution in any of the method embodiments, and the implementation principle and the technical effect are similar, which are not described herein again.
Fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application. The electronic device may be used to generate test cases. As shown in fig. 8, the electronic device 800 provided in this embodiment includes: a processor 801 and a memory 802.
A memory 802 for storing a computer program; the processor 801 is configured to execute a computer program stored in the memory to implement one or more steps in the method for generating a test case in the foregoing embodiments. Specifically, reference may be made to the related descriptions in the foregoing method embodiments, which have similar implementation principles and technical effects, and this embodiment is not described herein again.
Alternatively, the memory 802 may be separate or integrated with the processor 801.
When the memory 802 is a separate device from the processor 801, the electronic device 800 may further include: a bus 803 for connecting the memory 802 and the processor 801.
An embodiment of the present application further provides a computer-readable storage medium, where the computer-readable storage medium includes a computer program, and the computer program is used to implement one or more steps in the method for generating a test case in any method embodiment, and implement principles and technical effects similar to each other, and are not described herein again.
An embodiment of the present application further provides a chip, including: the test case generating method includes a memory and a processor, where the memory stores a computer program, and the processor runs the computer program to execute one or more steps in the test case generating method in any one of the above method embodiments, and the implementation principle and the technical effect are similar, and are not described herein again.
The embodiments of the present application further provide a computer program product, which includes a computer program, and when the computer program is executed by a processor, the computer program implements one or more steps in the method for generating a test case in any of the above method embodiments, and the implementation principle and the technical effect are similar, and details are not described here.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described device embodiments are merely illustrative, and for example, the division of the modules is only one logical division, and other divisions may be realized in practice, for example, a plurality of modules 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.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present application may be integrated into one processing unit, or each module may exist alone physically, or two or more modules are integrated into one unit. The unit formed by the modules can be realized in a hardware form, and can also be realized in a form of hardware and a software functional unit.
The integrated module implemented in the form of a software functional module may be stored in a computer-readable storage medium. The software functional module is stored in a storage medium and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the methods according to the embodiments of the present application.
It should be understood that the Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in the incorporated application may be directly implemented by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.
The memory may comprise a high-speed RAM memory, and may further comprise a non-volatile storage NVM, such as at least one disk memory, and may also be a usb disk, a removable hard disk, a read-only memory, a magnetic or optical disk, etc.
The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended ISA (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, the buses in the figures of the present application are not limited to only one bus or one type of bus.
The storage medium 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. A storage media may be any available media that can be accessed by a general purpose or special purpose computer.
An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. Of course, the storage medium may also be integral to the processor. The processor and the storage medium may reside in an Application Specific Integrated Circuits (ASIC). Of course, the processor and the storage medium may reside as discrete components in an electronic device or host device.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.

Claims (13)

1. A method for generating a test case is characterized by comprising the following steps:
acquiring a plurality of historical access requests corresponding to an interface to be tested and a historical return result corresponding to each historical access request; wherein each historical access request comprises: historical dereferencing of at least one access parameter corresponding to the interface to be tested;
determining a plurality of groups of test values according to the historical values of the access parameters in the plurality of historical access requests, wherein each group of test values comprises the test values of the access parameters;
determining an expected return result corresponding to each group of test values according to each group of test values and the history return results corresponding to the plurality of history access requests;
and determining a plurality of test cases corresponding to the interface to be tested according to the plurality of groups of test values and the expected return result corresponding to each group of test values, wherein each test case comprises a group of test values and the expected return result corresponding to the group of test values.
2. The method of claim 1, wherein determining multiple sets of test values according to historical values of access parameters in the plurality of historical access requests comprises:
for each access parameter, determining at least one parameter value corresponding to the access parameter according to the historical values of the access parameter in the plurality of historical access requests;
and determining the multiple groups of test values according to the association relationship between the at least one access parameter and the at least one parameter value corresponding to each access parameter.
3. The method of claim 2, wherein determining at least one parameter value corresponding to the access parameter according to the historical value of the access parameter in the plurality of historical access requests comprises:
determining distance information between any two historical access requests according to the historical values of the access parameters in any two historical access requests;
clustering the plurality of historical access requests according to the distance information to obtain at least one cluster, wherein each cluster comprises at least one historical access request;
and determining at least one parameter value corresponding to the access parameter according to the at least one cluster.
4. The method of claim 3, wherein determining at least one parameter value corresponding to the access parameter according to the at least one cluster comprises:
determining a first historical access request corresponding to a cluster center of each cluster;
determining the historical value of the access parameter in the first historical access request as a parameter value corresponding to the cluster;
and determining the parameter value corresponding to each of the at least one cluster as the at least one parameter value corresponding to the access parameter.
5. The method of claim 3, wherein determining distance information between any two historical access requests according to historical values of the access parameter in the any two historical access requests comprises:
if the value type of the access parameter is an ordered type, determining distance information between any two historical access requests according to the Euclidean distance between the historical values of the access parameter in any two historical access requests; alternatively, the first and second electrodes may be,
and if the value type of the access parameter is an unordered type, determining distance information between any two historical access requests according to the VDM distance measured by the value difference between the historical values of the access parameter in any two historical access requests.
6. The method according to any one of claims 2 to 5, wherein determining the plurality of sets of test values according to the association relationship between the at least one access parameter and the at least one parameter value corresponding to each access parameter includes:
determining M groups of access parameters in the at least one access parameter according to the association relationship between the at least one access parameter, wherein each group of access parameters comprises one access parameter or comprises a plurality of access parameters with the association relationship, and M is an integer greater than or equal to 1;
determining at least one group of test values corresponding to each group of access parameters according to each parameter value corresponding to each access parameter in each group of access parameters;
and obtaining the multiple groups of test values according to at least one group of test values corresponding to the M groups of access parameters.
7. The method of claim 6, wherein determining at least one set of test values corresponding to each set of access parameters according to the respective parameter value corresponding to each access parameter in each set of access parameters comprises:
if the group of access parameters comprises one access parameter, respectively generating a group of test values according to each parameter value corresponding to the access parameter in the group of access parameters; alternatively, the first and second electrodes may be,
if the group of access parameters comprises a plurality of access parameters, different parameter values corresponding to the access parameters in the group of access parameters are combined to obtain a plurality of combined results, and a group of test values are respectively generated according to each combined result.
8. The method of any one of claims 1 to 5, wherein determining the expected return result corresponding to each set of test values according to each set of test values and the historical return result corresponding to the plurality of historical access requests comprises:
determining whether a target historical access request exists in the plurality of historical access requests, wherein the historical values of the access parameters in the target historical access request are matched with the test values of the access parameters in the group of test values;
and if so, determining the historical return result corresponding to the target historical access request as the expected return result corresponding to the group of test values.
9. The method according to any one of claims 1 to 5, wherein obtaining a plurality of historical access requests corresponding to the interface to be tested and a historical return result corresponding to each historical access request comprises:
acquiring a historical log file corresponding to a service system to which the interface to be tested belongs;
and acquiring a plurality of historical access requests corresponding to the interface to be tested and a historical return result corresponding to each historical access request from the historical log file.
10. An apparatus for generating a test case, comprising:
the acquisition module is used for acquiring a plurality of historical access requests corresponding to the interfaces to be tested and historical return results corresponding to each historical access request; wherein each historical access request comprises: historical dereferencing of at least one access parameter corresponding to the interface to be tested;
the first determining module is used for determining a plurality of groups of test values according to the historical values of the access parameters in the historical access requests, wherein each group of test values comprises the test values of the access parameters;
the second determining module is used for determining an expected return result corresponding to each group of test values according to each group of test values and the history return results corresponding to the plurality of history access requests;
and the third determining module is used for determining a plurality of test cases corresponding to the interface to be tested according to the plurality of groups of test values and the expected return result corresponding to each group of test values, wherein each test case comprises a group of test values and the expected return result corresponding to the group of test values.
11. An electronic device, comprising: a memory for storing a computer program and a processor for executing the computer program to implement the method of any one of claims 1 to 9.
12. A computer-readable storage medium, comprising: computer program which, when executed by a processor, implements the method of any one of claims 1 to 9.
13. A computer program product, comprising: computer program which, when executed by a processor, implements the method of any one of claims 1 to 9.
CN202110512111.0A 2021-05-11 2021-05-11 Test case generation method, device, equipment, storage medium and program Pending CN113238939A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110512111.0A CN113238939A (en) 2021-05-11 2021-05-11 Test case generation method, device, equipment, storage medium and program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110512111.0A CN113238939A (en) 2021-05-11 2021-05-11 Test case generation method, device, equipment, storage medium and program

Publications (1)

Publication Number Publication Date
CN113238939A true CN113238939A (en) 2021-08-10

Family

ID=77133465

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110512111.0A Pending CN113238939A (en) 2021-05-11 2021-05-11 Test case generation method, device, equipment, storage medium and program

Country Status (1)

Country Link
CN (1) CN113238939A (en)

Similar Documents

Publication Publication Date Title
CN110991474A (en) Machine learning modeling platform
CN110060053B (en) Identification method, equipment and computer readable medium
CN107622326A (en) User's classification, available resources Forecasting Methodology, device and equipment
CN110737917A (en) Data sharing device and method based on privacy protection and readable storage medium
US20220229854A1 (en) Constructing ground truth when classifying data
CN110929525A (en) Network loan risk behavior analysis and detection method, device, equipment and storage medium
CN112434884A (en) Method and device for establishing supplier classified portrait
CN109165947B (en) Account information determination method and device and server
CN113609020A (en) Test case recommendation method and device
CN112882956A (en) Method and device for automatically generating full-scene automatic test case through data combination calculation, storage medium and electronic equipment
CN111400695B (en) Equipment fingerprint generation method, device, equipment and medium
CN109857816B (en) Test sample selection method and device, storage medium and electronic equipment
CN112148880A (en) Customer service dialogue corpus clustering method, system, equipment and storage medium
CN113238939A (en) Test case generation method, device, equipment, storage medium and program
CN110728585A (en) Authority guaranteeing method, device, equipment and storage medium
CN112613762B (en) Group rating method and device based on knowledge graph and electronic equipment
CN109670976B (en) Feature factor determination method and device
CN114511409A (en) User sample processing method and device and electronic equipment
CN114418776A (en) Data processing method, device, terminal equipment and medium
CN113094615B (en) Message pushing method, device, equipment and storage medium
CN114116799A (en) Abnormal transaction loop identification method, device, terminal and storage medium
CN113656354A (en) Log classification method, system, computer device and readable storage medium
CN111932142A (en) Method, device, equipment and storage medium for scheme grouping and data grouping
CN114820003A (en) Pricing information abnormity identification method and device, electronic equipment and storage medium
CN117808441B (en) Bid information checking method and system

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