Test case sequence generation method and device, equipment and storage medium

By acquiring API call data in real time and extracting multi-dimensional features to identify dependencies, constructing test case sequences and dynamically injecting parameters, the problem of low efficiency in traditional API testing methods in complex systems is solved, achieving efficient automated testing.

CN121365007APending Publication Date: 2026-01-20HUNAN KAIHONG ZHIGU DIGITAL IND DEV CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511847405.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-09
Publication Date
2026-01-20

AI Technical Summary

Technical Problem

Traditional interface testing methods are inefficient in complex business logic systems and struggle to automate the handling of interface testing issues involving multiple dependencies.

Method used

By using probes to acquire API call data in real time, extracting multi-dimensional data features (data fingerprints, semantic vectors, and structural hashes), identifying dependencies between APIs, constructing API business process diagrams, generating test case sequences, and injecting dynamic parameters in conjunction with static data templates.

Benefits of technology

It achieves end-to-end automated test coverage of complex business links, significantly reducing the workload of manually sorting out dependencies and constructing test cases, and improving testing efficiency and reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121365007A_ABST
    Figure CN121365007A_ABST
Patent Text Reader

Abstract

The invention provides a test case sequence generation method and device, equipment and a storage medium. The method comprises the following steps: acquiring calling data of an interface in a business process in real time by adopting a probe; for each interface, multi-dimensional data features are extracted according to the corresponding calling data, and the data features comprise data fingerprints, semantic vectors and structural hash; performing feature matching according to the data feature of each interface to determine a dependency relationship between the interfaces; constructing an interface business flow chart according to the dependency relationship between the interfaces; and generating a test case sequence according to the interface business flow chart, associating the test case sequence with the static data template, and executing a test through dynamic injection parameters. According to the method, the interface dependency relationship can be accurately and automatically identified by extracting multi-dimensional features such as data fingerprints, semantic vectors and structural hash from the calling data and matching the multi-dimensional features, the interface business flow chart is constructed based on the dependency relationship, the test case sequence is generated according to the interface business flow chart, and the test efficiency and reliability are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application belongs to the technical field of interface testing, and particularly relates to a test case sequence generation method and device, equipment and a storage medium. BACKGROUND

[0002] With the microservice and complication of system architecture, the interface (API) calling link becomes very complex, and when the interface design document is missing or the data dependency in the interface cannot be correctly described in the document, especially when one interface needs data of multiple preceding interfaces (multiple dependencies), the traditional method is difficult to automatically process all data sources, and the current practice is to communicate with the development when performing interface testing, and manually associate all interfaces one by one, so that the existing interface testing method has the problem of low efficiency when dealing with complex business logic systems. SUMMARY

[0003] Therefore, the present application provides a test case sequence generation method, device, equipment and storage medium to improve the efficiency when dealing with complex business logic systems.

[0004] The first aspect of the present application provides a test case sequence generation method, comprising:

[0005] adopting a probe to acquire calling data of interfaces in a business process in real time;

[0006] extracting multi-dimensional data features according to the corresponding calling data for each interface, wherein the data features include data fingerprints, semantic vectors and structure hashes;

[0007] performing feature matching according to the data features of each interface to determine the dependency relationship between interfaces;

[0008] constructing an interface business process graph according to the dependency relationship between interfaces;

[0009] generating a test case sequence according to the interface business process graph, and associating the test case sequence with a static data template to execute testing by dynamically injecting parameters.

[0010] The second aspect of the present application provides a test case sequence generation device, comprising:

[0011] a calling data acquisition module configured to acquire calling data of interfaces in a business process in real time by adopting a probe;

[0012] a data feature extraction module configured to extract multi-dimensional data features according to the corresponding calling data for each interface, wherein the data features include data fingerprints, semantic vectors and structure hashes;

[0013] A dependency relationship determining module is configured to determine the dependency relationship between the interfaces according to the feature matching of the data features of each interface.

[0014] A business flowchart constructing module is configured to construct an interface business flowchart according to the dependency relationship between the interfaces.

[0015] A generating and executing module is configured to generate a test case sequence according to the interface business flowchart, and associate the test case sequence with a static data template, and execute the test by dynamically injecting parameters.

[0016] The third aspect of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the test case sequence generation method according to the first aspect.

[0017] The fourth aspect of the present application provides a computer readable storage medium, which stores a computer program, wherein the computer program is executed by a processor to implement the test case sequence generation method according to the first aspect.

[0018] Compared with the prior art, the embodiments of the present application have the following beneficial effects:

[0019] The technical solution deploys a probe to capture the interface calling data in real time in the real business flow, effectively avoiding the dependence on incomplete or outdated design documents. By extracting the data fingerprints, semantic vectors and structure hashes of the calling data and matching these multi-dimensional features, the implicit and multiple data dependency relationships between the interfaces can be accurately and automatically identified. Based on the dependency relationship, the interface business flowchart is automatically constructed, and the test case sequence conforming to the real calling time sequence and data flow direction is generated. In the execution sequence, the sequence is associated with the static template, and the parameters are dynamically injected during the execution, so that the end-to-end automatic test coverage of the complex business link is realized, the workload of manually arranging the dependencies and constructing the test cases is significantly reduced, and the test efficiency and reliability are improved. BRIEF DESCRIPTION OF DRAWINGS

[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0021] Figure 1 is a schematic diagram of a test case sequence generation method provided by the embodiments of the present application;

[0022] Figure 2 is a schematic diagram of another test case sequence generation method provided by an embodiment of the present application;

[0023] Figure 3 is a schematic diagram of a test case sequence generation device provided by an embodiment of the present application;

[0024] Figure 4 is a schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0025] In the following description, for the purpose of explanation and not limitation, specific details are set forth, such as particular system configurations, techniques, etc., in order to provide a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application can be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.

[0026] The technical solutions of the present application are described below through specific embodiments.

[0027] Reference Figure 1 is a schematic diagram of a test case sequence generation method provided by an embodiment of the present application, which can be executed by a test case sequence generation device. The test case sequence generation device can be implemented in the form of hardware and / or software, and can be configured in an electronic device. As shown in Figure 1 , the method can specifically include the following steps:

[0028] S101, real-time acquisition of calling data of interfaces in a business process by a probe.

[0029] A lightweight probe (Agent) is pre-embedded at a system key node (such as a gateway or a service framework), and the original data of requests (Request) and responses (Response) of all interface calls in a complete business process are captured by the probe, including URL, Header, Body (parameters and values), etc., and the timing of the call is recorded, including the calling interface (or predecessor interface), the called interface (or successor interface), and the time and environment when the call just occurred.

[0030] Specifically, all API calls can be captured in real time by using a non-intrusive probe technology (such as a service mesh agent or a bytecode instrumentation technology), and high-precision timestamps, unique link IDs, and I / O data bodies are recorded.

[0031] Direct acquisition of calling data by the probe can bypass incomplete or outdated design documents and directly acquire real data of the system when it is in operation.

[0032] S102. For each interface, extract multi-dimensional data features based on the corresponding call data. The data features include data fingerprint, semantic vector and structural hash.

[0033] Data fingerprinting: Generates unique identifiers (such as MD5 hashes) for key parameter values ​​(e.g., order ID, user ID) in requests / responses, used to accurately track the transmission path of the same data between interfaces. Specifically, a precise hash fingerprint of I / O values ​​and a set of fuzzy fingerprints containing common encoding / format conversion results can be extracted as data fingerprints.

[0034] Semantic vectors: Natural language processing is applied to parameter names and structures (such as the JSON field name "userName"), mapping them to vectors in a semantic space. Semantic vectors are used to identify parameters with similar business meanings but different literal meanings (e.g., "userId" and "customerId" may refer to the same thing). In real-world systems, different services may name the same business entity differently. Data fingerprints alone cannot identify this, but semantic vectors can identify that "custId" and "clientId" may refer to the same thing, thus inferring potential dependencies.

[0035] Structure hash: Generates a hash value for the entire request / response data structure template (such as JSON Schema). Structure hash is used to quickly determine whether the input / output formats (structures) of two interfaces are the same. The structure hash is the hash value obtained by normalizing the JSON / XML schema of the request / response (e.g., sorting keys, uniform placeholders), ignoring specific values. For example, all requests to create users, even if the username and email values ​​are different, will have the same structure hash.

[0036] A single feature cannot cope with complex scenarios, so multi-dimensional complementarity is needed. The purpose of this step is to transform massive, unstructured raw call data into standardized, computable, and comparable feature vectors, which will facilitate subsequent feature matching.

[0037] S103. Perform feature matching based on the data characteristics of each interface to determine the dependencies between interfaces.

[0038] The algorithm compares the characteristics of different interfaces to determine whether dependencies exist and the degree of those dependencies. For example:

[0039] If the data fingerprint of a request parameter of interface B matches some data fingerprint of the response data of interface A, it can be indicated that B depends on A to provide the data; if the parameter names are different but the semantic vectors are highly similar, and the occurrence time sequence is that A precedes B, it can be inferred that there is a dependency. Multiple dependencies can also be identified, for example, one parameter of B comes from A and another parameter of B comes from C, and indirect dependencies (data is transmitted through an intermediate interface) can also be identified.

[0040] S104, constructing an interface service flowchart according to the dependency relationship between interfaces.

[0041] The interface service flowchart includes nodes and edges with directions. Each unique interface (identified by an HTTP method + URL) is a node. Each determined dependency relationship (whether from exact matching or high-confidence inference) is a directed edge from the predecessor interface to the successor interface, and the edge can be marked with the parameter name transmitted.

[0042] In the interface service flowchart, the node without an incoming edge is usually a trigger of the service flow (such as a login interface or an order submission interface). The node without an outgoing edge is a terminal node of the service flow.

[0043] The interface service flowchart is not only a visual chart, but also a core input model for subsequent test case generation, which completely defines the execution order constraints and data supply relationships of the interfaces.

[0044] S105, generating a test case sequence according to the interface service flowchart, and associating the test case sequence with a static data template to execute the test by dynamically injecting parameters.

[0045] First, the interface service flowchart is traversed to generate a test sequence: an algorithm (such as topological sorting) traverses the interface service flowchart to generate one or more legal interface call sequences. The sequence naturally ensures that when any interface is called, all data dependencies of the interface have been executed. Specifically, a main path sequence can be generated, or a combination test sequence covering different branches can be generated through a graph algorithm.

[0046] Associating the test case sequence with the static data template is usually offline analysis. Specifically, for each interface request template in the sequence, the mandatory parameters are derived.

[0047] Dependency parameter: it is known from the flowchart that the parameter value will be provided by the response field Y of the predecessor interface X. The system marks the data source as [dynamic: X.Y].

[0048] Independent parameter (user input parameter): if a mandatory parameter cannot find any pre-interface to provide its value in the graph, it is determined that it must be input externally. The system associates this parameter with a static data template (such as a configured JSON file or database), and marks its data source as [static: template key name].

[0049] The test execution engine is started, and the interfaces are called in sequence. When constructing the request of interface N, the engine parses the data source mark of each parameter of it: for [dynamic: X.Y], the engine accurately finds the response of interface X from the response cache of the executed interfaces, and extracts the value of field Y. For [static: template key name], the preset value is read from the associated static data template. The two parts of the value are automatically assembled to form a complete, legal, and correct context data containing request and sent. This process is repeated until the end of the sequence, realizing one-key, unattended end-to-end automated testing of the entire business flow.

[0050] The test case sequence generation method of the embodiment captures the interface call data in the real business process in real time through the deployment of probes, effectively avoiding the dependence on incomplete or outdated design documents. By extracting data fingerprints, semantic vectors, and structure hashes from the call data and matching these multi-dimensional features, the implicit and multiple data dependency relationships between interfaces can be accurately and automatically identified. Based on this dependency relationship, an interface business flowchart is automatically constructed, and a test case sequence conforming to the real call timing and data flow direction is generated accordingly. In the execution of the sequence, by associating the sequence with a static template and dynamically injecting parameters during execution, end-to-end automated testing coverage of complex business links is realized, significantly reducing the workload of manual dependency sorting and case construction, and improving testing efficiency and reliability.

[0051] In an optional embodiment, feature matching is performed according to the data features of each interface to determine the dependency relationship between interfaces, including:

[0052] For each dimension, the similarity between interfaces is calculated based on the data features of the current dimension to obtain a dimension score corresponding to the current dimension, and the dimension score includes a fingerprint consistency score, a semantic consistency score, and a structure timing consistency score; a comprehensive dependency score between the predecessor interface and the successor interface is calculated according to the dimension score; when the comprehensive dependency score exceeds a preset threshold, the dependency relationship between the interfaces is determined, and a binding identifier of the predecessor interface and the successor interface is generated; wherein the fingerprint consistency score is obtained according to the similarity between the data fingerprints of the interfaces, the semantic consistency score is obtained according to the similarity between the semantic vectors of the interfaces, and the structure timing consistency score is obtained according to the structure hash and the response completion time or request time of the interfaces.

[0053] Among them, the fingerprint consistency score can be used to find the direct transmission of data entities, that is, to check whether there are exactly the same data values between interfaces. For example, does the order number "12345" returned by interface A appear intact in the request of interface B. By comparing the unique "fingerprint" (such as hash value) generated from the data value. The more the number of matching fingerprints, the higher the proportion of the total number of fingerprints relative to the request, the higher the score.

[0054] The fingerprint consistency score is the most direct and reliable evidence of the direct flow of data entities.

[0055] The semantic consistency score is used to identify similar associations of business meaning and solve the problem of different parameter names but the same meaning. For example, interface A returns "userId" and interface B requests "customerId", both of which refer to "user identification" in business. Specifically, using natural language processing technology, the parameter name is mapped to the semantic space, and the similarity (such as cosine similarity) of its vector representation is calculated. The more similar the semantics, the higher the score.

[0056] The semantic consistency score can capture implicit dependencies caused by design inconsistencies and service heterogeneity, greatly improving the coverage of dependency discovery.

[0057] The structure and timing consistency score is used to verify the reasonable order of interface call logic and comprehensively evaluate the similarity of the data structure of two interfaces and the rationality of the calling time sequence.

[0058] Structure part: Compare whether the data schema (Schema) of the request and response between interfaces is similar (for example, whether they both contain a specific set of fields).

[0059] Timing part: Analyze whether the request of interface B occurs within a reasonable time window of the response of interface A. The shorter the time interval and the more logical it is, the higher the rationality.

[0060] Multiply the structure similarity and timing rationality to get this score.

[0061] The structure and timing consistency score can provide contextual evidence. Even if there is no exact data value transmission or obvious semantic association, if the structures of two interfaces are similar and closely connected in time, it may indicate that they have business logic dependencies.

[0062] When calculating the comprehensive dependency score, the system calculates the score of the above three dimensions for each pair of interfaces that may have dependencies (predecessor A and successor B). Then, according to the preset weight (for example, the most reliable fingerprint evidence has the highest weight, followed by semantics, and structure and timing as auxiliary), the weighted sum is calculated to obtain a comprehensive dependency score between 0 and 1. This score represents the overall confidence of the system in determining that A depends on B.

[0063] A configurable confidence threshold (e.g. 0.6) is set. Only when the combined dependency score of a pair of interfaces exceeds the threshold, the system formally confirms the existence of a dependency between them. This effectively filters out accidental or weak associations.

[0064] For each confirmed dependency, the system generates a unique binding identifier. The identifier usually contains the predecessor interface ID, successor interface ID, and confidence score. This is equivalent to archiving each dependency for later tracking, management, and direct reference in the test process.

[0065] In this optional embodiment, dependency identification is not simply a yes-or-no judgment, but is achieved through a multi-dimensional, quantifiable, and configurable scoring system, which makes the identification of dependencies more accurate, interpretable, and tunable.

[0066] In an optional embodiment, when the dimension is a data fingerprint; the similarity between interfaces is calculated based on the data characteristics of the current dimension, to obtain a dimension score corresponding to the current dimension, including:

[0067] The output field of the predecessor interface is matched with the input field of the successor interface for exact hash fingerprint matching; if they are consistent, it is determined that the exact matching condition is met, and a first sub-score when the exact matching condition is met is obtained; if they are not consistent, it is determined whether the exact hash fingerprint of the input field of the successor interface hits the fuzzy fingerprint set of the predecessor interface, if it hits, it is determined that the fuzzy matching condition is met, and a second sub-score when the fuzzy matching condition is met is obtained; wherein the fuzzy fingerprint set contains the results after encoding or format conversion of the output value of the predecessor interface; if neither the exact matching condition nor the fuzzy matching condition is met, a third sub-score is obtained, the first sub-score, the second sub-score, and the third sub-score decrease in turn; in all field combinations of input fields and output fields, the fingerprint consistency score of the pair of predecessor interface and successor interface is calculated according to the highest sub-score of each field combination obtained.

[0068] First, two kinds of fingerprints are generated for the input and output fields of each interface:

[0069] Exact hash fingerprint: the fingerprint obtained by performing hash operation (such as MD5, SHA256) on the original value of the field.

[0070] Fuzzy hash fingerprint set: after a series of common format conversion or encoding conversion on the original value, the hash values are calculated respectively to form a set of fingerprints. For example:

[0071] String case conversion (e.g. ABC is converted to abc);

[0072] Date format conversion (e.g., 2023-10-27 to 27 / 10 / 2023);

[0073] Encoding conversion (e.g., URL encoding, Base64 encoding);

[0074] Number format conversion (e.g., 1000 to 1k);

[0075] In this way, each output field of the predecessor interface will correspond to a set of fuzzy fingerprints, containing various possible transformations of the field value.

[0076] Then, for a pair of predecessor interface (output) and successor interface (input), for each input field of the successor interface, match with all output fields of the predecessor interface.

[0077] First, perform exact matching, compare whether the exact hash fingerprint of the successor interface input field is equal to the exact hash fingerprint of any output field of the predecessor interface. If equal, it means that the value of this input field directly comes from a certain output field of the predecessor interface and has not changed. At this time, assign the highest first sub-score (e.g., 1.0) to the matching of this field.

[0078] If the exact matching fails, perform fuzzy matching, check whether the exact hash fingerprint of the successor interface input field exists in the set of fuzzy fingerprints of any output field of the predecessor interface. If it exists, it means that the value of this input field may come from a certain output field of the predecessor interface, but has undergone certain format or encoding conversion. At this time, assign a second sub-score that is slightly lower (e.g., 0.7).

[0079] If both of the above two matches are unsuccessful, it means that the value of this input field may not come from this predecessor interface, or has undergone an unrecognized transformation. At this time, assign a third sub-score that is lower (e.g., 0 or a very small base score).

[0080] For each input field of the successor interface, get the highest sub-score after matching with all output fields of the predecessor interface (i.e., the best matching score selected from all possible field combinations). Then, integrate all the highest sub-scores of the input fields (e.g., take the average, weighted average, or maximum value) to get the fingerprint consistency score of this pair of interfaces in the data fingerprint dimension.

[0081] In an optional embodiment, when the dimension is a semantic vector; based on the data characteristics of the current dimension, calculate the similarity between interfaces to get the dimension score corresponding to the current dimension, including:

[0082] determining the field combination with the fingerprint consistency score greater than the third sub-score as a target field combination; for each target field combination, obtaining semantic vectors of two field names in the target field combination, and calculating cosine similarity between the two semantic vectors; taking the highest cosine similarity as the semantic consistency score of the pair of predecessor interface and successor interface.

[0083] The third sub-score represents the lowest score when there is no match (i.e., neither an exact match nor a fuzzy match) in the foregoing fingerprint matching embodiment. Therefore, the target field combination specifically refers to those field pairs that have reached fuzzy matching or exact matching in the data fingerprint dimension. This means that these fields have shown a certain association possibility at the numerical level, i.e., the data may be directly transmitted or transmitted after recognizable conversion.

[0084] First, the data fingerprint matching finds the field combination that has a transmission possibility at the numerical level. Only for these candidate field combinations, it is verified whether they are consistent at the business meaning level, to ensure that the semantic analysis is performed on the field combinations that are truly likely to be associated, and meaningless semantic comparison between unrelated fields is avoided.

[0085] Then, for each pair of target field combinations screened out, semantic vectors of two field names (for example, the vector representation of "orderId" and "orderCode") are extracted respectively, and then the cosine similarity between the two vectors is calculated. The cosine similarity measures the closeness of the two vectors in direction, and the value is between -1 and 1. It can be verified whether the fields that are associated at the numerical level are also related at the business definition in the semantic space.

[0086] Among all the calculated cosine similarities of the target field combinations, the highest score is taken as the final semantic consistency score of the pair of predecessor interface and successor interface.

[0087] In this embodiment, a field must meet two conditions to contribute to the final semantic consistency score: numerical association (fingerprint matching) and semantic association (semantic similarity), which makes the result of the final score very reliable.

[0088] In an optional embodiment, when the dimension is a structure hash; based on the data characteristics of the current dimension, the similarity between interfaces is calculated to obtain the dimension score corresponding to the current dimension, including:

[0089] According to the response completion time of the predecessor interface and the request start time of the successor interface, the timing constraint score of the predecessor interface and the successor interface is calculated;

[0090] The structure similarity score is obtained by comparing the structure similarity of the output structure hash of the predecessor interface and the input structure hash of the successor interface;

[0091] The structural temporal consistency score is obtained by weighted summation of the temporal constraint score and the structural similarity score with preset weight information.

[0092] The temporal constraint score (measuring the rationality of the calling sequence) is based on the time difference between the response completion time of the predecessor interface and the request start time of the successor interface. Usually, a decay function (such as exponential decay) is used to calculate the score.

[0093] If the time difference is very short (such as a few milliseconds to a few seconds), the score is very high, indicating that the two are closely connected in business, and are likely to be direct dependent calls. If the time difference is within a reasonable range (such as within tens of seconds), the score is moderate, which may belong to asynchronous operations or step intervals within the same session. If the time difference is too long or negative (the successor interface is called before the predecessor interface), the score is extremely low or zero, because this violates the basic logic of the dependency relationship (the reason cannot be later than the result).

[0094] The temporal constraint score can filter out logically impossible dependency relationships. Even if the data and semantics match, if the calling sequence is not reasonable, the dependency relationship does not exist.

[0095] The structural similarity score is specifically to compare the output structure hash of the predecessor interface with the input structure hash of the successor interface.

[0096] The structure hash represents the data template or schema (Schema) of the interface request or response, ignoring specific values. For example, an interface that returns {“orderId”: string, “amount”: number} has a fixed structure hash.

[0097] The structural hash similarity comparison is not simply a judgment of whether two hash values are equal (which means the structure is exactly the same), but a calculation of their structural similarity. This can be achieved by comparing the tree structure of JSONSchema, the degree of overlap of field sets, etc.

[0098] The structural similarity score can be used to evaluate whether the data form produced by the predecessor interface matches the data form required by the successor interface as a whole. The more similar the structure, the more compatible the data format, and the greater the possibility of a dependency relationship.

[0099] After obtaining the temporal constraint score and the structural similarity score, a preset weighting formula is used for comprehensive evaluation:

[0100] The structural temporal consistency score=(weight α × temporal constraint score)+(weight β × structural similarity score).

[0101] α and β are configurable weights.

[0102] For dependencies that pass data asynchronously through message queues, event buses, etc., data fingerprints and precise timing can fail, but the high similarity of data structures remains a key identifying feature, and the structural timing consistency score can effectively capture this relationship, as long as the invocation timing is reasonable and the structures are similar, the system can still infer potential dependencies; conversely, if the timing is extremely unreasonable, even if the data matches, it may be a coincidence.

[0103] In an optional embodiment, the timing constraint score of the predecessor interface and the successor interface is calculated according to the response completion time of the predecessor interface and the request start time of the successor interface, including:

[0104] The predecessor interface and the successor interface that meet the timing constraint condition are screened out, and the timing constraint condition requires that the response completion time of the predecessor interface be earlier than the request start time of the successor interface.

[0105] For the predecessor interface and the successor interface that meet the timing constraint condition, the time interval between the request start time of the successor interface and the response completion time of the predecessor interface is calculated.

[0106] The timing constraint score is obtained according to whether the time interval is within a preset time window.

[0107] Screening out all interface pairs that meet the condition that the response completion time of the predecessor interface is earlier than the request start time of the successor interface is a necessary condition for the establishment of a dependency relationship. If the request of interface B is issued before the completion of interface A, then B cannot depend on the response data of A. This step directly excludes all logically impossible interface combinations, and enables the subsequent analysis to be targeted at possible effective candidates.

[0108] The time interval Δt between the request start time of the successor interface and the response completion time of the predecessor interface quantifies the "waiting" or "delay" from the data readiness of the previous interface to the start of consumption of the next interface. This interval is a key indicator for evaluating the tightness of the dependency and the rationality of the business logic. According to whether the calculated Δt falls within a preset time window, the final timing constraint score is generated.

[0109] The time window is usually defined as [0, T_max], where T_max is a maximum reasonable delay threshold preset according to the specific business scenario. T_max is flexibly set according to actual needs.

[0110] The higher the timing constraint score, the more reasonable and closer the dependency relationship between the two interfaces in terms of time sequence.

[0111] By introducing a reasonable time window, this embodiment can effectively exclude false dependencies that are accidentally matched in data or semantics but have a long call time interval (may be completely independent twice business sessions), greatly improving the reliability of confirming dependencies.

[0112] In an optional embodiment, the interface business flow chart is constructed according to the dependencies between interfaces, comprising:

[0113] According to the dependencies between interfaces, an initial flow chart is constructed, the nodes of the initial flow chart are interfaces, the edges are dependencies between interfaces, and the edge weights are the comprehensive dependency scores between the associated interfaces; for the initial flow chart, nodes with a call frequency exceeding a preset threshold are identified, and the node weights or edge weights associated with the nodes are reduced; the average value of all edge weights is calculated to obtain a reference value; in the initial flow chart, edges with edge weights lower than the reference value are removed; for any two nodes with association in the initial flow chart, the total dependency strength of different paths between the nodes is calculated, the total dependency strength being the sum of the edge weights of all edges in the path; according to the difference between the total dependency strength of different paths and the total dependency strength of the shortest path between the nodes, the paths between the nodes are removed.

[0114] The two nodes with association refer to two nodes with direct association or indirect association.

[0115] First, take each interface as a node, and take the identified dependencies as directed edges, and assign a weight to each edge, which directly comes from the comprehensive dependency score calculated in the previous step.

[0116] Identify nodes that are frequently called by a large number of other interfaces (call frequency exceeding a preset threshold) in the graph, and actively reduce the weights of all edges connected to the nodes. Such high-frequency nodes are usually general technical or platform interfaces, such as identity authentication interfaces, log recording interfaces, and message pushing interfaces. Although they are widely called, they are not part of the core business logic. If not handled, they will form hub nodes in the graph and make the real business data flow be ignored. After reducing the weights of their associated edges, the influence of these general interfaces is weakened in subsequent path strength calculation and optimization, so that the flow chart can more clearly reflect the specific business function link.

[0117] Interface business flow chart purification: after the interface business flow chart is constructed, frequency filtering, weak edge elimination, redundant path pruning and other purification steps are needed to ensure that the graph structure can accurately reflect the core business process.

[0118] Frequency filtering: To remove or weaken high-frequency common interfaces (such as heartbeat, log reporting) and the dependencies they generate, which usually do not represent core business data flows. Identify nodes with call frequency exceeding a global threshold Fmax (e.g., 30 times per minute) and significantly reduce their node weights or the weights of the involved edges.

[0119] Weak edge pruning: Remove edges with scores far below the average of all scores globally, which represent low-confidence, randomly generated dependencies.

[0120] Redundancy pruning based on path strength: Aim to optimize the graph structure, avoiding redundant intermediate steps and focusing on the strongest, core business paths. Treat the scores of edges as weights of the graph. Apply shortest / strongest path algorithms (e.g., using Dijkstra's algorithm) to calculate the total dependency strength between all pairs of nodes. If there is a path A-B-C, but its total strength P(A-B) + P(B-C) is much lower than the direct edge strength of P(A-C), the system will mark the low-value edges in the indirect path for pruning, where P represents path strength.

[0121] In an optional embodiment, a test case sequence is generated according to the interface business process graph, and the test case sequence is associated with a static data template, and the test is executed by dynamically injecting parameters, including:

[0122] A test case sequence is generated according to a graph search algorithm with a second timing constraint and an interface business process graph, wherein the second timing constraint is to ensure that all predecessor interfaces having a data dependency relationship with any interface are included in the sequence before the interface is accessed in the test case sequence; for each interface request in the test case sequence, analyze the parameter structure of the request, identify the necessary parameters that do not depend on any predecessor interface response data as user input parameters, and associate them to a preset static data template; during execution of the test case sequence, according to the data source type of each parameter, the corresponding parameter value is extracted from the response data cache of the executed interface and the static data template through the preset dynamic reflection mechanism to dynamically reconstruct the complete request of the current interface and send it.

[0123] Exemplarily, the test sequence intelligent generation and parameter binding specifically includes the following processes:

[0124] 1. Test sequence generation: Use a graph search algorithm with constraints (such as K-shortest path algorithm) to generate a test case sequence Pi. The algorithm ensures that all necessary predecessor node sets of any node C are included in the sequence before C is accessed in the sequence to meet multiple timing constraints.

[0125] 2. Static template association and marking: after the sequence Pi is generated, the system analyzes the request template in reverse and the mandatory parameters that are not bound by API dependency, automatically identifies as a set of user input parameters Ui. The system associates Pi to an initial static data template Ti, and creates a source_type:User_Input instruction for Ui in the data_bindings of Pi. The user perfects the corresponding parameter value in the static data template Ti.

[0126] 3. Runtime execution and synchronous injection: the test execution engine synchronously extracts all parameters of the target interface C from the API cache and the static data template Ti object through dynamic reflection mechanism (based on JSONPath / XPath), and completes the request body reconstruction.

[0127] 4. Basic verification: automatically assert HTTP status code, response format and business code, key field.

[0128] In order to clearly illustrate the technical scheme and beneficial effects of the test case sequence generation method of the present application, the following Figure 2 will be described.

[0129] Referring to Figure 2 , another schematic diagram of a test case sequence generation method provided by an embodiment of the present application is shown, which can specifically include the following steps:

[0130] Step one, dynamic data monitoring and feature extraction.

[0131] First, data capture and feature extraction are performed to obtain data fingerprints, semantic vectors and hash structures.

[0132] Step two, dependency relationship confirmation.

[0133] First, the comprehensive dependency score Score between interfaces is calculated, and then Score is compared with the threshold value. If Score is greater than the threshold value, the dependency relationship is confirmed, otherwise the dependency relationship is ignored.

[0134] Step three, IBFG (‌Business Item Flow Diagram) automatic construction and purification.

[0135] First, the initial IBFG is constructed according to the dependency relationship, and the purified IBFG is obtained by purifying the IBFG.

[0136] Step four, test sequence intelligent generation and execution.

[0137] Specifically, it includes: generating test sequence based on IBFC, parameter and static template association, runtime execution and parameter synchronous injection, and basic verification.

[0138] The technical effects of the embodiments of the present application include:

[0139] 1. Intelligent reasoning based on multi-dimensional feature matching to realize dependency discovery: value matching, field semantic matching, structure timing consistency and weighted comprehensive score are introduced, and the reasoning accuracy is higher than that of traditional static or accurate matching methods.

[0140] 2. IBFG multiple dependency processing and purification: the graph modeling problem of one interface depending on multiple preceding interfaces is solved, the multiple in-degree and edge attribute are recorded to accurately represent the dependency, and the graph structure is purified by using noise filtering and other strategies.

[0141] 3. Static template reverse association and synchronous binding: dynamic / static data source automatic differentiation and management based on reverse analysis are realized, and dynamic reflection mechanism is used to realize synchronous injection of multi-source parameters.

[0142] It should be noted that the size of the serial number of each step in the above embodiments does not mean the execution order, and the execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0143] Referring to Figure 3 , a schematic diagram of a test case sequence generation device provided by an embodiment of the present application is shown, which can specifically include the following modules:

[0144] The calling data acquisition module 301 is used to acquire the calling data of the interfaces in the business process in real time by using a probe;

[0145] The data feature extraction module 302 is used to extract multi-dimensional data features including data fingerprints, semantic vectors and structure hashes according to the corresponding calling data for each interface;

[0146] The dependency relationship determination module 303 is used to perform feature matching according to the data features of each interface to determine the dependency relationship between the interfaces;

[0147] The business process graph construction module 304 is used to construct an interface business process graph according to the dependency relationship between the interfaces;

[0148] The generation and execution module 305 is used to generate a test case sequence according to the interface business process graph, associate the test case sequence with a static data template, and execute the test by dynamically injecting parameters.

[0149] Optionally, the dependency relationship determination module 303 performs feature matching according to the data features of each interface to determine the dependency relationship between the interfaces, including:

[0150] The first sub-module is configured to calculate similarity between interfaces based on the data feature of the current dimension, to obtain a dimension score corresponding to the current dimension, and the dimension score comprises a fingerprint consistency score, a semantic consistency score and a structure timing consistency score.

[0151] The second sub-module is configured to calculate a comprehensive dependency score between the predecessor interface and the successor interface according to the dimension score.

[0152] The third sub-module is configured to determine a dependency relationship between interfaces when the comprehensive dependency score exceeds a preset threshold, and to generate a binding identifier of the predecessor interface and the successor interface.

[0153] The fingerprint consistency score is obtained according to similarity between data fingerprints of interfaces, the semantic consistency score is obtained according to similarity between semantic vectors of interfaces, and the structure timing consistency score is obtained according to a structure hash and a response completion time or a request time of interfaces.

[0154] Optionally, when the dimension is a data fingerprint, the first sub-module is configured to:

[0155] perform accurate hash fingerprint matching on the output field of the predecessor interface and the input field of the successor interface.

[0156] If the output field of the predecessor interface and the input field of the successor interface are consistent, it is determined that the accurate matching condition is met, and a first sub-score when the accurate matching condition is met is obtained.

[0157] If the output field of the predecessor interface and the input field of the successor interface are inconsistent, it is determined whether the accurate hash fingerprint of the input field of the successor interface hits a fuzzy fingerprint set of the predecessor interface, if the accurate hash fingerprint of the input field of the successor interface hits the fuzzy fingerprint set of the predecessor interface, it is determined that the fuzzy matching condition is met, and a second sub-score when the fuzzy matching condition is met is obtained; wherein the fuzzy fingerprint set comprises a result after encoding or format conversion of the output value of the predecessor interface.

[0158] If neither the accurate matching condition nor the fuzzy matching condition is met, a third sub-score is obtained, and the first sub-score, the second sub-score and the third sub-score are in descending order.

[0159] In all field combinations of input fields and output fields, a fingerprint consistency score of the pair of the predecessor interface and the successor interface is calculated according to the highest sub-score of each field combination obtained.

[0160] Optionally, when the dimension is a semantic vector, the first sub-module is configured to:

[0161] determine a field combination with a fingerprint consistency score greater than the third sub-score as a target field combination.

[0162] For each of the target field combinations, obtain semantic vectors of two field names in the target field combination, and calculate cosine similarity between the two semantic vectors;

[0163] Take the highest cosine similarity as the semantic consistency score of the pair of predecessor interface and successor interface.

[0164] Optionally, when the dimension is a structure hash; the first sub-module is configured to:

[0165] According to the response completion time of the predecessor interface and the request start time of the successor interface, calculate the timing constraint score of the predecessor interface and the successor interface;

[0166] By comparing the structure similarity of the output structure hash of the predecessor interface and the input structure hash of the successor interface, obtain the structure similarity score;

[0167] By preset weight information, the timing constraint score and the structure similarity score are weighted and summed to obtain the structure timing consistency score.

[0168] Optionally, the first sub-module, when calculating the timing constraint score of the predecessor interface and the successor interface according to the response completion time of the predecessor interface and the request start time of the successor interface, is configured to:

[0169] Filter out the predecessor interface and the successor interface that meet the timing constraint condition, the timing constraint condition requires that the response completion time of the predecessor interface is earlier than the request start time of the successor interface;

[0170] For the predecessor interface and the successor interface that meet the timing constraint condition, calculate the time interval between the request start time of the successor interface and the response completion time of the predecessor interface;

[0171] According to whether the time interval is within a preset time window, the timing constraint score is obtained.

[0172] Optionally, the business process graph construction module 304 is configured to:

[0173] According to the dependency relationship between interfaces, an initial process graph is constructed, the nodes of the initial process graph are interfaces, the edges are dependency relationships between interfaces, and the edge weights are comprehensive dependency scores between associated interfaces;

[0174] For the initial process graph, identify nodes with a call frequency exceeding a preset threshold, and reduce the node weight or edge weight associated with the node;

[0175] Calculate the average value of all the edge weights to obtain a reference value;

[0176] In the initial process graph, remove edges with edge weights lower than the reference value;

[0177] For any two nodes with relevance in the initial flowchart, total dependency strength of different paths between the nodes is calculated, the total dependency strength being a sum of edge weights of all edges in the path;

[0178] According to difference between the total dependency strength of different paths and the total dependency strength of the shortest path between the nodes, the path between the nodes is removed.

[0179] The test case sequence generation device provided by the embodiment of the present application can realize each step in each test case sequence generation method embodiment.

[0180] It should be noted that the division of the modules in the various test case sequence generation devices provided by the above embodiments is illustrative, and is merely a logical functional division. In actual implementation, another division manner can be used. In addition, each functional module in each embodiment of the present application can be integrated in one processor, or can be physically separated, or two or more modules can be integrated into one module. The integrated module can be realized in the form of hardware or in the form of a software functional module.

[0181] If the integrated module is realized in the form of a software functional module and is sold or used as an independent product, the integrated module can be stored in a computer readable storage medium. Based on this understanding, all or part of the technical solutions of the embodiments of the present application can be embodied in the form of a computer program product stored in a computer storage medium, including a plurality of instructions for causing an electronic device or a processor to execute all or part of the steps of the method in each embodiment of the present application. The foregoing computer storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various program code storage media.

[0182] In addition, the test case sequence generation device and the test case sequence generation method provided by the above embodiments belong to the same concept, and the specific implementation process is detailed in the method embodiments, which will not be described here.

[0183] Referring to Figure 4 , a schematic diagram of an electronic device provided by an embodiment of the present application is shown. As Figure 4As shown, the electronic device in the embodiment of the present application includes a processor, a memory, and a computer program stored in the memory and executable on the processor. The processor implements the steps in the test case sequence generation method embodiment described above when executing the computer program. Alternatively, the processor implements the functions of each module in the test case sequence generation apparatus embodiment described above when executing the computer program.

[0184] For example, the computer program can be divided into one or more modules, which are stored in the memory and executed by the processor to complete the present application. The one or more modules can be a series of computer program instruction segments capable of completing a specific function, which can be used to describe the execution process of the computer program in the electronic device.

[0185] The electronic device can be a desktop computer, a cloud server, or other computing devices. The electronic device can include, but is not limited to, a processor, a memory. Those skilled in the art can understand that the electronic device can include more or less components, or combine certain components, or different components, for example, the electronic device can also include an input / output device, a network access device, a bus, etc. Figure 4 This is only an example of an electronic device and does not constitute a limitation on the electronic device, which can include more or fewer components than shown, or combine certain components, or different components, for example, the electronic device can also include an input / output device, a network access device, a bus, etc.

[0186] The processor can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), ready programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.

[0187] The memory can be an internal storage unit of the electronic device, such as a hard disk or a memory of the electronic device. The memory can also be an external storage device of the electronic device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, and the like. Further, the memory can include both the internal storage unit and the external storage device of the electronic device. The memory is used to store the computer program and other programs and data required by the electronic device. The memory can also be used to temporarily store data that has been output or will be output.

[0188] The embodiment of the present application also discloses an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the test case sequence generation method according to the foregoing embodiments when executing the computer program.

[0189] The embodiment of the present application also discloses a computer readable storage medium, which stores a computer program, and the computer program implements the test case sequence generation method according to the foregoing embodiments when executed by a processor.

[0190] The embodiment of the present application also discloses a computer program product, which, when executed on a computer, causes the computer to execute the test case sequence generation method according to the foregoing embodiments.

[0191] The above embodiments are only used to illustrate the technical solutions of the present application, rather than limit them. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: they can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacements to some technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.

Claims

1. A method for generating test case sequences, characterized in that, include: Probes are used to obtain API call data in the business process in real time; For each interface, multi-dimensional data features are extracted based on the corresponding call data. These data features include data fingerprints, semantic vectors, and structural hashes. Feature matching is performed based on the data characteristics of each interface to determine the dependencies between interfaces; Construct an interface business process diagram based on the dependencies between interfaces; A test case sequence is generated based on the interface business process diagram, and the test case sequence is associated with a static data template. Tests are then executed by dynamically injecting parameters.

2. The method according to claim 1, characterized in that, The step of performing feature matching based on the data characteristics of each interface to determine the dependencies between interfaces includes: For each dimension, the similarity between interfaces is calculated based on the data features of the current dimension to obtain the dimension score corresponding to the current dimension. The dimension score includes fingerprint consistency score, semantic consistency score and structural temporal consistency score. Calculate the comprehensive dependency score between the predecessor interface and the successor interface based on the aforementioned dimension scores; When the overall dependency score exceeds a preset threshold, the dependency relationship between interfaces is determined, and the binding identifiers of the predecessor interface and the successor interface are generated. The fingerprint consistency score is obtained based on the similarity between the data fingerprints of the interfaces, the semantic consistency score is obtained based on the similarity between the semantic vectors of the interfaces, and the structural temporal consistency score is obtained based on the structural hash of the interfaces and the response completion time or request time.

3. The method according to claim 2, characterized in that, When the dimension is a data fingerprint; the similarity calculation between the interfaces based on the data features of the current dimension yields the dimension score corresponding to the current dimension, including: Perform precise hash fingerprint matching between the output fields of the predecessor interface and the input fields of the successor interface; If they match, it is determined that the exact match condition is met, and the first sub-score when the exact match condition is met is obtained; If they do not match, it is determined whether the exact hash fingerprint of the input field of the successor interface matches the fuzzy fingerprint set of the predecessor interface. If they match, it is determined that the fuzzy matching condition is met, and the second sub-score when the fuzzy matching condition is met is obtained. The fuzzy fingerprint set includes the result of the predecessor interface output value after encoding or format conversion. If neither the exact matching condition nor the fuzzy matching condition is met, then the third sub-score is obtained, and the first sub-score, the second sub-score, and the third sub-score decrease in that order. Among all combinations of input and output fields, the fingerprint consistency score of the predecessor and successor interfaces is calculated based on the highest sub-score of each obtained field combination.

4. The method according to claim 3, characterized in that, When the dimension is a semantic vector; the similarity calculation between the interfaces based on the data features of the current dimension, to obtain the dimension score corresponding to the current dimension, includes: The field combination whose fingerprint consistency score is greater than the third sub-score is determined as the target field combination; For each target field combination, obtain the semantic vectors of the two field names in the target field combination, and calculate the cosine similarity between the two semantic vectors; The highest cosine similarity is taken as the semantic consistency score of the predecessor and successor interfaces.

5. The method according to claim 2, characterized in that, When the dimension is a structure hash; the similarity calculation between the data features based on the current dimension, to obtain the dimension score corresponding to the current dimension, includes: Calculate the timing constraint scores for the predecessor and successor interfaces based on the response completion time of the predecessor interface and the request start time of the successor interface. A structural similarity score is obtained by comparing the structural similarity between the output structural hash of the predecessor interface and the input structural hash of the successor interface. The temporal constraint score and the structural similarity score are weighted and summed using preset weight information to obtain the structural temporal consistency score.

6. The method according to claim 5, characterized in that, The calculation of timing constraint scores for the predecessor and successor interfaces based on the response completion time of the predecessor interface and the request start time of the successor interface includes: The predecessor and successor interfaces that meet the timing constraints are selected, whereby the timing constraints require that the response completion time of the predecessor interface is earlier than the request start time of the successor interface. For the predecessor and successor interfaces that satisfy the timing constraints, calculate the time interval between the request start time of the successor interface and the response completion time of the predecessor interface. A timing constraint score is obtained by scoring whether the time interval is within a preset time window.

7. The method according to claim 2, characterized in that, The step of constructing the interface business process diagram based on the dependencies between interfaces includes: An initial flowchart is constructed based on the dependencies between interfaces. The nodes of the initial flowchart are interfaces, the edges are the dependencies between interfaces, and the edge weights are the comprehensive dependency scores between the associated interfaces. For the initial flowchart, identify nodes whose call frequency exceeds a preset threshold, and reduce the weight of the nodes or edges associated with those nodes. Calculate the average of all the edge weights to obtain a reference value; In the initial flowchart, remove edges whose weights are lower than the reference value; For any two related nodes in the initial flowchart, calculate the total dependency strength of different paths between the nodes. The total dependency strength is the sum of the edge weights of all edges in the path. Paths between nodes are removed based on the difference between the total dependency strength of different paths and the total dependency strength of the shortest path between nodes.

8. A test case sequence generation device, characterized in that, include: The data acquisition module is used to acquire API call data in the business process in real time using probes. The data feature extraction module is used to extract multi-dimensional data features for each interface based on the corresponding call data. The data features include data fingerprints, semantic vectors, and structural hashes. The dependency determination module is used to perform feature matching based on the data characteristics of each interface in order to determine the dependency relationships between interfaces. The business process diagram building module is used to build interface business process diagrams based on the dependencies between interfaces. The generation and execution module is used to generate a test case sequence based on the interface business process diagram, associate the test case sequence with a static data template, and execute the test by dynamically injecting parameters.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the test case sequence generation method as described in any one of claims 1-7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the test case sequence generation method as described in any one of claims 1-7.

Citation Information

Cited By

  • Demand-driven test case automatic generation method and system based on semantic test chart

    CN122152714A