Generation method and device of interface test case, storage medium and computer equipment
By automatically identifying and adapting the field changes of the interface, the test cases of the associated interface are generated, which solves the problems of low generation efficiency and low accuracy in the prior art, and achieves more efficient and accurate test case generation.
Patent Information
- Application Number
- CN202411789316.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2025-05-06
AI Technical Summary
In the prior art, the way of manually determining the associated interface of the interface and regenerating the test cases results in low generation efficiency and low accuracy, and prone to code writing errors.
By responding to the field information change signal of the current interface, obtaining the initial and change field information, determining the associated interface and its test cases, calculating the field difference information, and adapting and adjusting the initial test cases to generate the test cases of the associated interface.
Improve the efficiency and accuracy of interface test cases generation, avoiding errors and waste of time caused by manual code writing.
Smart Images

Figure CN119938514A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information technology, and in particular to a method, device, storage medium and computer equipment for generating an interface test case. Background Art
[0002] The interface defines the data exchange and communication methods between system modules, making the interaction between modules clearer and more explicit. In order to verify the interface function and improve the system stability, it is necessary to generate interface test cases to test the interface.
[0003] At present, the associated interfaces of a certain interface are usually determined manually, and the test cases of the associated interfaces are regenerated by manually writing complete codes. However, if the test cases of the associated interfaces are maintained only because a certain interface field is changed, this method of manually rewriting the entire test case will lead to low test case generation efficiency. At the same time, due to the uneven technical level of the staff, it will also lead to code writing errors, resulting in low test case generation accuracy. Summary of the invention
[0004] The present invention provides a method, device, storage medium and computer equipment for generating an interface test case, which are mainly capable of improving the generation efficiency and generation accuracy of the interface test case.
[0005] According to a first aspect of the present invention, there is provided a method for generating an interface test case, comprising:
[0006] In response to a field information change signal of the current interface, obtaining initial field information before the change and changed field information after the change of the field information corresponding to the current interface;
[0007] Based on the initial field information, determining an associated interface associated with the current interface, and determining an initial associated test case of the associated interface;
[0008] Determine the associated field information of the associated interface, and determine the field difference information between the changed field information and the associated field information;
[0009] Based on the field difference information, the initial associated test case is adapted and adjusted for the associated interface test to obtain an associated test case for the associated interface.
[0010] Optionally, the determining, based on the initial field information, an associated interface associated with the current interface includes:
[0011] Determine a standard field feature vector corresponding to each standard field in a preset association interface configuration table, wherein the preset association interface configuration table stores different standard fields and their corresponding standard association interfaces;
[0012] Determine an initial field feature vector corresponding to the initial field information, and match the initial field information with each of the standard fields based on the initial field feature vector and the standard field feature vector to obtain a matching result;
[0013] Based on the matching result, a target standard field matching the initial field information is determined in each of the standard fields, and a standard associated interface corresponding to the target standard field is determined as an associated interface associated with the current interface.
[0014] Optionally, before determining an associated interface associated with the current interface based on the initial field information, the method further includes:
[0015] Obtaining interface document information in different interfaces, and parsing the interface document information to obtain field information in different interfaces;
[0016] Determine the field feature vectors corresponding to the field information in different interfaces, and match the field information in different interfaces based on the field feature vectors to obtain standard fields that meet the matching conditions in different interfaces, and determine the multiple interfaces to which the standard fields belong as standard associated interfaces;
[0017] Based on the standard fields and their corresponding standard associated interfaces, a preset associated interface configuration table is constructed.
[0018] Optionally, before determining the initial associated test case of the associated interface, the method further includes:
[0019] Determine interface document information of different interfaces, and determine call interface parameter sets of different interfaces based on the interface document information, wherein the call interface parameter set is composed of multiple call interface parameter subsets;
[0020] Clustering each of the calling interface parameter subsets to obtain calling interface parameter subsets under different request mode clusters;
[0021] Determine user input information corresponding to different interfaces, and construct test case templates under different request mode clusters corresponding to different interfaces based on the user input information and the calling interface parameter subsets under each request mode cluster, wherein the test case templates contain general test information and personalized test information title items;
[0022] Determine the field type of the pre-filled field corresponding to the personalized test information title item, the business logic information of different interfaces, and the format requirement information of different interfaces for the pre-filled field;
[0023] Based on the field type of the pre-filled field, the business logic information of different interfaces, and the format requirement information of different interfaces for the pre-filled field, personalized test information is filled in the preset position corresponding to the personalized test information title item in the test case template to obtain initial associated test cases for different interfaces under different request methods.
[0024] Optionally, clustering the call interface parameter subsets to obtain call interface parameter subsets under different request mode clusters includes:
[0025] Initialize the centroid vectors corresponding to the clusters of different request modes, and determine the interface parameter feature vectors corresponding to each of the calling interface parameter subsets;
[0026] Calculating the distance between the interface parameter feature vector and the centroid vector corresponding to the different request mode clusters, and based on the distance, dividing each of the call interface parameter subsets into the different request mode clusters;
[0027] Determine updated centroid vectors corresponding to the different request mode clusters based on interface parameter feature vectors corresponding to the calling interface parameter subsets in the different request mode clusters;
[0028] Based on the updated centroid vector, each of the calling interface parameter subsets is re-divided into the different request mode clusters until the updated centroid vector does not change, and the calling interface parameter subsets finally divided into the different request mode clusters are determined as the calling interface parameter subsets under the different request mode clusters.
[0029] Optionally, the adapting and adjusting the initial associated test case for the associated interface test based on the field difference information to obtain an associated test case for the associated interface includes:
[0030] Determine the interface function information of the current interface and the field constraint information for the initial field information, the associated interface function information of the associated interface and the associated field constraint information for the associated field information, and the dependency relationship information between the current interface and the associated interface;
[0031] Determine function difference information based on the interface function information and the associated interface function information, and determine field constraint difference information based on the field constraint information and the associated field constraint information;
[0032] Based on the field difference information, the function difference information, the field constraint difference information, and the dependency information, the initial associated test case is adapted and adjusted for the associated interface test to obtain an associated test case for the associated interface.
[0033] Optionally, the method further comprises:
[0034] Get the initial test case of the current interface;
[0035] Parsing the field information change signal to obtain the field change type of the current interface, wherein the field change type includes: at least one of a field range change type, a field default value change type, a field name change type, a field type change type, a field constraint change type, and a field description change type;
[0036] Based on the field change type, determining an adaptation adjustment method for the initial test case to test the current interface after the field change;
[0037] The initial test case is adjusted using the adaptation adjustment method to obtain a test case corresponding to the current interface after the field is changed.
[0038] According to a second aspect of the present invention, there is provided a device for generating an interface test case, comprising:
[0039] An acquiring unit, configured to acquire, in response to a field information change signal of a current interface, initial field information before the change and changed field information after the change of the field information corresponding to the current interface;
[0040] A first determining unit, configured to determine an associated interface associated with the current interface based on the initial field information, and determine an initial associated test case of the associated interface;
[0041] a second determining unit, configured to determine associated field information of the associated interface, and determine field difference information between the changed field information and the associated field information;
[0042] An adjustment unit is used to adapt the initial associated test case for the associated interface test based on the field difference information to obtain an associated test case for the associated interface.
[0043] According to a third aspect of the present invention, there is provided a computer-readable storage medium having a computer program stored thereon, which implements the above method for generating interface test cases when executed by a processor.
[0044] According to a fourth aspect of the present invention, there is provided a computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the above method for generating interface test cases when executing the program.
[0045] According to a method, device, storage medium and computer equipment for generating interface test cases provided by the present invention, compared with the current method of manually determining the associated interface of a certain interface and manually writing complete code to regenerate the test case of the associated interface, the present invention obtains the initial field information of the field information corresponding to the current interface before the change and the changed field information after the change by responding to the field information change signal of the current interface; and based on the initial field information, determines the associated interface associated with the current interface, and determines the initial associated test case of the associated interface; then determines the associated field information of the associated interface, and determines the field difference information between the changed field information and the associated field information; finally, based on the field difference information, adapts the initial associated test case for the associated interface test to obtain the associated test case of the associated interface. Therefore, the present invention determines the associated interface associated with the interface through the initial field information of the current interface, which can avoid the problem of determination errors and low determination efficiency caused by manual determination of the associated interface, so that the present invention can improve the determination efficiency and accuracy of the associated interface. At the same time, the present invention adjusts the initial associated test case in the associated interface according to the difference information between the changed field information of the current interface and the associated field information of the associated interface, so as to generate an associated test case for the associated interface, which can avoid the waste of time and code writing errors caused by manually writing code to regenerate the entire test case, so that the present invention can improve the generation efficiency and accuracy of interface test cases. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0047] Figure 1 A flow chart of a method for generating an interface test case provided by an embodiment of the present invention is shown;
[0048] Figure 2 A flow chart of another method for generating interface test cases provided by an embodiment of the present invention is shown;
[0049] Figure 3 A schematic diagram of the structure of a device for generating interface test cases provided by an embodiment of the present invention is shown;
[0050] Figure 4A schematic diagram showing the structure of another device for generating interface test cases provided by an embodiment of the present invention;
[0051] Figure 5 A schematic diagram of the physical structure of a computer device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0052] The present invention will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other without conflict.
[0053] Currently, manually determining the associated interfaces of a certain interface and regenerating test cases of the associated interfaces by manually writing complete codes will result in low test case generation efficiency and low generation accuracy.
[0054] In order to solve the above problems, an embodiment of the present invention provides a method for generating an interface test case, such as Figure 1 As shown, the method includes:
[0055] 101. In response to a field information change signal of a current interface, obtain initial field information before the change and changed field information after the change of field information corresponding to the current interface.
[0056] Among them, field information refers to the information of the instance fields of the class that implements the interface, or the information involved in the interface method parameters and return values; field information includes field value, field name, data type, field length, constraints, default value, field description and other information.
[0057] For the embodiment of the present invention, the change of field information may be a change in the range of field values, a change in the field type, a change in the field name, a change in the field length, a change in the field constraint, a change in the field default value, a change in the field description, etc., or when the current interface changes, the field of the interface is affected. For example, if the change of field information is a change in the range of field values, the field value A corresponding to the current interface is an enumeration type, the initial field information of the field value A before the range change is {'red', 'green', 'blue'}, and the changed field information after the change is {'red', 'green', 'blue', 'purple'}; if the change of field information is a change in the field constraint condition, the initial field information of field A before the constraint condition change is: "field unique constraint and field non-null constraint", and the changed field information after the change is: "field unique constraint"; if the change of field information is a change in the field length, the initial field information of the field before the range change is VARCHAR(20), and the changed field information after the change is VARCHAR(30).
[0058] 102. Based on the initial field information, determine an associated interface associated with the current interface, and determine an initial associated test case of the associated interface.
[0059] Among them, the associated interface is an interface that is mutually dependent or interacts with the current interface in business logic or data flow. There is a relationship such as data transfer or function call between the current interface and the associated interface. For example, the data obtained in the current interface request can be used as input parameters for the request in the associated interface.
[0060] For the embodiment of the present invention, the field value in the initial field information can be used to search for interfaces with the same field value as the field value in other interfaces, and the interface with the same field value can be determined as an associated interface associated with the current interface, and the associated test case corresponding to the associated interface can be obtained through the correspondence between the pre-constructed initial test case and different interfaces. Therefore, the embodiment of the present invention automatically identifies the associated interface through the initial field information, which can avoid the time wasted and the selection errors caused by manually selecting the associated interface, so that the embodiment of the present invention can improve the determination efficiency and accuracy of the associated interface.
[0061] 103. Determine the associated field information of the associated interface, and determine the field difference information between the changed field information and the associated field information.
[0062] For the embodiment of the present invention, the associated field information is field information that is the same as or similar to the initial field information. For example, if the field value range is changed, if the initial field information is {'red', 'green', 'blue'}, the changed field information is {'red', 'green', 'blue', 'purple'}, and the associated field information is {'red', 'green', 'blue'}, then the field difference information is {'purple'}. If the field constraint is changed, and the initial field information is: "field unique constraint and field non-null constraint", the changed field information is "field unique constraint", and the associated field information is "field unique constraint and field non-null constraint", then the field difference information is that the "field non-null constraint" in the original associated field information is deleted. If the field length is changed, and the initial field information is VARCHAR(20), the changed field information is VARCHAR(30), and the associated field information is VARCHAR(20), then the field difference information is that the field length is increased by 10.
[0063] 104. Based on the field difference information, the initial associated test case is adapted and adjusted for the associated interface test to obtain an associated test case of the associated interface.
[0064] For the embodiment of the present invention, since the field change may affect the data exchange and business logic processing between interfaces, in two associated interfaces, when the field in one interface changes, it is usually necessary to adjust the test case of the other interface, and use the adjusted test case to verify the performance of the associated interface, so as to ensure the reliable operation of the associated interface. Based on this, after determining the field difference information between the changed field information and the associated field information, it is necessary to adjust the test case of the associated interface based on the field difference information. The specific adjustment method is as follows: Field name change: If the field name referenced in the current interface changes, then according to the changed field difference information, all places involving the field name in the initial test case of the associated interface need to be updated, including request parameters, response data, assertion conditions, etc. Field type change: The change of the field type may affect the format and parsing method of the data. Therefore, if the field type referenced in the current interface changes (for example, from a string to an integer), the format and type assertion of the data need to be adjusted accordingly in the initial associated test case of the associated interface. Field length change: For fields of string or text type, if the length limit has changed, the initial association test case in the associated interface needs to ensure that the data sent does not exceed the new length limit and verify whether the response data meets the new length requirement. Field constraint change: If the constraint of the field in the current interface has changed (for example, a unique constraint or a non-null constraint has been added), the initial association test case in the associated interface needs to adjust the data input and assertion conditions accordingly to ensure the validity and consistency of the data. Field default value change: If the default value of the field in the current interface has changed, the initial association test case in the associated interface needs to verify whether the interface is processed according to the new default value when the field value is not provided. Field deletion: If a field referenced in the current interface is deleted, the initial association test case in the associated interface needs to remove all references to the field and verify whether the interface behaves as expected when the field is missing. Field addition: If a field is added to the current interface, the initial association test case of the associated interface needs to add validation for the field, including assertions for data input and response data. Field order change: If the field order in the current interface changes (for example, when using a specific serialization format), the data input and assertion conditions of the initial associated test case in the associated interface need to be adjusted. Therefore, the present invention adjusts the initial associated test case in the associated interface according to the difference information between the changed field information of the current interface and the associated field information of the associated interface, thereby generating an associated test case of the associated interface, which can avoid wasting time and code writing errors caused by manually writing code to regenerate the entire test case, so that the present invention can improve the generation efficiency and generation accuracy of interface test cases.
[0065] According to a method for generating an interface test case provided by the present invention, compared with the current method of manually determining the associated interface of a certain interface and manually writing complete code to regenerate the test case of the associated interface, the present invention obtains the initial field information of the field information corresponding to the current interface before the change and the changed field information after the change by responding to the field information change signal of the current interface; and based on the initial field information, determines the associated interface associated with the current interface, and determines the initial associated test case of the associated interface; then determines the associated field information of the associated interface, and determines the field difference information between the changed field information and the associated field information; finally, based on the field difference information, adapts the initial associated test case for the associated interface test to obtain the associated test case of the associated interface. Therefore, the present invention determines the associated interface associated with the interface through the initial field information of the current interface, which can avoid the problem of determination errors and low determination efficiency caused by manual determination of the associated interface, so that the present invention can improve the determination efficiency and accuracy of the associated interface. At the same time, the present invention adjusts the initial associated test case in the associated interface according to the difference information between the changed field information of the current interface and the associated field information of the associated interface, so as to generate an associated test case for the associated interface, which can avoid the waste of time and code writing errors caused by manually writing code to regenerate the entire test case, so that the present invention can improve the generation efficiency and accuracy of interface test cases.
[0066] Further, in order to better illustrate the process of generating the interface test case, as a refinement and extension of the above embodiment, the embodiment of the present invention provides another method for generating an interface test case, such as Figure 2 As shown, the method includes:
[0067] 201. In response to a field information change signal of a current interface, obtain initial field information before the change and changed field information after the change of field information corresponding to the current interface.
[0068] Specifically, when field information of a certain interface is changed, in order to adjust the test cases of the interface associated with the interface, it is first necessary to determine the initial field information of the interface before the field change and the changed field information after the field change.
[0069] 202. Determine a standard field feature vector corresponding to each standard field in a preset associated interface configuration table.
[0070] 203. Determine an initial field feature vector corresponding to the initial field information, and match the initial field information with each standard field based on the initial field feature vector and the standard field feature vector to obtain a matching result.
[0071] 204. Based on the matching result, determine a target standard field that matches the initial field information in each standard field, and determine a standard associated interface corresponding to the target standard field as an associated interface associated with the current interface.
[0072] The preset associated interface configuration table stores different standard fields and their corresponding standard associated interfaces.
[0073] For the embodiments of the present invention, in order to improve the efficiency of determining associated interfaces, it is first necessary to construct a preset associated interface configuration table. Based on this, the method includes: obtaining interface document information in different interfaces, and parsing the interface document information to obtain field information in different interfaces; determining field feature vectors corresponding to field information in different interfaces, and matching field information in different interfaces based on the field feature vectors to obtain standard fields that meet matching conditions in different interfaces, and determining multiple interfaces to which the standard fields belong as standard associated interfaces; constructing a preset associated interface configuration table based on the standard fields and their corresponding standard associated interfaces.
[0074] The interface document information refers to a document used to describe and record detailed information of each interface in a software system. The interface document information includes field information, interface request information, response information, etc.
[0075] Specifically, the part describing the request information, such as the request method, URL, request parameters and request body, is determined in the interface document information of different interfaces, and all request parameters are listed, including name, type (such as string, integer, Boolean value, etc.), whether it is required, description and possible value range or sample value. If the interface accepts the request body (such as POST, PUT method), the structure of the request body is parsed, and each field in the request body is extracted, including their name, type, description and possible nested fields, so as to obtain the field information in the request body. At the same time, the part describing the response information can also be determined in the interface document, such as including the response status code, response header and response body, the structure of the response body is parsed, and the name, type, description and possible nested fields of each field are extracted. Pay attention to check whether the response body has different states or conditions (such as successful response, error response, etc.), and extract the field information under these states respectively, so as to obtain the field information in the response body. Further, the field feature vector of the field information is determined by using word embedding and other methods, and based on the field feature vector, the fields in different interfaces are matched for similarity, so as to find the matching fields that meet the requirements of similarity, and the interface corresponding to the matching field is determined as the associated interface. For example, if the field information in interface 1 and interface 4 meets the matching conditions (matching conditions such as the similarity between two fields is greater than 98%), interface 4 is determined as the associated interface of interface 1, or interface 1 is determined as the associated interface of interface 4. At this time, the field information in interface 1 and the field information in interface 4 can be unified into the same standard field, and a corresponding relationship can be established between the standard field and interface 1 and interface 4 respectively, thereby establishing a corresponding relationship between different interfaces and standard fields. Finally, based on the corresponding relationship between the standard fields and the interfaces, a preset associated interface configuration table is constructed, and the preset associated interface configuration table stores different standard fields and their corresponding interfaces (associated interfaces).
[0076] Further, after the preset associated interface configuration table is constructed, the associated interface associated with the current interface can be determined based on the preset associated interface configuration table. The specific method of determining the associated interface is: first, the standard field feature vector corresponding to each standard field of the preset associated interface configuration table is determined by word embedding or the like, and the initial field feature vector corresponding to the initial field information corresponding to the current interface is determined. Then, according to the initial field feature vector and each standard field feature vector, the target standard field identical to the initial field information is found in the preset associated interface configuration table, and based on the correspondence between the standard field and the associated interface in the preset associated interface configuration table, the interface corresponding to the target standard field is determined, and the interface is determined as the associated interface associated with the current interface. Therefore, the embodiment of the present invention directly determines the associated interface corresponding to the current interface through the pre-constructed associated interface configuration table, which can improve the determination efficiency and accuracy of the associated interface.
[0077] 205. Determine the initial associated test case of the associated interface.
[0078] For the embodiment of the present invention, in order to determine the initial associated test cases of the associated interfaces, it is first necessary to construct corresponding test cases for different interfaces. Based on this, the method includes: determining the interface document information of different interfaces, and based on the interface document information, determining the call interface parameter set of different interfaces, wherein the call interface parameter set is composed of multiple call interface parameter subsets; clustering each of the call interface parameter subsets to obtain the call interface parameter subsets under different request mode clusters; determining the user input information corresponding to different interfaces, and constructing the call interface parameter subsets corresponding to different interfaces based on the user input information and the call interface parameter subsets under each of the request mode clusters. A test case template under different request mode clusters, wherein the test case template contains general test information and personalized test information title items; determining the field type of the pre-filled field corresponding to the personalized test information title item, the business logic information of different interfaces, and the format requirement information of different interfaces for the pre-filled field; based on the field type of the pre-filled field, the business logic information of different interfaces, and the format requirement information of different interfaces for the pre-filled field, filling the personalized test information at the preset position corresponding to the personalized test information title item in the test case template, and obtaining the initial associated test cases of different interfaces under different request modes. Among them, the method for clustering each of the calling interface parameter subsets includes: initializing the centroid vector corresponding to different request mode clusters, and determining the interface parameter feature vector corresponding to each of the calling interface parameter subsets; calculating the distance between the interface parameter feature vector and the centroid vector corresponding to the different request mode clusters, and based on the distance, dividing each of the calling interface parameter subsets into the different request mode clusters; based on the interface parameter feature vectors corresponding to the calling interface parameter subsets in the different request mode clusters, determining the updated centroid vector corresponding to the different request mode clusters; based on the updated centroid vector, re-dividing each of the calling interface parameter subsets into the different request mode clusters until the updated centroid vector does not change, and the calling interface parameter subsets finally divided into the different request mode clusters are determined as the calling interface parameter subsets under the different request mode clusters.
[0079] Among them, the calling interface parameter set refers to the set of all parameters that need to be passed when calling the interface, and the calling interface parameter set includes authentication parameters, request identification parameters, business parameters, paging parameters, sorting parameters, request body, metadata parameters, callback parameters, file upload parameters, business parameters, etc. For example, when calling a user information query interface, the calling interface parameter set may include the user's ID, the query field, paging information, etc., and these parameters together constitute all the information required for the interface call. The interface call parameter subset refers to a part of the parameters selected from the calling interface parameter set, and the selection of the calling interface parameter subset usually depends on the specific business requirements and interface design. For example, when calling a user information update interface, it may only be necessary to pass the user's ID and the fields to be updated as parameter subsets, without passing all user information. The parameter set contains parameter subsets. The parameter subset is a part of the parameters selected from the parameter set. User input information refers to the data or instructions that the user passes to the interface in some way (such as the front-end interface, command line tool, etc.) when using the interface. These data or instructions are necessary for the interface to perform its functions and are also an important way for the interface to interact with the user. Request methods include: GET request method (used to request information about a specified resource from the server), POST request method (used to submit data to a specified resource for processing), PUT request method (used to upload the latest content to a specified resource location), DELETE request method (used to request the server to delete a specified resource), HEAD request method (similar to GET request, but the server will not return the message body in the response, only the response header), etc. The preset position is set according to actual needs, such as the blank position near the personalized test information title item.
[0080] Specifically, the interface document information of different interfaces is parsed to obtain the calling interface parameter sets under different interfaces. Then, the calling interface parameter sets can be divided into multiple calling interface parameter subsets according to different business needs and business scenarios. Each parameter subset should contain the parameters required to meet specific business scenarios or needs. Afterwards, each call interface parameter subset is clustered according to different request modes. The specific clustering method is as follows: first, the centroid vector corresponding to the clusters of different request modes is initialized. The initialization method is as follows: determine the data density in the preset neighborhood corresponding to each of the call interface parameter subsets, and determine the density mean corresponding to each of the data densities; based on the density mean, divide each of the call interface parameter subsets into a high-density set and a low-density set; determine a high-density call interface parameter subset whose data density is greater than a preset density threshold in the call interface parameter subsets of the high-density set, and determine the preset number of central call interface parameter subsets whose mutual distance is greater than a preset distance threshold in each of the high-density call interface parameter subsets, and use the central call interface parameter subsets as the initial centroids under the clusters of different request modes, and use the centroid vectors corresponding to the initial centroids to initialize the centroid vectors under the clusters of different request modes. Among them, the preset neighborhood is set according to actual needs, the preset density threshold is set according to actual needs, and the preset distance is set according to actual needs. Specifically, the data density in the preset neighborhood corresponding to each calling interface parameter subset is determined respectively, such as the data density corresponding to calling interface parameter subset 1 is 3, the data density corresponding to calling interface parameter subset 2 is 4, the data density corresponding to calling interface parameter subset 3 is 5, the data density corresponding to calling interface parameter subset 4 is 9, the data density corresponding to calling interface parameter subset 5 is 9, and the data density corresponding to calling interface parameter subset 6 is 10, then the density mean is 6.7, and calling interface parameter subset 4, calling interface parameter subset 5, and calling interface parameter subset 6 with data density greater than 6.7 are divided into The calling interface parameter subsets 1, 2, and 3 are divided into high-density sets, and the calling interface parameter subsets 1, 2, and 3 are divided into low-density sets. If the preset density threshold is 5 and the preset number is 2, the data whose mutual distance is greater than the preset threshold is finally determined to be the calling interface parameter subset 4 and the calling interface parameter subset 6. Finally, the calling interface parameter subsets 4 and 6 are respectively determined as the initial centroids corresponding to each cluster, and the centroid vectors of each initial centroid are determined by word embedding and other methods, and the centroid vectors of different clusters are initialized by the centroid vectors to obtain the centroid vectors corresponding to each cluster.The embodiment of the present invention determines the initial centroid of the cluster by data density and mutual heterogeneity. By considering data density, the natural distribution characteristics of the data can be more accurately reflected. High-density areas usually correspond to the core part of the data set, while low-density areas may contain noise or outliers. Therefore, selecting the initial centroid according to data density helps to place the centroid at the core position of the data, thereby improving the accuracy of the initial centroid determination and further improving the clustering accuracy. At the same time, mutual heterogeneity measures the degree of difference between data objects. By considering mutual heterogeneity, the subtle differences between data objects can be better captured, thereby more accurately determining the initial centroid of the cluster. In the case of an accurate initial centroid, the clustering effect can be further improved.
[0081] Furthermore, after determining the centroid vectors corresponding to different request mode clusters, first determine the interface parameter feature vectors corresponding to each calling interface parameter subset, and based on the interface parameter feature vectors and the centroid vectors of the initial centroids corresponding to each cluster, calculate the distance between each calling interface parameter subset and the initial centroid, and assign each calling interface parameter subset to the cluster corresponding to the nearest centroid vector. Then, for each cluster, recalculate the centroid of each cluster and its corresponding centroid vector, and re-divide the calling interface parameter subsets into different clusters. In this way, the calling interface parameter subsets are continuously divided until the position of the centroid does not change, that is, the centroid vector does not change, and finally the calling interface parameter subsets divided into different clusters are determined as calling interface parameter subsets under different request mode clusters.
[0082] Further, after clustering each call interface parameter subset to obtain the call interface parameter subset under different request mode clusters, it is necessary to construct a test case template (basic framework of the test case) under each request mode for the call interface parameter subset under each request mode, and the test case template contains the common test information and personalized test title items under the same request mode. When it is necessary to construct a test case under each request mode, it is only necessary to fill in the personalized test information in the test case template under each request mode, without rewriting all the codes to regenerate the entire test case, saving the test case generation time and improving the test case generation accuracy. Further, after the test case template is constructed, in order to fill in the personalized test case information in the test case template, so as to obtain the test cases under different request modes corresponding to different interfaces, it is first necessary to determine the field type of the pre-filled field, such as analyzing the field attributes: first, it is necessary to determine the type of the pre-filled field corresponding to the personalized test information title item, such as string, integer, date, Boolean, etc. Field type marking: Mark the type of each pre-filled field in the test case template for subsequent processing and verification. Determine the business logic information of different interfaces: Interface document analysis: Read and understand the business logic document of each interface, including the interface's functions, parameters, return values, etc. Business logic extraction: Extract business logic information related to pre-filled fields from the document, for example, which fields are required and which fields have specific format requirements or value range restrictions. Determine the format requirement information for pre-filled fields of different interfaces. Format requirement combing: According to the interface document and business logic, comb the format requirements of each interface for pre-filled fields, such as date format (YYYY-MM-DD), phone number format (+86-XXXX-XXXXXXX), email format (user@domain.com), etc. Format verification rules: Formulate format verification rules for each field to ensure that the filled data meets the interface requirements. Finally, fill in personalized test information in the test case template, including template positioning: Find the preset position corresponding to the personalized test information title item in the test case template, data filling: Generate or select data that meets the type requirements according to the field type of the pre-filled field, and ensure that the filled data meets the functional requirements and parameter requirements of the interface according to the business logic information. According to the format requirement information, format the filled data to ensure that the data meets the format requirements of the interface, and generate the initial associated test case: insert the filled personalized test information into the test case template to generate the initial associated test case for different interfaces and different request methods. For example, if the test case template contains the following personalized test information header items:
[0083] User name (string type)
[0084] Registration Date (date type)
[0085] Email address (string type, in email format)
[0086] For different interfaces (such as login interface, registration interface) and different request methods (such as GET, POST), we can fill in data in the following ways:
[0087] Login interface (POST request):
[0088] Username: JohnDoe
[0089] Registration Date: (no need to fill in)
[0090] Email address: johndoe@example.com
[0091] Registration interface (POST request):
[0092] Username: JaneSmith
[0093] Registration Date: 2023-04-01
[0094] Email address: janesmith@example.com.
[0095] The embodiment of the present invention generates test cases for each request method. Since each request method has its own specific behavior pattern and data processing logic, the use of special test cases can ensure that the test cases accurately reflect these differences, thereby improving the accuracy of the test, which helps to reduce errors and vulnerabilities caused by improper request methods; at the same time, the embodiment of the present invention generates test cases through test case templates. The common structure and content in the template can be reused between different test scenarios and projects, reducing duplication of work and greatly shortening the writing time of test cases. Testers only need to fill in the necessary information in the template without having to create each test case from scratch. At the same time, the template provides a unified format for the test case. The standardized template reduces the ambiguity in the interpretation and understanding of test requirements, ensuring that team members have a common understanding of the test case.
[0096] Furthermore, after constructing different test cases for different interfaces according to the request method, a mapping relationship between different interfaces and different test cases is established. After determining the associated interface corresponding to the current interface, the test case (initial associated test case) corresponding to the associated interface is determined based on the mapping relationship between different interfaces and different test cases.
[0097] 206. Determine the associated field information of the associated interface, and determine the field difference information between the changed field information and the associated field information.
[0098] For the embodiment of the present invention, the preset associated interface configuration table stores the standard field corresponding to the associated interface, and the standard field is determined as the associated field information of the associated interface. It should be noted that the similarity between the associated field information and the initial field information of the current interface is greater than a preset threshold, wherein the preset threshold is set according to actual needs. Then, the field difference information between the changed field information of the current interface and the associated field information of the associated interface is determined, and finally, the initial associated test case of the associated interface is adjusted according to the field difference information, without having to rewrite the test case of the associated interface from scratch, thereby improving the efficiency of test case generation and avoiding the low accuracy of the rewritten test case due to negligence.
[0099] 207. Based on the field difference information, the initial associated test case is adapted and adjusted for the associated interface test to obtain an associated test case of the associated interface.
[0100] For the embodiment of the present invention, after determining the field difference information, it is necessary to adjust the initial associated test case of the associated interface according to the field difference information. Based on this, step 207 specifically includes: determining the interface function information of the current interface and the field constraint information for the initial field information, the associated interface function information of the associated interface and the associated field constraint information for the associated field information, and the dependency information between the current interface and the associated interface; based on the interface function information and the associated interface function information, determining the function difference information, based on the field constraint information and the associated field constraint information, determining the field constraint difference information; based on the field difference information, the function difference information, the field constraint difference information, and the dependency information, adapting and adjusting the initial associated test case for the associated interface test to obtain the associated test case of the associated interface.
[0101] The interface function information includes: interface name, interface description, request method, request parameters, etc. Field constraint information refers to a series of rules and restrictions attached to the field, including: primary key constraint, foreign key constraint, unique constraint, non-null constraint, default value constraint, check constraint, automatic growth constraint, etc. The dependency relationship between two interfaces mainly refers to the fact that one interface depends on the service or data provided by another interface in terms of functional implementation or business logic, including direct dependency, indirect dependency, inheritance dependency, aggregation or combination dependency, etc.
[0102] Specifically, the processing of field difference information: if the field of the associated interface is different from the current interface, the request or response data in the initial associated test case corresponding to the associated interface needs to be modified to match the field requirements of the associated interface. Processing of functional difference information: if the function of the associated interface is different from the current interface, the business logic of the initial associated test case needs to be adjusted to cover the unique function of the associated interface. Processing of field constraint difference information: according to the field constraint information of the associated interface, the data format, length, constraint conditions, etc. in the initial associated test case are adjusted to ensure the compliance of the test data. Processing of dependency information: if there is a dependency relationship between the current interface and the associated interface in terms of data flow or call order, it is necessary to adjust the execution order of the initial associated test case or add necessary preprocessing steps. Finally, after the above adaptation and adjustment, the associated test case for the associated interface is obtained, so that the associated test case can fully cover the functions, field constraints and dependencies of the associated interface, and ensure the adjustment or generation accuracy of the associated test case corresponding to the associated interface, thereby improving the accuracy and effectiveness of the associated interface test and ensuring the stability of the associated interface.
[0103] Furthermore, after the field information corresponding to the current interface changes, the test case of the current interface needs to be adjusted. Based on this, the method includes: obtaining an initial test case for the current interface; parsing the field information change signal to obtain the field change type of the current interface, wherein the field change type includes: at least one of a field range change type, a field default value change type, a field name change type, a field type change type, a field constraint change type, and a field description change type; based on the field change type, determining an adaptation adjustment method for the initial test case to test the current interface after the field is changed; using the adaptation adjustment method to adjust the initial test case to obtain a test case corresponding to the current interface after the field is changed.
[0104] Among them, different field change types may correspond to different test case adjustment methods. Specifically, after receiving the field information change information of the current interface, first, obtain the initial test case of the current interface. These initial test cases are previously written for the current interface based on the test case template to verify the function and field constraints of the interface. After that, the field information change signal of the current interface is parsed. This signal may come from the interface document, version control record or notification of the development team. The purpose of the parsing is to identify which fields have changed, as well as the specific content of the change and the specific field change type, and obtain the adjustment method configuration table, wherein the adjustment method configuration table records the test case adjustment method corresponding to different field change types, and according to the corresponding relationship between different field change types and test case adjustment methods in the adjustment method configuration table, the test case adjustment method (adaptation adjustment method) of the current interface is determined, and finally the initial test case of the current interface is adjusted using the adaptation method to obtain the test case corresponding to the current interface after the field is changed. For example, if the field name, type, range or default value has changed, its corresponding adaptation adjustment method is a request or corresponding adjustment method, that is, the request or response data in the test case needs to be modified. If the constraint or description of the field changes, the corresponding adaptation adjustment method is the assertion update adjustment method, that is, the assertion conditions in the test case need to be updated to ensure the accuracy of the test results. If the field change affects the business logic of the interface, the corresponding adaptation adjustment method is the test logic adjustment method, that is, the test logic of the test case needs to be adjusted. Therefore, the embodiment of the present invention selects a suitable adjustment method for the test case according to the field change type, and by identifying the specific change type of the field, the relevant test cases can be adjusted in a targeted manner, thereby avoiding the tedious process of comprehensive review of all test cases, saving the adjustment time of the test cases, and improving the adjustment or generation efficiency of the test cases.
[0105] According to another method for generating interface test cases provided by the present invention, compared with the current method of manually determining the associated interface of a certain interface and manually writing complete code to regenerate the test case of the associated interface, the present invention obtains the initial field information of the field information corresponding to the current interface before the change and the changed field information after the change by responding to the field information change signal of the current interface; and based on the initial field information, determines the associated interface associated with the current interface, and determines the initial associated test case of the associated interface; then determines the associated field information of the associated interface, and determines the field difference information between the changed field information and the associated field information; finally, based on the field difference information, adapts the initial associated test case for the associated interface test to obtain the associated test case of the associated interface. Therefore, the present invention determines the associated interface associated with the interface through the initial field information of the current interface, which can avoid the problem of determination errors and low determination efficiency caused by manual determination of the associated interface, so that the present invention can improve the determination efficiency and accuracy of the associated interface. At the same time, the present invention adjusts the initial associated test case in the associated interface according to the difference information between the changed field information of the current interface and the associated field information of the associated interface, so as to generate an associated test case for the associated interface, which can avoid the waste of time and code writing errors caused by manually writing code to regenerate the entire test case, so that the present invention can improve the generation efficiency and accuracy of interface test cases.
[0106] Further, as Figure 1 In the specific implementation of the present invention, an embodiment of the present invention provides a device for generating interface test cases, such as Figure 3 As shown, the device includes: an acquisition unit 31, a first determination unit 32, a second determination unit 33, and an adjustment unit 34.
[0107] The acquisition unit 31 may be configured to respond to a field information change signal of the current interface to acquire initial field information before the change and changed field information after the change of the field information corresponding to the current interface.
[0108] The first determining unit 32 may be configured to determine an associated interface associated with the current interface based on the initial field information, and determine an initial associated test case of the associated interface.
[0109] The second determining unit 33 may be configured to determine the associated field information of the associated interface, and determine field difference information between the changed field information and the associated field information.
[0110] The adjusting unit 34 may be configured to perform adaptation adjustment on the initial associated test case for the associated interface test based on the field difference information, so as to obtain an associated test case for the associated interface.
[0111] In a specific application scenario, in order to determine the associated interface associated with the current interface, such as Figure 4 As shown, the first determination unit 32 includes a first determination module 321 and a matching module 322 .
[0112] The first determination module 321 may be used to determine a standard field feature vector corresponding to each standard field in a preset associated interface configuration table, wherein the preset associated interface configuration table stores different standard fields and their corresponding standard associated interfaces.
[0113] The matching module 322 may be used to determine an initial field feature vector corresponding to the initial field information, and match the initial field information with each of the standard fields based on the initial field feature vector and the standard field feature vector to obtain a matching result.
[0114] The first determination module 321 can be specifically used to determine the target standard field matching the initial field information in each of the standard fields based on the matching result, and determine the standard associated interface corresponding to the target standard field as the associated interface associated with the current interface.
[0115] In a specific application scenario, in order to construct a preset associated interface configuration table, the device further includes: a construction unit 35 .
[0116] The construction unit 35 can be specifically used to obtain interface document information in different interfaces, and parse the interface document information to obtain field information in different interfaces; determine the field feature vectors corresponding to the field information in different interfaces, and match the field information in different interfaces based on the field feature vectors to obtain standard fields that meet the matching conditions in different interfaces, and determine the multiple interfaces to which the standard fields belong as standard associated interfaces; and construct a preset associated interface configuration table based on the standard fields and their corresponding standard associated interfaces.
[0117] In a specific application scenario, in order to determine initial associated test cases of different interfaces, the device further includes a case generation unit 36 .
[0118] The use case generation unit 36 can be specifically used to determine the interface document information of different interfaces, and based on the interface document information, determine the call interface parameter set of different interfaces, wherein the call interface parameter set is composed of multiple call interface parameter subsets; cluster each of the call interface parameter subsets to obtain the call interface parameter subsets under different request mode clusters; determine the user input information corresponding to the different interfaces, and based on the user input information and the call interface parameter subsets under each of the request mode clusters, construct test case templates under different request mode clusters corresponding to the different interfaces, wherein the test case template contains general test information and personalized test information title items; determine the field type of the pre-filled field corresponding to the personalized test information title item, the business logic information of different interfaces, and the format requirement information of different interfaces for the pre-filled field; based on the field type of the pre-filled field, the business logic information of different interfaces, and the format requirement information of different interfaces for the pre-filled field, fill the personalized test information at the preset position corresponding to the personalized test information title item in the test case template to obtain the initial associated test cases of different interfaces under different request modes.
[0119] In a specific application scenario, in order to cluster each calling interface parameter subset, the use case generation unit 36 includes an initialization module 361 , a division module 362 , and a second determination module 363 .
[0120] The initialization module 361 may be used to initialize the centroid vectors corresponding to the clusters of different request modes, and determine the interface parameter feature vectors corresponding to each of the calling interface parameter subsets.
[0121] The division module 362 may be used to calculate the distance between the interface parameter feature vector and the centroid vector corresponding to the different request mode clusters, and based on the distance, divide each of the call interface parameter subsets into the different request mode clusters.
[0122] The second determination module 363 may be configured to determine updated centroid vectors corresponding to the different request mode clusters based on the interface parameter feature vectors corresponding to the calling interface parameter subsets in the different request mode clusters.
[0123] The second determination module 363 can be specifically used to re-divide each of the calling interface parameter subsets into the different request mode clusters based on the updated centroid vector until the updated centroid vector does not change, and the calling interface parameter subsets finally divided into the different request mode clusters are determined as the calling interface parameter subsets under the different request mode clusters.
[0124] In a specific application scenario, in order to generate an associated test case of an associated interface, the adjustment unit 34 includes a third determination module 341 and an adjustment module 342 .
[0125] The third determination module 341 can be used to determine the interface function information of the current interface and the field constraint information for the initial field information, the associated interface function information of the associated interface and the associated field constraint information for the associated field information, and the dependency information between the current interface and the associated interface.
[0126] The third determination module 341 may also be used to determine function difference information based on the interface function information and the associated interface function information, and determine field constraint difference information based on the field constraint information and the associated field constraint information.
[0127] The adjustment module 342 can be used to adapt the initial associated test case for the associated interface test based on the field difference information, the function difference information, the field constraint difference information, and the dependency information to obtain the associated test case of the associated interface.
[0128] In a specific application scenario, in order to generate a test case corresponding to the current interface, the case generation unit 36 can also be used to obtain an initial test case for the current interface; parse the field information change signal to obtain the field change type of the current interface, wherein the field change type includes: at least one of a field range change type, a field default value change type, a field name change type, a field type change type, a field constraint change type, and a field description change type; based on the field change type, determine an adaptation adjustment method for the initial test case to test the current interface after the field is changed; use the adaptation adjustment method to adjust the initial test case to obtain a test case corresponding to the current interface after the field is changed.
[0129] It should be noted that for other corresponding descriptions of the functional modules involved in the device for generating an interface test case provided in an embodiment of the present invention, reference can be made to Figure 1 The corresponding description of the method shown will not be repeated here.
[0130] Based on the above Figure 1The method shown, accordingly, an embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the following steps are implemented: in response to a field information change signal of a current interface, obtaining the initial field information before the change and the changed field information after the change of the field information corresponding to the current interface; based on the initial field information, determining the associated interface associated with the current interface, and determining the initial associated test case of the associated interface; determining the associated field information of the associated interface, and determining the field difference information between the changed field information and the associated field information; based on the field difference information, adapting and adjusting the initial associated test case for the associated interface test to obtain the associated test case of the associated interface.
[0131] Based on the above Figure 1 The method shown and Figure 3 The embodiment of the device shown in the figure, the embodiment of the present invention also provides a physical structure diagram of a computer device, such as Figure 5 As shown, the computer device includes: a processor 41, a memory 42, and a computer program stored in the memory 42 and executable on the processor, wherein the memory 42 and the processor 41 are both arranged on a bus 43, and the processor 41 implements the following steps when executing the program: in response to a field information change signal of a current interface, obtaining the initial field information before the change and the changed field information after the change of the field information corresponding to the current interface; based on the initial field information, determining an associated interface associated with the current interface, and determining an initial associated test case of the associated interface; determining the associated field information of the associated interface, and determining the field difference information between the changed field information and the associated field information; based on the field difference information, adapting and adjusting the initial associated test case for the associated interface test to obtain an associated test case of the associated interface.
[0132] Through the technical solution of the present invention, the present invention obtains the initial field information before the change and the changed field information after the change of the field information corresponding to the current interface in response to the field information change signal of the current interface; and based on the initial field information, determines the associated interface associated with the current interface, and determines the initial associated test case of the associated interface; then determines the associated field information of the associated interface, and determines the field difference information between the changed field information and the associated field information; finally, based on the field difference information, adapts and adjusts the initial associated test case for the associated interface test to obtain the associated test case of the associated interface. Therefore, the present invention determines the associated interface associated with the interface through the initial field information of the current interface, which can avoid the problem of determination errors and low determination efficiency caused by manual determination of the associated interface, so that the present invention can improve the determination efficiency and accuracy of the associated interface. At the same time, the present invention adjusts the initial associated test case in the associated interface according to the difference information between the changed field information of the current interface and the associated field information of the associated interface, so as to generate an associated test case for the associated interface, which can avoid the waste of time and code writing errors caused by manually writing code to regenerate the entire test case, so that the present invention can improve the generation efficiency and accuracy of interface test cases.
[0133] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0134] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for generating an interface test case, characterized in that: include: In response to a field information change signal of the current interface, obtaining initial field information before the change and changed field information after the change of the field information corresponding to the current interface; Based on the initial field information, determining an associated interface associated with the current interface, and determining an initial associated test case of the associated interface; Determine the associated field information of the associated interface, and determine the field difference information between the changed field information and the associated field information; Based on the field difference information, the initial associated test case is adapted and adjusted for the associated interface test to obtain an associated test case for the associated interface.
2. The method according to claim 1, characterized in that The determining, based on the initial field information, an associated interface associated with the current interface includes: Determine a standard field feature vector corresponding to each standard field in a preset association interface configuration table, wherein the preset association interface configuration table stores different standard fields and their corresponding standard association interfaces; Determine an initial field feature vector corresponding to the initial field information, and match the initial field information with each of the standard fields based on the initial field feature vector and the standard field feature vector to obtain a matching result; Based on the matching result, a target standard field matching the initial field information is determined in each of the standard fields, and a standard associated interface corresponding to the target standard field is determined as an associated interface associated with the current interface.
3. The method according to claim 1, characterized in that Before determining the associated interface associated with the current interface based on the initial field information, the method further includes: Obtaining interface document information in different interfaces, and parsing the interface document information to obtain field information in different interfaces; Determine the field feature vectors corresponding to the field information in different interfaces, and match the field information in different interfaces based on the field feature vectors to obtain standard fields that meet the matching conditions in different interfaces, and determine the multiple interfaces to which the standard fields belong as standard associated interfaces; Based on the standard fields and their corresponding standard associated interfaces, a preset associated interface configuration table is constructed.
4. The method according to claim 1, characterized in that Before determining the initial associated test case of the associated interface, the method further includes: Determine interface document information of different interfaces, and determine call interface parameter sets of different interfaces based on the interface document information, wherein the call interface parameter set is composed of multiple call interface parameter subsets; Clustering each of the calling interface parameter subsets to obtain calling interface parameter subsets under different request mode clusters; Determine user input information corresponding to different interfaces, and construct test case templates under different request mode clusters corresponding to different interfaces based on the user input information and the calling interface parameter subsets under each request mode cluster, wherein the test case templates contain general test information and personalized test information title items; Determine the field type of the pre-filled field corresponding to the personalized test information title item, the business logic information of different interfaces, and the format requirement information of different interfaces for the pre-filled field; Based on the field type of the pre-filled field, the business logic information of different interfaces, and the format requirement information of different interfaces for the pre-filled field, personalized test information is filled in the preset position corresponding to the personalized test information title item in the test case template to obtain initial associated test cases for different interfaces under different request methods.
5. The method according to claim 4, characterized in that The clustering of the calling interface parameter subsets to obtain the calling interface parameter subsets under different request mode clusters includes: Initialize the centroid vectors corresponding to the clusters of different request modes, and determine the interface parameter feature vectors corresponding to each of the calling interface parameter subsets; Calculating the distance between the interface parameter feature vector and the centroid vector corresponding to the different request mode clusters, and based on the distance, dividing each of the call interface parameter subsets into the different request mode clusters; Determine updated centroid vectors corresponding to the different request mode clusters based on interface parameter feature vectors corresponding to the calling interface parameter subsets in the different request mode clusters; Based on the updated centroid vector, each of the calling interface parameter subsets is re-divided into the different request mode clusters until the updated centroid vector does not change, and the calling interface parameter subsets finally divided into the different request mode clusters are determined as the calling interface parameter subsets under the different request mode clusters.
6. The method according to claim 1, characterized in that The adapting and adjusting the initial associated test case for the associated interface test based on the field difference information to obtain the associated test case of the associated interface includes: Determine the interface function information of the current interface and the field constraint information for the initial field information, the associated interface function information of the associated interface and the associated field constraint information for the associated field information, and the dependency relationship information between the current interface and the associated interface; Determine function difference information based on the interface function information and the associated interface function information, and determine field constraint difference information based on the field constraint information and the associated field constraint information; Based on the field difference information, the function difference information, the field constraint difference information, and the dependency information, the initial associated test case is adapted and adjusted for the associated interface test to obtain an associated test case for the associated interface.
7. The method according to claim 1, characterized in that The method further comprises: Get the initial test case of the current interface; Parsing the field information change signal to obtain the field change type of the current interface, wherein the field change type includes: at least one of a field range change type, a field default value change type, a field name change type, a field type change type, a field constraint change type, and a field description change type; Based on the field change type, determining an adaptation adjustment method for the initial test case to test the current interface after the field change; The initial test case is adjusted using the adaptation adjustment method to obtain a test case corresponding to the current interface after the field is changed.
8. A device for generating interface test cases, characterized in that: include: An acquiring unit, configured to acquire, in response to a field information change signal of a current interface, initial field information before the change and changed field information after the change of the field information corresponding to the current interface; A first determining unit, configured to determine, based on the initial field information, an associated interface associated with the current interface, and determine an initial associated test case of the associated interface; a second determining unit, configured to determine associated field information of the associated interface, and determine field difference information between the changed field information and the associated field information; An adjustment unit is used to adapt the initial associated test case for the associated interface test based on the field difference information to obtain an associated test case for the associated interface.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Method, device and equipment for generating test case based on large language model
CN120803950A