Test case generation method and device, medium and product
By parsing the documents to be tested and generating test cases using business knowledge graphs and test case generation models, and by combining supervised learning to optimize the generation results, the problem of existing technologies being unable to perceive the impact of existing functions when generating test cases has been solved, thereby improving the quality and accuracy of test case generation.
Patent Information
- Application Number
- CN202511214397.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-28
- Publication Date
- 2025-11-18
AI Technical Summary
Existing test case generation methods rely excessively on manually written requirements documents, lack the ability to explore the correlations between existing business systems, and result in poor readability of the generated test cases, which fail to cover key business scenarios. Furthermore, the intelligent agent generation scheme suffers from redundancy and violations of business rules.
By receiving and parsing user-uploaded test documents, the system uses a business knowledge graph to identify the impact function nodes corresponding to the function modification points, generates target test requirements, generates basic test cases based on a case generation model, generates target test cases by combining target format templates, and introduces supervised learning algorithms to optimize the generation results.
It improved the quality of generated test cases, solved the problem that generated test cases could not perceive the impact of existing functions, improved the accuracy and readability of generated test cases, and reduced the probability of redundancy and violation of business rules.
Smart Images

Figure CN120973686A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of software testing and data processing, and can be used in the technical field of financial technology, and particularly relates to a test case generation method, device, medium and product. BACKGROUND
[0002] The current test case generation method includes: obtaining the classified and labeled function entity or keyword in the demand document by using a pre-trained model based on demand analysis, and generating a business logic flowchart, but this method excessively relies on manually written demand documents or software manuals, resulting in that the analysis result is limited by the completeness and accuracy of the document, and lacks correlation mining of the existing business system. Based on code analysis, that is, according to the key nodes in the code execution path model, branches, loops and exception handling are identified to generate test cases covering all paths, but this method reverses the demand from the code logic, lacks business semantic understanding, and the generated cases are poor in readability and cannot cover key business scenarios. Based on the agent generation, that is, the cases generated based on the large model, the historical cases and business rules are retrieved through the enhancement engine to solve the problem of lack of domain knowledge in the large language model, but this method requires high semantic statement of the prompt engineer, and the same prompt may lead to different results without a fixed and reliable prompt framework. SUMMARY
[0003] The present application provides a test case generation method, device, medium and product to improve the quality of case generation.
[0004] According to an aspect of the present application, a test case generation method is provided, comprising:
[0005] receiving and analyzing a user-uploaded test document to obtain a function modification point;
[0006] determining an impact function node corresponding to the function modification point from a business knowledge graph based on the function modification point, and generating a target test requirement;
[0007] generating a basic test case based on a case generation model for the target test requirement; the basic test case includes a basic test logic;
[0008] generating a target test case according to the basic test logic and a target format template.
[0009] According to another aspect of the present application, a test case generation device is provided, comprising:
[0010] a function modification point determination module configured to receive and analyze a user-uploaded test document to obtain a function modification point;
[0011] The test requirement determination module is configured to determine, based on the function modification point, an influence function node corresponding to the function modification point from the business knowledge graph, and generate a target test requirement.
[0012] The basic test case generation module is configured to generate, based on a case generation model, a basic test case for the target test requirement, wherein the basic test case comprises a basic test logic.
[0013] The target test case generation module is configured to generate a target test case according to the basic test logic and a target format template.
[0014] According to another aspect of the present application, there is provided an electronic device, comprising:
[0015] at least one processor; and
[0016] a memory communicatively connected to the at least one processor; wherein
[0017] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the test case generation method according to any one of the embodiments of the present application.
[0018] According to another aspect of the present application, there is provided a computer readable storage medium storing computer instructions for enabling a processor to implement the test case generation method according to any one of the embodiments of the present application when executed by the processor.
[0019] According to another aspect of the present application, there is provided a computer program product comprising a computer program for implementing the test case generation method according to any one of the embodiments of the present application when executed by a processor.
[0020] The technical solution of the embodiments of the present application comprises the following steps: receiving and analyzing a user-uploaded document to be tested to obtain a function modification point; determining, based on the function modification point, an influence function node corresponding to the function modification point from a business knowledge graph, and generating a target test requirement; generating, based on a case generation model, a basic test case for the target test requirement; the basic test case comprises a basic test logic; and generating a target test case according to the basic test logic and a target format template. The above technical solution solves the problem that the generated test case cannot perceive the influence of the existing function, and improves the quality of case generation.
[0021] It should be understood that the content described in this part is not intended to identify key or important features of the embodiments of the present application, nor to limit the scope of the present application. Other features of the present application will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments 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 any creative effort based on these drawings.
[0023] Figure 1 is a flow chart of a test case generation method according to an embodiment of the present application;
[0024] Figure 2 is a flow chart of a test case generation method according to an embodiment of the present application;
[0025] Figure 3 is a structural schematic diagram of a test case generation device according to an embodiment of the present application;
[0026] Figure 4 is a structural schematic diagram of an electronic device for implementing the test case generation method according to an embodiment of the present application. DETAILED DESCRIPTION
[0027] In order to make the person skilled in the art better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely with reference to the drawings of the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without any creative effort should be within the scope of the present application.
[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily mean a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0029] In addition, it also needs to be explained that in the technical solutions of the application, the collected information is information and data authorized by the user or authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of related data comply with relevant laws, regulations and standards of relevant countries and regions, necessary security measures are taken, public order and good customs are not violated, and corresponding operation entrances are provided for users to choose authorization or refusal.
[0030] The existing scheme excessively relies on standardized requirement document input, lacks active association capability for stock business logic, cannot automatically identify semantic association between historical function nodes and current requirements, the generated test cases have poor readability and low business scene restoration degree, the core transaction scene library construction efficiency is low, and the accuracy of change impact range analysis is affected. Moreover, the existing scheme can only use fixed templates for import analysis and export, is not suitable for iterative test system case import function, and often needs manual maintenance of exported cases. Furthermore, the adoption rate of the recommended cases of the existing scheme is low, that is, the current generation scheme of the test case based on LLM has multiple bottlenecks, the third-party intelligent agent has sensitive business data and unauthorized access risk, does not meet the regulatory requirements of the financial industry, the generated cases have high redundancy and low effective coverage, depend on external application programming interfaces (APIs), the generated logic is not auditable, and the trusted verification of the key business system is affected.
[0031] Figure 1 A flowchart of a test case generation method according to an embodiment of the application is shown. The embodiment can be applied to the case of how to generate a test case in the financial field. The method can be executed by a test case generation device, which can be realized in the form of hardware and / or software. The test case generation device can be configured in an electronic device carrying a test case generation function, such as a server. As shown in the figure, the method comprises the following steps. Figure 1
[0032] S110, receiving and analyzing a user-uploaded test document to obtain a function modification point.
[0033] In this embodiment, the function modification point refers to a modification point of a business function. The test document refers to a business document that needs to be tested for new functions.
[0034] Specifically, in response to the input operation of the user, the test document is obtained, and the test document is analyzed to obtain the function modification point.
[0035] S120, determining an impact function node corresponding to the function modification point from a business knowledge graph based on the function modification point, and generating a target test requirement.
[0036] In this embodiment, the business knowledge graph refers to a knowledge graph related to business in a financial scenario; the node in the business knowledge graph is a business function node, and the edge in the business knowledge graph is an influence relationship between different business function nodes. The so-called influence function node refers to a business function node affected or associated with a function modification point. The so-called target test requirement refers to the requirement for testing the function modification point and the influence function point.
[0037] Specifically, taking the function modification point as an index, the influence supply node corresponding to the function modification point is determined from the business knowledge graph, and the target test requirement is generated.
[0038] S130, generating a basic test case for the target test requirement based on a case generation model.
[0039] In this embodiment, the basic test case refers to a test case directly generated by the case generation model, and optionally includes a basic test logic.
[0040] Specifically, the target test requirement is input into the case generation model, and the model outputs the basic test case.
[0041] S140, generating a target test case according to the basic test logic and a target format template.
[0042] In this embodiment, the target format template refers to the output format of the final test case; optionally, the target format template can be pre-set. The so-called target test case refers to the finally generated test case.
[0043] An optional way can process the basic test logic according to the target format template to obtain the target test case.
[0044] Another optional way, according to the basic test logic and the target format template, generates a target test case, including: performing semantic feature extraction on the basic test logic to obtain target semantic features; the target semantic features include abstract test steps and test data; parsing the target format template to obtain a target topology structure and a field to be filled; mapping the abstract test steps to the target topology structure, and filling the test data in the field to be filled to obtain the target test case.
[0045] Specifically, based on a natural language recognition algorithm, the semantic features of the basic test logic are extracted to obtain target semantic features, wherein the target semantic features include abstract test steps and test data, the target format template is parsed to obtain a target topology structure and a field to be filled, the abstract test steps are mapped to the target topology structure, and the test data is filled in the field to be filled to obtain the target test case.
[0046] It should be noted that, in order to meet the input and output analysis of various format documents, it is necessary to establish a standardized template configuration protocol and provide a multi-modal format registration interface. The interface supports the custom upload of structured data templates such as JSON / XML and target format templates. A dynamic field constraint engine is introduced to realize field-level format control through regular expressions and data type verification rules.
[0047] It can be understood that by providing a multi-format input and output interface and standardizing the case template workflow generation, the problem of rigid input and output document format requiring manual intervention is solved.
[0048] The technical scheme of the embodiment of the application receives and analyzes the user-uploaded test document to obtain a function modification point, determines an influence function node corresponding to the function modification point from a business knowledge graph based on the function modification point, and generates a target test requirement; based on a case generation model, a basic test case is generated for the target test requirement; the basic test case includes a basic test logic; and a target test case is generated according to the basic test logic and a target format template. The above technical scheme solves the problem that the generated test case cannot perceive the influence of the existing function, and improves the case generation quality.
[0049] Figure 2 is a flowchart of a test case generation method according to an embodiment of the application. Based on the above-mentioned embodiment, the determination of the business knowledge graph and the case generation model is further described. As shown in Figure 2 the method comprises:
[0050] S210, receiving and analyzing the user-uploaded test document to obtain a function modification point.
[0051] S220, based on the function modification point, determining an influence function node corresponding to the function modification point from a business knowledge graph, and generating a target test requirement.
[0052] S230, based on a case generation model, generating a basic test case for the target test requirement.
[0053] Among them, the basic test case includes a basic test logic;
[0054] S240, according to the basic test logic and the target format template, generating a target test case.
[0055] In an optional manner, the business knowledge graph is determined in the following manner: a core function asset library is constructed according to business data; the core function asset library comprises a business scenario asset library and a transaction link asset library; a business entity and an attribute value of the business entity are extracted from the core function asset library, the business entity is taken as a node of the business knowledge graph, and the attribute value is taken as an attribute of the node; and a relationship edge of the business knowledge graph is determined according to a business hierarchical relationship in the business scenario asset library.
[0056] The core function asset library stores a historical version of a core function description, an interface calling link and a dependency relationship; optionally, the core function asset library comprises a business scenario asset library and a transaction link asset library; the business scenario asset library is implemented by using a pyramid model; the pyramid model comprises three layers of business functions; the first layer of functions is a basic transaction scenario, that is, a transaction scenario frequently used by a financial system, such as payment, savings, loan, settlement and the like; the second layer of functions is a specific business scenario under the basic transaction scenario, such as a compliance process special installment, a bill installment, a second payment, a e-loan and the like; and the third layer of functions is a business branch of the specific business scenario, which is further classified and refined to an actual operation, such as a new generation special installment normal process through calculation (increasing confidence), application, approval, archiving, opening an account, lending and post-loan; a direct account opening process application, opening an account, lending and post-loan and the like.
[0057] The transaction link asset library is used to represent an interface calling link, is implemented by using a chain structure model, and clearly shows a data transmission path, such as a special installment face-to-face signing update transaction data flow being set page input→set interface input or set page input→set interface input; the transaction link asset library is associated with the third layer of functions in a one-to-one or one-to-many manner. Specifically, for the one-to-one association, one chain model node (such as a specific interface F-BAM-ISAS) only serves one specific third layer function point (such as “special installment customer information input”) in the asset library. For the one-to-many association, one chain model node (such as a general data verification service) simultaneously serves multiple related third layer function points (such as “installment application input”, “customer information modification”, “credit limit adjustment application” and the like) in the asset library.
[0058] It can be understood that by establishing a precise mapping relationship between the nodes / steps and the function points, when a parameter of a certain node (a data source, a processing logic, a target interface, a switch configuration) is changed, one or more third layer function points associated with the node can be directly located, so that a specific business function scenario possibly affected by the change can be quickly identified, and precise tracing and analysis of an influence range are achieved.
[0059] Then, the business entity and the attribute value of the business entity are extracted from the core function asset library, the business entity is taken as a node of the business knowledge graph, and the attribute value is taken as an attribute of the node; and the relationship edge of the business knowledge graph is determined according to the business hierarchical relationship in the business scenario asset library.
[0060] Specifically, each layer business entity (basic scenario, specific scenario, business process, operation step, system interface) defined in the core function asset library is automatically extracted and created as a node (Node) in the knowledge graph. The node type (Label) is determined according to its belonging level or category, such as basic scenario, specific business scenario, business process, operation step, and system interface. According to the preset hierarchical relationship in the core function asset library, such as belongs to, contains step, and realizes, the relationship edge (Edge) is automatically created between the corresponding nodes. According to the interface calling link stored in the core transaction link asset library, the calling relationship edge is automatically created between the interface nodes, and the calling direction is marked. According to the mapping rule defined in the asset library association, the mapping relationship edge is automatically created between the business operation step node and the mapped system interface node. The entity attributes (such as process step sequence number, interface version information, and description text) stored in the core function asset library are automatically filled into the attributes (Property) of the corresponding nodes of the knowledge graph; the generated knowledge graph structure containing nodes, relationships, and attributes is persistently stored in the graph database. When the content of the core function asset library (new function description, interface change, link update, and mapping relationship adjustment) changes, the incremental update mechanism of the corresponding graph node, relationship, or attribute is triggered.
[0061] It can be understood that by constructing the knowledge graph, it is convenient to subsequently quickly locate the function modification point and the influence point, and quickly generate the test requirement.
[0062] The application introduces an artificial marking-feedback learning mechanism: the user can mark unreasonable test data in the generated case; through a supervised learning algorithm, the marked data is taken as negative sample training data to generate a model, and the rationality of the subsequent generation result is optimized.
[0063] In order to improve the adoption rate of the test cases generated by the system according to the requirement document or the software development specification, the following analysis is made:
[0064] The agent-generated test cases may not be adopted because of redundancy or violation of business rules, and the essential reason is that the incremental requirements are described ambiguously, omitting the content that is considered common sense by developers and testers. To solve the problem of redundancy and error in intelligent case generation, the feedback learning mechanism is used to improve the adoption rate of system case recommendations, which requires manual intervention for labeling. For non-adopted cases, they can be stored and classified into error and duplicate cases (expandable later) based on user feedback after case generation.
[0065] For example, the requirement document describes that the newly added parameter field mobileNo is 11 digits, and the recommended test case is as follows:
[0066] Case name Execution step Expected result Recommended case 1 Mobile phone number length is 11 digits Mobile phone number is saved successfully Recommended case 2 Mobile phone number length is 12 digits Save error: mobile phone number cannot exceed 11 digits Recommended case 3 Mobile phone number length is 13 digits Save error: mobile phone number cannot exceed 11 digits Recommended case 4 Mobile phone number input: 028-832… Mobile phone number is saved successfully
[0067] Among them, the recommended cases 1 and 2 are considered to be generated by the length boundary value method and are adopted; the recommended case 3 is considered to be a redundant case, because its essence belongs to the same super-long equivalence class range as the recommended case 2, and is marked as duplicate by the user; the recommended case 4 is considered to be an error case, because it lacks the hidden business concept, and this function is only applicable to domestic mobile numbers, and the default area code is 028, which does not need to fill in the area code, and is marked as error by the user.
[0068] A supervised learning algorithm is added based on the recommendation of the intelligent agent, and the difference between the negative sample and the adopted sample is regarded as the prediction error, which is converted into a gradient signal to drive parameter iterative update. The specific implementation is as follows:
[0069] In an optional manner, the case generation model is obtained by training in the following manner, including: determining training samples; the training samples include positive samples and negative samples; training the discriminant model according to the training samples to obtain model prediction values; the model prediction values include case adoption probability, case quality score and predicted text; based on a preset loss function, the training loss is calculated according to the model prediction value and the true label; the back propagation gradient is determined according to the training loss; the parameters of the discriminant model are updated according to the back propagation gradient and the learning rate, and the case generation model is obtained.
[0070] The positive sample includes a requirement description segment and context information; the requirement description segment includes a natural language description text of a current function point or requirement change point, such as a requirement document segment or a software development specification segment; the context information includes associated function module information, existing business rule summary and domain knowledge graph embedding; the negative sample includes redundant cases and error cases.
[0071] In this embodiment, the discriminant model uses a model based on the Transformer architecture or other models suitable for discrimination. The true label means the true value of the training sample, including 1-adopted and 0-not adopted, including errors or redundancies.
[0072] Specifically, the training samples (X = Text_req, Context) are input into the discriminative model, and the model predicts the values (case adoption probability P_adopt, case quality score Score, or generated predicted text). Here, Text_req represents the requirement description fragment, and Context represents the contextual information. Based on a preset loss function, such as the binary cross-entropy loss function, the training loss is calculated according to the model's predicted values and the true labels. For example, the binary cross-entropy loss L = -[Y*log(P_adopt) + (1-Y)*log(1-P_adopt)]. For negative samples (Y = 0), the loss becomes L = -log(1-P_adopt). When the model incorrectly assigns a high P_adopt to a negative sample, log(1-P_adopt) will be very small, resulting in a large L. Alternatively, the text generation loss can be determined by calculating the difference between the generated predicted text sequence and the target sequence (the true label), i.e., the correct text expected by the user, or a special sequence marked as invalid, at each position, thus obtaining the training loss.
[0073] Furthermore, the backpropagation gradient is determined based on the training loss. Using the backpropagation gradient and the learning rate, the parameters of the discriminative model are updated to obtain the case generation model. Specifically, the gradient of the loss L with respect to the parameters of each layer of the model is calculated using the backpropagation algorithm. gradient It is a vector indicating the direction in which L increases with respect to each parameter. Using the optimizer, along the gradient... Updating model parameters in the opposite direction Where η is the learning rate. This update step directly utilizes the high loss signal L brought by negative samples, driving the model parameters to adjust in the direction of reducing the probability of outputting negative samples. It can be understood that the model learns "when seeing similar inputs, it should avoid generating such outputs that are marked as errors or redundancies".
[0074] Using the above mobile phone number generation case as an example, we can explain the processing logic of this supervised model. The user labels recommended case 3 as "redundant" and case 4 as "incorrect".
[0075] From the perspective of the model, the negative sample is when the demand description fragment Text_req="add input field mobileNo mobile number is 11 digits", the model generates recommended case 4-input 028-83291022. The user marks this case as "wrong". In subsequent training, the model encounters similar inputs such as "11 digits", "mobile number", etc. If it tends to generate cases containing "area code", the loss value will be high. High loss leads to large gradient, forcing the model to adjust internal parameters significantly, reducing the likelihood of generating such cases that violate the implicit rule that "domestic mobile number does not require area code". It can be understood that the model has learned this hidden business constraint from the error.
[0076] By constructing the above supervised learning model and using artificially labeled negative samples to calculate high loss value to drive parameter backpropagation, the continuous optimization of the recommendation system is realized. The problem of low adoption rate caused by the generation of redundant cases or cases that violate business rules by existing agents is effectively solved, and the rationality and practicality of the generated test cases are significantly improved.
[0077] The execution steps and prediction results in the above recommended cases are respectively taken as elements a, b affecting the adoption rate Ra, a, b are converted into numerical values through natural language processing for comparison to obtain errors Ea=a1-a4, Eb=b1-b4, i.e. negative feedback information, for quantifying prediction bias. Whether the scenario of accurately recommending adopted cases can be abstracted as a decision tree problem. By continuously guiding feature split selection through the purity error of sample labels in leaf nodes, the algorithm is adjusted to make more correct decisions by controlling tree complexity, minimum separable number, and cost pruning strength, etc. parameters, and more likely to be adopted recommended cases are obtained from the results.
[0078] The data rationality self-learning module constructs a recommendation mechanism of the user feedback optimization system through supervised learning, solves the problem of low adoption rate caused by the generation of redundant cases and cases that do not meet business rules by existing agents.
[0079] The technical scheme of the embodiment of the application receives and analyzes the user-uploaded test document to obtain a function modification point; determines an impact function node corresponding to the function modification point from a business knowledge graph based on the function modification point, and generates a target test requirement; generates a basic test case based on a case generation model for the target test requirement; the basic test case includes a basic test logic; and generates a target test case according to the basic test logic and a target format template. The above technical scheme solves the shortcoming that the generated test case cannot perceive the impact of the existing function, and improves the case generation quality.
[0080] On the basis of the above-mentioned embodiments, as an optional mode of the present application, if the target test case is not adopted, the target test case is taken as a negative sample, and the case generation model is retrained and updated.
[0081] Specifically, if the target test case is not adopted, the target test case is marked as a negative sample, and the case generation model is retrained using the target test case. It can be understood that the performance of the case generation model is further improved by updating and enriching the negative sample to form a closed loop.
[0082] Figure 3 It is a structural schematic diagram of a test case generation device provided by an embodiment of the present application. The present embodiment can be applied to the case of how to generate a test case in the financial field. The test case generation device can be realized in the form of hardware and / or software. The test case generation device can be configured in an electronic device carrying a test case generation function, such as a server. As shown in the figure, the device includes: Figure 3
[0083] The function modification point determination module 310 is configured to receive and parse the user-uploaded test document to obtain a function modification point.
[0084] The test requirement determination module 320 is configured to determine an impact function node corresponding to the function modification point from the business knowledge graph based on the function modification point, and generate a target test requirement.
[0085] The basic test case generation module 330 is configured to generate a basic test case based on a case generation model for the target test requirement. The basic test case includes a basic test logic.
[0086] The target test case generation module 340 is configured to generate a target test case according to the basic test logic and a target format template.
[0087] The technical scheme of the present embodiment, by receiving and parsing the user-uploaded test document, obtaining a function modification point, determining an impact function node corresponding to the function modification point from the business knowledge graph based on the function modification point, and generating a target test requirement, generating a basic test case based on a case generation model for the target test requirement, the basic test case including a basic test logic, and generating a target test case according to the basic test logic and a target format template, solves the shortcoming that the generated test case cannot perceive the impact of the existing function, and improves the case generation quality.
[0088] Optionally, the device further includes a knowledge graph determination module configured to:
[0089] construct a core function asset library according to business data; the core function asset library includes a business scenario asset library and a transaction link asset library;
[0090] extracting the business entities and attribute values of the business entities from the core function asset library, taking the business entities as nodes of the business knowledge graph, and taking the attribute values as attributes of the nodes;
[0091] determining the relationship edges of the business knowledge graph according to the business hierarchical relationships in the business scenario asset library.
[0092] Optionally, the business scenario asset library is implemented by using a pyramid model; the pyramid model includes three layers of business functions; the first layer of functions is a basic transaction scenario; the second layer of functions is a specific business scenario under the basic transaction scenario; and the third layer of functions is a business branch of the specific business scenario; the transaction link asset library is implemented by using a chain structure model; and the transaction link asset library is in one-to-one or one-to-many association with the third layer of functions.
[0093] Optionally, the model training module is configured to:
[0094] determine training samples; the training samples include positive samples and negative samples;
[0095] train the discriminant model according to the training samples to obtain model prediction values; the model prediction values include a case adoption probability, a case quality score, and a predicted text;
[0096] based on a preset loss function, calculate a training loss according to the model prediction values and real labels;
[0097] determine a back propagation gradient according to the training loss;
[0098] update parameters of the discriminant model according to the back propagation gradient and a learning rate to obtain a case generation model.
[0099] Optionally, the positive samples include a requirement description segment and context information; the requirement description segment includes a natural language description text of a current function point to be tested or a requirement change point; and the context information includes associated function module information, an existing business rule summary, and a domain knowledge graph embedding; and the negative samples include redundant cases and error cases.
[0100] Optionally, the target test case generation module 340 is configured to:
[0101] perform semantic feature extraction on the basic test logic to obtain target semantic features; the target semantic features include abstract test steps and test data;
[0102] perform parsing on the target format template to obtain a target topology structure and fields to be filled;
[0103] map the abstract test steps to the target topology structure, and fill the test data in the fields to be filled to obtain a target test case.
[0104] Optionally, the model training module is further configured to:
[0105] If the target test case is not adopted, the target test case is taken as a negative sample, and the case generation model is retrained and updated.
[0106] The test case generation apparatus provided in the embodiments of the present application can execute the test case generation method provided in any of the embodiments of the present application, and has the corresponding function modules and beneficial effects of the execution method.
[0107] According to the embodiments of the present application, the present application further provides an electronic device, a readable storage medium and a computer program product.
[0108] Figure 4 is a structural schematic diagram of an electronic device for implementing the test case generation method of the embodiments of the present application. Figure 4 A structural schematic diagram of an electronic device 10 that can be used to implement embodiments of the present application is shown. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular telephones, smart phones, wearable devices (such as headsets, glasses, watches, etc.), and other similar computing devices. The components shown in the figure, their connections and relationships, and their functions, are merely examples, and are not intended to limit the implementations of the present application described and / or claimed in this document.
[0109] As shown in Figure 4 The electronic device 10 includes at least one processor 11, and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., which is communicatively connected to the at least one processor 11, wherein the memory stores a computer program that can be executed by the at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0110] A plurality of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunication networks.
[0111] The processor 11 can be various general and / or special purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 performs various methods and processes described above, such as the test case generation method.
[0112] In some embodiments, the test case generation method can be implemented as a computer program tangibly embodied in a computer readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded onto the RAM 13 and executed by the processor 11, one or more steps of the test case generation method described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to perform the test case generation method by any other appropriate means, such as by means of firmware.
[0113] Various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a programmable logic device (PLD), a computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
[0114] Computer programs for implementing the methods of the present application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer program, when executed, can cause instructions defined in the flow charts and / or block diagrams to be implemented. The computer program can be executed entirely on a machine, partially on a machine, partially on a machine as a stand-alone software package and partially on a remote machine or entirely on a remote machine or server.
[0115] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer-readable storage medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of a machine-readable storage medium will include one or more lines of a program of instructions in a transitory signal, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0116] To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
[0117] The systems and techniques described herein can be implemented in a computing system that includes a back end component, e.g., as a data server, or that includes a middleware component, e.g., an application server, or that includes a front end component, e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described herein, or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication, e.g., a communication network. Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), a blockchain network, and the Internet.
[0118] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. A server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system, and solves the defects of large management difficulty and weak business scalability in traditional physical host and virtual private service.
[0119] It should be understood that the various forms of flow shown above can be re-ordered, added to, or deleted from without departing from the scope of the present disclosure. For example, the steps recited in the present disclosure can be executed in parallel, executed in sequence, or executed in different orders, as long as the desired results of the technical solutions of the present disclosure can be achieved, and the present disclosure is not limited herein.
[0120] The above detailed description does not constitute a limitation on the protection scope of the present application. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements, and improvements made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A test case generation method, characterized in that, include: Receive and parse the user-uploaded test document to obtain the functional modification points; Based on the aforementioned functional modification points, the affected functional nodes corresponding to the functional modification points are determined from the business knowledge graph, and target test requirements are generated. Based on the case generation model, basic test cases are generated for the target test requirements; The basic test cases include basic test logic; Based on the basic test logic and target format template, generate target test cases.
2. The method according to claim 1, characterized in that, The business knowledge graph is determined in the following way: A core functional asset library is constructed based on business data; the core functional asset library includes a business scenario asset library and a transaction link asset library. Extract business entities and attribute values of the business entities from the core functional asset library, use the business entities as nodes of the business knowledge graph, and use the attribute values as attributes of the nodes; Based on the business hierarchy relationships in the business scenario asset library, determine the relationship edges of the business knowledge graph.
3. The method according to claim 2, characterized in that, The business scenario asset library is implemented using a pyramid model; the pyramid model includes three layers of business functions; the first layer is the basic transaction scenario; the second layer is the specific business scenario under the basic transaction scenario; the third layer is the business branch of the specific business scenario; the transaction link asset library is implemented using a chain structure model; the transaction link asset library is associated with the third layer function in a one-to-one or one-to-many manner.
4. The method according to claim 1, characterized in that, The case generation model is trained in the following ways: Determine the training samples; the training samples include positive samples and negative samples; The discrimination model is trained based on the training samples to obtain the model prediction value; the model prediction value includes the case adoption probability, the case quality score, and the predicted text; Based on a preset loss function, the training loss is calculated according to the model's predicted values and the true labels; The backpropagation gradient is determined based on the training loss. Based on the backpropagation gradient and learning rate, the parameters of the discriminative model are updated to obtain the case generation model.
5. The method according to claim 4, characterized in that, The positive samples include a requirement description fragment and contextual information; wherein, the requirement description fragment includes natural language description text of the current functional point to be tested or the requirement change point; the contextual information includes information on associated functional modules, summaries of existing business rules, and embeddings of domain knowledge graphs; the negative samples include redundant cases and erroneous cases.
6. The method according to claim 1, characterized in that, Based on the aforementioned basic test logic and target format template, generate target test cases, including: Semantic features are extracted from the basic test logic to obtain target semantic features; the target semantic features include abstract test steps and test data. The target format template is parsed to obtain the target topology and fields to be filled; The abstract test steps are mapped to the target topology, and the test data is used to fill in the fields to be filled, thus obtaining the target test case.
7. The method according to any one of claims 1-5, characterized in that, Also includes: If the target test case is not adopted, the target test case is used as a negative sample, and the test case generation model is retrained and updated.
8. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the test case generation method according to any one of claims 1-7.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the test case generation method of any one of claims 1-7.
10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the test case generation method according to any one of claims 1-7.