Test case generation method and device and storage medium
By generating transaction message domain vectors and using a neural network model to output test cases, the problem of test case generation being intrusive to financial trading systems was solved, achieving non-intrusive test case generation and ensuring the security and accuracy of the production environment.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-26
- Publication Date
- 2026-04-10
AI Technical Summary
In existing technologies, test case generation methods have an intrusive impact on financial transaction systems, and there is a lack of effective solutions.
By receiving the target test requirements, a target transaction message domain vector is generated, and test cases are output using the test case generation model. Feature extraction and splicing are performed by combining text convolutional neural network, long short-term memory neural network and multi-head latent attention mechanism modules to generate target test cases.
It eliminates the need to rely on real message replay, reducing the intrusive impact on the financial transaction production environment and ensuring the security of the production environment and the accuracy of test cases.
Smart Images

Figure CN121833480A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence, and more specifically, to a method, apparatus, and storage medium for generating test cases. Background Technology
[0002] Automated testing refers to the use of test scripts and frameworks to automatically execute a series of tests to evaluate the functionality, performance, security, and stability of a system. It is a crucial step in ensuring the software quality and security of financial trading systems. During the testing process, traditional manual testing struggles to cover all scenarios, and manually writing test cases is inefficient; therefore, automatically generating test cases is of paramount importance.
[0003] In existing technologies, test cases are typically generated by replaying real messages from a production environment. This requires using customized testing tools to capture, process, and anonymize the original transaction messages from the production environment. This method can have an intrusive impact on the original production environment.
[0004] There is currently no effective solution to the problem that the generation of test cases in related technologies can have an intrusive impact on financial trading systems. Summary of the Invention
[0005] The main objective of this application is to provide a method, apparatus, and storage medium for generating test cases, in order to solve the problem that the generation of test cases in related technologies can have an intrusive impact on financial trading systems.
[0006] To achieve the above objectives, according to one aspect of this application, a method for generating test cases is provided. The method includes: receiving target test requirements and determining target transaction message field information based on the target test requirements; generating a target transaction message field vector based on the target transaction message field information, inputting the target transaction message field vector into a test case generation model, and outputting test cases using the test case generation model; and concatenating the test cases with the target transaction message field information to obtain target test cases.
[0007] Furthermore, generating the target transaction message domain vector based on the target transaction message domain information includes: determining multiple message domain terms based on the target transaction message domain information; obtaining the word vector corresponding to each message domain term using a word mapping function to obtain multiple word vectors; and generating the target transaction message domain vector based on the multiple word vectors.
[0008] Furthermore, the process of inputting the target transaction message domain vector into the test case generation model and outputting test cases using the test case generation model includes: extracting features from the target transaction message domain vector using the text convolutional neural network module in the test case generation model to obtain message domain spatial features; inputting the message domain spatial features into the long short-term memory neural network module in the test case generation model to output message domain sequence features; inputting the message domain sequence features into the multi-head latent attention mechanism module in the test case generation model to output message domain attention fusion features; and inputting the message domain attention fusion features into the output layer of the test case generation model to output test cases.
[0009] Furthermore, the training steps of the test case generation model include: acquiring key-value pair data of multiple transaction messages, wherein each key-value pair data includes a key name and a key value, the key name includes a first subkey name and a first subkey value, and the key value includes a second subkey name and a second subkey value; concatenating the first subkey name and the second subkey name to obtain the input sample, and concatenating the first subkey value and the second subkey value to obtain the label corresponding to the input sample; and training a preset neural network model using the input sample and the label corresponding to the input sample to obtain the test case generation model.
[0010] Furthermore, the test case generation model is obtained by training the preset neural network model using the input samples and their corresponding labels. This includes: determining the preset neural network model based on the text convolutional neural network module, the long short-term memory neural network module, and the multi-head latent attention mechanism module; determining the mean squared error loss function as the target loss function and determining the target optimization algorithm based on the gradient optimization algorithm; and training the preset neural network model by minimizing the target loss function based on the input samples and their corresponding labels to obtain the test case generation model. The target optimization algorithm is used to update the parameters of the preset neural network model during training.
[0011] Furthermore, the test cases are concatenated with the target transaction message field information to obtain the target test cases, including: determining the first message field sub-information and the second message field sub-information based on the target transaction message field information; dividing the test cases according to a preset delimiter to obtain the first test sub-case and the second test sub-case; concatenating the first message field sub-information with the first test sub-case to obtain the test input data; concatenating the second message field sub-information with the second test sub-case to obtain the expected test output data; and determining the target test cases based on the test input data and the expected test output data.
[0012] To achieve the above objectives, according to another aspect of this application, a test case generation apparatus is provided. The apparatus includes: an information determination unit, configured to receive target test requirements and determine target transaction message field information based on the target test requirements; a test case generation unit, configured to generate a target transaction message field vector based on the target transaction message field information, input the target transaction message field vector into a test case generation model, and output test cases using the test case generation model; and a test case acquisition unit, configured to concatenate the test cases with the target transaction message field information to obtain target test cases.
[0013] Furthermore, the case generation unit includes: a word segmentation module, used to determine multiple message domain words based on the target transaction message domain information; a mapping module, used to obtain the word vector corresponding to each message domain word using a word mapping function, resulting in multiple word vectors; and a vector determination module, used to generate the target transaction message domain vector based on the multiple word vectors.
[0014] Furthermore, the case generation unit includes: a convolution extraction module, used to extract features from the target transaction message domain vector based on the text convolutional neural network module in the test case generation model to obtain message domain spatial features; a sequence extraction module, used to input the message domain spatial features into the long short-term memory neural network module in the test case generation model, and use the long short-term memory neural network module to output message domain sequence features; an attention module, used to input the message domain sequence features into the multi-head latent attention mechanism module in the test case generation model, and use the multi-head latent attention mechanism module to output message domain attention fusion features; and an output module, used to input the message domain attention fusion features into the output layer in the test case generation model, and use the output layer to output test cases.
[0015] Furthermore, the device also includes: a key-value pair acquisition unit, used to acquire key-value pair data of multiple transaction messages, wherein each key-value pair data includes a key name and a key value, the key name includes a first subkey name and a first subkey value, and the key value includes a second subkey name and a second subkey value; a key-value pair processing unit, used to concatenate the first subkey name and the second subkey name to obtain an input sample, and concatenate the first subkey value and the second subkey value to obtain a label corresponding to the input sample; and a model training unit, used to train a preset neural network model using the input sample and the label corresponding to the input sample to obtain a test case generation model.
[0016] Furthermore, the model training unit includes: a model determination module, used to determine a preset neural network model based on a text convolutional neural network module, a long short-term memory neural network module, and a multi-head latent attention mechanism module; a loss function determination module, used to determine the mean squared error loss function as the target loss function and to determine the target optimization algorithm based on the gradient optimization algorithm; and a preset training module, used to train the preset neural network model by minimizing the target loss function based on the input samples and their corresponding labels to obtain a test case generation model, wherein the target optimization algorithm is used to update the parameters of the preset neural network model during the training process.
[0017] Furthermore, the test case acquisition unit includes: a sub-information determination module, used to determine the first message field sub-information and the second message field sub-information based on the target transaction message field information; a sub-case determination module, used to divide the test cases according to a preset separator to obtain the first test sub-case and the second test sub-case; a first splicing module, used to splice the first message field sub-information with the first test sub-case to obtain test input data; a second splicing module, used to splice the second message field sub-information with the second test sub-case to obtain expected test output data; and a test case determination module, used to determine the target test cases based on the test input data and the expected test output data.
[0018] According to another aspect of this application, a computer-readable storage medium is provided, the computer-readable storage medium including a stored program, wherein, when the program is running, it controls the device where the computer-readable storage medium is located to execute any test case generation method.
[0019] According to another aspect of this application, an electronic device is provided, comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include a method for generating any type of test case.
[0020] According to another aspect of this application, a computer program product is provided, including computer instructions, and steps for generating test cases that implement any of the above when the computer instructions are executed by a processor.
[0021] In this embodiment, the target test requirements are received, and the target transaction message field information is determined based on the target test requirements; a target transaction message field vector is generated based on the target transaction message field information, and the target transaction message field vector is input into the test case generation model, which then outputs test cases; the test cases are concatenated with the target transaction message field information to obtain target test cases. This solves the technical problem in the prior art where the generation of test cases would have an intrusive impact on the financial transaction system.
[0022] By receiving target test requirements, using a test case generation model to output test cases, and then concatenating the test cases with target transaction message field information, target test cases are obtained. The target test cases are generated through the process of receiving target test requirements, prediction, and concatenation, without relying on real message playback, reducing the intrusive impact on the financial transaction production environment and ensuring the security of the production environment. Attached Figure Description
[0023] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0024] Figure 1 A hardware structure block diagram of a computer terminal for implementing a test case generation method is shown.
[0025] Figure 2 This is a flowchart of a test case generation method provided according to an embodiment of this application;
[0026] Figure 3 This is a schematic diagram of a test case generation device provided according to an embodiment of this application;
[0027] Figure 4 This is a structural block diagram of an electronic device according to an embodiment of this application. Detailed Implementation
[0028] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0029] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0030] It should be noted that the information collected in this application (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) are information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of this data all comply with relevant laws, regulations, and standards, necessary confidentiality measures have been taken, and they do not violate public order and good morals. Corresponding access points are provided for users to choose to authorize or refuse. For example, interfaces are set up between this system and relevant users or organizations, providing users with corresponding access points to choose to agree to or refuse automated decision-making results; if the user chooses to refuse, the process proceeds to the expert decision-making stage.
[0031] Example 1
[0032] According to an embodiment of this application, a method embodiment for generating test cases is also provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0033] The method embodiment provided in Embodiment 1 of this application can be executed on a mobile terminal, computer terminal, or similar computing device. Figure 1 A hardware block diagram of a computer terminal (or mobile device) for implementing a test case generation method is shown. Figure 1 As shown, the computer terminal 10 (or mobile device) may include one or more processors 102 (shown as 102a, 102b, ..., 102n in the figure) 102 (processor 102 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of a BUS bus), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0034] It should be noted that the aforementioned one or more processors 102 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 10 (or mobile device). As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).
[0035] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the test case generation method in this embodiment. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby implementing the aforementioned test case generation method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0036] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0037] The display may be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 10 (or mobile device).
[0038] Under the aforementioned operating environment, this application provides the following: Figure 2 The method for generating test cases is shown. Figure 2 This is a flowchart of the test case generation method according to Embodiment 1 of this application.
[0039] Step S201: Receive the target test requirements and determine the target transaction message field information based on the target test requirements.
[0040] Optionally, with the authorization of the target user, the target test requirements can be received through the client's user page. These requirements may include the type of financial transaction to be tested, specified by the target user, and multiple target transaction message fields. The target test requirements can be in document format; by parsing the document, the target transaction message field information can be obtained. The target test requirements may also include the number of target test cases. The number of target test cases controls the number of test cases the test case generation model outputs at one time. The target transaction message field information may include the keys of the test input data and the keys of the expected test output data.
[0041] For example, by analyzing the target test requirements, we can find that the financial transaction type is contract test, and the target transaction message field information can be the contract name and the return information.
[0042] Step S202: Generate a target transaction message field vector based on the target transaction message field information, input the target transaction message field vector into the test case generation model, and output test cases using the test case generation model.
[0043] For example, pre-trained word embedding models or dummy coding can be used to convert the target transaction message domain information into a target transaction message domain vector. This vector serves as input data for the test case generation model, helping it better understand the target transaction message domain information. The test case generation model can be trained using a network structure based on TextCNN (a convolutional neural network) - BiLSTM (bidirectional long short-term memory network) - MLA (multi-head latent attention mechanism). When the target testing requirement also includes a target number of test cases, the test case generation model can generate that number of test cases at once, based on the target number.
[0044] Step S203: Concatenate the test case with the target transaction message field information to obtain the target test case.
[0045] Optionally, the test case generation model generates key-value pairs corresponding to the key names in the target transaction message field information. That is, a test case can include key-value pairs for both test input data and expected test output data. By concatenating the key names and key-value pairs, complete test input data and expected test output data can be obtained, and these data are then used as target test cases. When the test case generation model outputs multiple test cases, the target transaction message field information can be used to concatenate each test case to obtain multiple target test cases.
[0046] For example, the target transaction message field information can be the contract name and the return information, and the test case is Company A and contract successful. By concatenating the test case with the target transaction message field information, the target test case is obtained, which includes the test input data: "Contract Name - Company A" and the expected test output data: "Return Information - Contract Successful".
[0047] In summary, by receiving the target test requirements, using the test case generation model to output test cases, and then concatenating the test cases with the target transaction message field information, the target test cases are obtained. The target test cases are generated through the process of receiving the target test requirements, prediction, and concatenation, without relying on the playback of real messages, thus reducing the intrusive impact on the financial transaction production environment and ensuring the security of the production environment.
[0048] To reduce the intrusive impact of generating test cases on the financial transaction system, optionally, generating the target transaction message domain vector based on the target transaction message domain information includes: determining multiple message domain terms based on the target transaction message domain information; using a word mapping function to obtain the word vector corresponding to each message domain term, resulting in multiple word vectors; and generating the target transaction message domain vector based on the multiple word vectors.
[0049] Optionally, the target transaction message field information can be an XML format message or a JSON format message. The target transaction message field information can be text composed of multiple message field words. Multiple message field words corresponding to the target transaction message field information can be obtained by using the Jieba word segmentation tool, and the corresponding word vector can be obtained for each message field word using the word mapping function to obtain multiple word vectors. The multiple word vectors are then integrated to obtain the target transaction message field vector.
[0050] In summary, by determining multiple message domain terms based on the target transaction message domain information, and then using the word mapping function to obtain the target transaction message domain vector, a data foundation was laid for the test case generation model, reducing the intrusive impact of generating test cases on the financial transaction system.
[0051] To reduce the intrusive impact of generated test cases on the financial trading system, optionally, the target transaction message domain vector is input into the test case generation model, and the test case is output using the test case generation model. This includes: extracting features from the target transaction message domain vector using the text convolutional neural network module in the test case generation model to obtain message domain spatial features; inputting the message domain spatial features into the long short-term memory neural network module in the test case generation model to output message domain sequence features; inputting the message domain sequence features into the multi-head latent attention mechanism module in the test case generation model to output message domain attention fusion features; and inputting the message domain attention fusion features into the output layer of the test case generation model to output test cases.
[0052] Optionally, the text convolutional neural network module can be a Text-CNN neural network module. The Text-CNN neural network module uses one-dimensional convolution operations to process the input data. The width of the convolutional kernel is set to multiple different values to capture text features of different sizes. The output feature map (i.e., feature map) of the convolutional layer in the Text-CNN neural network module can be represented as:
[0053] Ci=f(W·X i:i+h-1 +b)
[0054] Where Ci represents the feature map, W represents the weight matrix, b represents the bias term, and X represents the feature map. i:i+h-1 Let f represent the input submatrix from position i to i+h-1, and let f represent the non-linear activation function (e.g., a ReLU activation function). In addition to convolutional layers, the Text-CNN neural network module may also include pooling layers. Pooling layers are used to perform pooling operations on the feature maps. For example, pooling layers may be used to perform max pooling on the feature maps to obtain pooling results with different convolutional kernels. The message domain spatial features output by the Text-CNN neural network module can be a concatenation of different pooling results.
[0055] Optionally, the Long Short-Term Memory (LSTM) neural network module can be a bidirectional LSTM (a type of recurrent neural network) neural network module, which excels at capturing long-term relationships in time series. It maintains and updates the cell state by introducing a logical control unit with three gates: a forget gate, an input gate, and an output gate. The bidirectional LSTM (a type of recurrent neural network) neural network module can include forward LSTM and backward LSTM. The sum of the outputs of the forward LSTM and the backward LSTM can be processed using the sigmoid activation function to obtain the message domain sequence features.
[0056] Optionally, the multi-head latent attention mechanism module can be an MLA mechanism module. The MLA mechanism module processes message domain sequence features through low-rank joint compression of attention keys and values, thereby reducing key-value caching during inference. The MLA mechanism module can use multiple heads to calculate the attention query (i.e., key) and KV cache (i.e., value). Each head has its own independent linear transformation parameters, thus learning different attention patterns. For example, some heads may focus more on the syntactic structure of the input transaction message domain, some may excel at capturing semantic information, and others may be more sensitive to the logical relationships between transaction message domains. In this way, the multi-head latent attention mechanism module in this embodiment understands the message domain sequence features from multiple perspectives. Furthermore, when calculating the attention score, it also mines the semantic, syntactic, and other latent information in the target transaction message domain information, integrating this latent information into the attention calculation. This allows the test case generation model to better understand the deeper meaning of the input message domain, thereby obtaining a more comprehensive message domain attention fusion feature that reflects the target transaction message domain information. For example, the attention formula for a single layer in the MLA mechanism module can be as follows:
[0057]
[0058] Among them, O t,i Let q represent the output vector of the i-th attention group at time step t, where j represents the index of the sequence's historical position, and q represents the output vector of the ith attention group. t,i Let k represent the query vector for the i-th group at time step t. j,i V represents the key vector of the i-th group at historical position j. c j,i Let d represent the value vector of the i-th group at historical position j. h d represents the feature dimension of each subhead. R Y W represents the feature dimension of each sub-head of the query decoupled by rotational position encoding. 0 Let represent the feature projection matrix of the prediction result, and ut represent the final output vector at time step t. Multi-head computation can be performed in parallel on multiple graphics processors to significantly improve computational efficiency.
[0059] Optionally, the output layer may include a fully connected layer and a softmax layer. The fully connected layer maps the message domain attention fusion features onto a logits vector, where each value represents a possible tendency value for a word. The softmax layer converts these scores into probability values (all probability values are positive, and the sum of all probability values is 1). The word in the dimension corresponding to the highest probability value is the output word for this step. All words output by the output layer are then combined to obtain the test case.
[0060] In summary, by utilizing a test case generation model that includes a text convolutional neural network module, a long short-term memory neural network module, a multi-head latent attention mechanism module, and an output layer, test cases were generated, ensuring their accuracy. This enabled test case generation without the need for replaying real transaction messages, reducing the intrusive impact of test case generation on the financial trading system.
[0061] To reduce the invasive impact of generated test cases on financial trading systems, the training steps of the test case generation model may optionally include: acquiring key-value pair data of multiple transaction messages, wherein each key-value pair data includes a key name and a key value, the key name includes a first subkey name and a first subkey value, and the key value includes a second subkey name and a second subkey value; concatenating the first subkey name and the second subkey name to obtain an input sample, and concatenating the first subkey value and the second subkey value to obtain a label corresponding to the input sample; and training a preset neural network model using the input sample and the label corresponding to the input sample to obtain the test case generation model.
[0062] For example, one could obtain 500,000 JSON-formatted messages and 1 million XML-formatted messages from a financial institution's annual financial transaction logs. These messages contain 35 million transaction message field samples. These messages can be used as key-value pairs for multiple transaction messages, with the transaction message field samples serving as keys and the corresponding values within the transaction messages as values. The first subkey is the key for the input data in the transaction message, and the second subkey is the key for the output data (the first and second subkeys together form the transaction message field sample, i.e., the input sample). The first subkey value is the key value for the input data in the transaction message, and the second subkey value is the key value for the output data.
[0063] In summary, by using the key values of multiple transaction messages to concatenate the data, input samples and their corresponding labels are obtained. After training the preset neural network model, a test case generation model is obtained, which reduces the intrusive impact of generating test cases on the financial trading system.
[0064] To reduce the intrusive impact of generated test cases on the financial trading system, optionally, a pre-defined neural network model can be trained using input samples and their corresponding labels to obtain a test case generation model. This includes: determining the pre-defined neural network model based on a text convolutional neural network module, a long short-term memory neural network module, and a multi-head latent attention mechanism module; determining the mean squared error loss function as the target loss function and determining the target optimization algorithm based on a gradient optimization algorithm; and training the pre-defined neural network model by minimizing the target loss function based on the input samples and their corresponding labels to obtain the test case generation model. The target optimization algorithm is used to update the parameters of the pre-defined neural network model during training.
[0065] For example, the text convolutional neural network module can be the aforementioned Text-CNN neural network module, the long short-term memory neural network module can be the aforementioned bidirectional LSTM neural network module, and the multi-head latent attention mechanism module can be the aforementioned MLA mechanism module. An output layer including fully connected layers and softmax layers can be added to the Text-CNN-bidirectional LSTM-MLA model to obtain the preset neural network model (all of the above modules are untrained network modules). The target loss function can be the mean squared error loss function, as detailed below:
[0066]
[0067] Where Loss represents the objective loss function, Mi represents the test case (i.e., the predicted value), and Yi represents the label (i.e., the true value) corresponding to the input sample. The objective optimization algorithm can be the Amad optimization algorithm, which updates the parameters in the model through gradient-based optimization.
[0068] In summary, by training a pre-defined neural network model based on input samples and their corresponding labels, and by minimizing the objective loss function, a test case generation model is obtained, which reduces the intrusive impact of generating test cases on the financial trading system.
[0069] To reduce the intrusive impact of generated test cases on the financial transaction system, optionally, the test cases are concatenated with the target transaction message field information to obtain the target test cases. This includes: determining the first message field sub-information and the second message field sub-information based on the target transaction message field information; dividing the test cases according to a preset delimiter to obtain the first test sub-case and the second test sub-case; concatenating the first message field sub-information with the first test sub-case to obtain the test input data; concatenating the second message field sub-information with the second test sub-case to obtain the expected test output data; and determining the target test cases based on the test input data and the expected test output data.
[0070] For example, the target transaction message field information could be "Contract Name - Return Information," and the test case could be "Company A - Contract Successful." The preset separator could be "-" or other punctuation marks (e.g., comma, semicolon). The first message field sub-information is "Contract Name," and the second message field sub-information is "Return Information." After splitting the test case according to the preset separator, the first test sub-case is "Company A," and the second test sub-case is "Contract Successful." Concatenating the first message field sub-information with the first test sub-case yields the test input data "Contract Name - Company A." Concatenating the second message field sub-information with the second test sub-case yields the expected test output data "Return Information - Contract Successful." The test input data is the sent message in the target test case, and the expected test output data is the response message in the target test case. When using the target test case for testing, the sent message can be input into the financial transaction system to be tested. When the data output by the financial transaction system to be tested matches the expected test output data, the test result is "Test Passed"; otherwise, the test result is "Test Failed."
[0071] In summary, by concatenating test cases with target transaction message field information, target test cases are obtained, providing test input data and expected test output data for testing, thus reducing the intrusive impact of generating test cases on the financial transaction system.
[0072] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0073] Example 2
[0074] This application also provides a test case generation apparatus. It should be noted that the test case generation apparatus of this application can be used to execute the test case generation method provided in this application. The test case generation apparatus provided in this application will be described below.
[0075] According to embodiments of this application, an apparatus for implementing the above-described test case generation method is also provided, such as... Figure 3 As shown, the device includes:
[0076] The information determination unit 301 is used to receive the target test requirements and determine the target transaction message field information based on the target test requirements.
[0077] The test case generation unit 302 is used to generate a target transaction message field vector based on the target transaction message field information, input the target transaction message field vector into the test case generation model, and output test cases using the test case generation model.
[0078] The test case acquisition unit 303 is used to concatenate the test case with the target transaction message field information to obtain the target test case.
[0079] The test case generation apparatus provided in this application embodiment receives target test requirements through an information determination unit 301 and determines target transaction message field information based on the target test requirements. A test case generation unit 302 generates a target transaction message field vector based on the target transaction message field information and inputs the target transaction message field vector into a test case generation model. The test case generation model outputs test cases, and a test case acquisition unit 303 concatenates the test cases with the target transaction message field information to obtain target test cases. This solves the problem in related technologies where test case generation can have an intrusive impact on financial trading systems. Therefore, it effectively reduces the intrusive impact of generated test cases on financial trading systems.
[0080] Optionally, in the test case generation device provided in this application embodiment, the test case generation unit 302 includes: a word segmentation module, used to determine multiple message domain words based on the target transaction message domain information; a mapping module, used to obtain the word vector corresponding to each message domain word using a word mapping function, thereby obtaining multiple word vectors; and a vector determination module, used to generate a target transaction message domain vector based on the multiple word vectors.
[0081] Optionally, in the test case generation apparatus provided in this application embodiment, the test case generation unit 302 includes: a convolution extraction module, used to extract features from the target transaction message domain vector based on the text convolutional neural network module in the test case generation model to obtain message domain spatial features; a sequence extraction module, used to input the message domain spatial features into the long short-term memory neural network module in the test case generation model, and use the long short-term memory neural network module to output message domain sequence features; an attention module, used to input the message domain sequence features into the multi-head latent attention mechanism module in the test case generation model, and use the multi-head latent attention mechanism module to output message domain attention fusion features; and an output module, used to input the message domain attention fusion features into the output layer in the test case generation model, and use the output layer to output test cases.
[0082] Optionally, in the test case generation apparatus provided in the embodiments of this application, the apparatus further includes: a key-value pair acquisition unit, used to acquire key-value pair data of multiple transaction messages, wherein each key-value pair data includes a key name and a key value, the key name includes a first subkey name and a first subkey value, and the key value includes a second subkey name and a second subkey value; a key-value pair processing unit, used to concatenate the first subkey name and the second subkey name to obtain an input sample, and concatenate the first subkey value and the second subkey value to obtain a label corresponding to the input sample; and a model training unit, used to train a preset neural network model using the input sample and the label corresponding to the input sample to obtain a test case generation model.
[0083] Optionally, in the test case generation apparatus provided in this application embodiment, the model training unit includes: a model determination module, used to determine a preset neural network model based on a text convolutional neural network module, a long short-term memory neural network module, and a multi-head latent attention mechanism module; a loss function determination module, used to determine the mean squared error loss function as the target loss function and determine the target optimization algorithm based on the gradient optimization algorithm; and a preset training module, used to train the preset neural network model by minimizing the target loss function based on the input samples and the labels corresponding to the input samples to obtain a test case generation model, wherein the target optimization algorithm is used to update the parameters of the preset neural network model during the training process.
[0084] Optionally, in the test case generation apparatus provided in this application embodiment, the test case acquisition unit 303 includes: a sub-information determination module, used to determine first message field sub-information and second message field sub-information based on target transaction message field information; a sub-case determination module, used to divide the test case according to a preset separator to obtain a first test sub-case and a second test sub-case; a first splicing module, used to splice the first message field sub-information with the first test sub-case to obtain test input data; a second splicing module, used to splice the second message field sub-information with the second test sub-case to obtain expected test output data; and a test case determination module, used to determine target test cases based on test input data and expected test output data.
[0085] It should be noted that the information determination unit 301, case generation unit 302, and use case acquisition unit 303 mentioned above correspond to steps S201 to S203 in Embodiment 1. The instances and application scenarios implemented by the units and corresponding steps are the same, but are not limited to the content disclosed in Embodiment 1. It should be noted that the above modules or units can be hardware or software components stored in memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b, ..., 102n). The above modules can also be part of a device and can run in the computer terminal 10 provided in Embodiment 1.
[0086] Example 3
[0087] Embodiments of this application may provide an electronic device. Figure 4 This is a structural block diagram of an electronic device according to an embodiment of this application. Figure 4 As shown, the electronic device may include: one or more ( Figure 4 (Only one is shown) processor 1002, memory 1004, memory controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.
[0088] The memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the methods and apparatus in the embodiments of this application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, thereby implementing the above-described methods. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory remotely located relative to the processor, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0089] The processor can access the information and application programs stored in the memory via the transmission device to perform the following steps: receive the target test requirements and determine the target transaction message field information based on the target test requirements; generate a target transaction message field vector based on the target transaction message field information and input the target transaction message field vector into the test case generation model, and output test cases using the test case generation model; and concatenate the test cases with the target transaction message field information to obtain the target test cases.
[0090] The processor can also call the information and application program stored in the memory through the transmission device to perform the following steps: determine multiple message field words based on the target transaction message field information; obtain the word vector corresponding to each message field word using the word mapping function to obtain multiple word vectors; and generate the target transaction message field vector based on the multiple word vectors.
[0091] The processor can also access information and applications stored in the memory via a transmission device to perform the following steps: extracting features from the target transaction message domain vector using the text convolutional neural network module in the test case generation model to obtain message domain spatial features; inputting the message domain spatial features into the long short-term memory neural network module in the test case generation model, and using the long short-term memory neural network module to output message domain sequence features; inputting the message domain sequence features into the multi-head latent attention mechanism module in the test case generation model, and using the multi-head latent attention mechanism module to output message domain attention fusion features; inputting the message domain attention fusion features into the output layer in the test case generation model, and using the output layer to output the test case.
[0092] The processor can also invoke information and applications stored in the memory via the transmission device to perform the following steps: acquiring key-value pair data of multiple transaction messages, wherein each key-value pair data includes a key name and a key value, the key name includes a first subkey name and a first subkey value, and the key value includes a second subkey name and a second subkey value; concatenating the first subkey name and the second subkey name to obtain an input sample, and concatenating the first subkey value and the second subkey value to obtain a label corresponding to the input sample; training a preset neural network model using the input sample and the label corresponding to the input sample to obtain a test case generation model.
[0093] The processor can also access information and applications stored in the memory via a transmission device to perform the following steps: determining a preset neural network model based on the text convolutional neural network module, long short-term memory neural network module, and multi-head latent attention mechanism module; determining the mean squared error loss function as the target loss function and determining the target optimization algorithm based on the gradient optimization algorithm; training the preset neural network model by minimizing the target loss function based on the input samples and their corresponding labels to obtain a test case generation model, wherein the target optimization algorithm is used to update the parameters of the preset neural network model during training.
[0094] The processor can also call the information and application program stored in the memory through the transmission device to perform the following steps: determine the first message field sub-information and the second message field sub-information based on the target transaction message field information; divide the test case according to the preset delimiter to obtain the first test sub-case and the second test sub-case; concatenate the first message field sub-information with the first test sub-case to obtain the test input data; concatenate the second message field sub-information with the second test sub-case to obtain the expected test output data; and determine the target test case based on the test input data and the expected test output data.
[0095] This application provides a scheme for generating test cases. It involves receiving target test requirements and determining target transaction message field information based on those requirements; generating a target transaction message field vector based on the target transaction message field information; inputting the target transaction message field vector into a test case generation model; and using the test case generation model to output test cases. Finally, the test cases are concatenated with the target transaction message field information to obtain target test cases. This solves the technical problem in the prior art where test case generation can have an intrusive impact on financial transaction systems.
[0096] Those skilled in the art will understand that Figure 4 The structure shown is for illustrative purposes only. Electronic devices can also be smartphones, tablets, handheld computers, mobile internet devices (MIDs), PADs, and other terminal devices. Figure 4 This does not limit the structure of the aforementioned electronic device. For example, electronic devices may also include components that are more... Figure 4 The more or fewer components shown (such as network interfaces, display devices, etc.), or having the same Figure 4 The different configurations shown.
[0097] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0098] Example 4
[0099] Embodiments of this application also provide a storage medium. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the test case generation method provided in Embodiment 1.
[0100] Optionally, in this embodiment, the storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.
[0101] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for performing the following steps: receiving target test requirements and determining target transaction message field information based on the target test requirements; generating a target transaction message field vector based on the target transaction message field information and inputting the target transaction message field vector into a test case generation model, and outputting test cases using the test case generation model; concatenating the test cases with the target transaction message field information to obtain target test cases.
[0102] Optionally, in this embodiment, the computer-readable storage medium is further configured to store program code for performing the following steps: determining multiple message field words based on the target transaction message field information; obtaining the word vector corresponding to each message field word using a word mapping function to obtain multiple word vectors; and generating a target transaction message field vector based on the multiple word vectors.
[0103] Optionally, in this embodiment, the computer-readable storage medium is further configured to store program code for performing the following steps: extracting features from the target transaction message domain vector based on the text convolutional neural network module in the test case generation model to obtain message domain spatial features; inputting the message domain spatial features into the long short-term memory neural network module in the test case generation model, and using the long short-term memory neural network module to output message domain sequence features; inputting the message domain sequence features into the multi-head latent attention mechanism module in the test case generation model, and using the multi-head latent attention mechanism module to output message domain attention fusion features; inputting the message domain attention fusion features into the output layer in the test case generation model, and using the output layer to output test cases.
[0104] Optionally, in this embodiment, the computer-readable storage medium is further configured to store program code for performing the following steps: acquiring key-value pair data of multiple transaction messages, wherein each key-value pair data includes a key name and a key value, the key name includes a first subkey name and a first subkey value, and the key value includes a second subkey name and a second subkey value; concatenating the first subkey name and the second subkey name to obtain an input sample, and concatenating the first subkey value and the second subkey value to obtain a label corresponding to the input sample; training a preset neural network model using the input sample and the label corresponding to the input sample to obtain a test case generation model.
[0105] Optionally, in this embodiment, the computer-readable storage medium is further configured to store program code for performing the following steps: determining a preset neural network model based on a text convolutional neural network module, a long short-term memory neural network module, and a multi-head latent attention mechanism module; determining the mean squared error loss function as the target loss function and determining the target optimization algorithm based on a gradient optimization algorithm; training the preset neural network model by minimizing the target loss function based on the input sample and the label corresponding to the input sample to obtain a test case generation model, wherein the target optimization algorithm is used to update the parameters of the preset neural network model during the training process.
[0106] Optionally, in this embodiment, the computer-readable storage medium is further configured to store program code for performing the following steps: determining first message field sub-information and second message field sub-information based on target transaction message field information; dividing test cases according to a preset delimiter to obtain first test sub-cases and second test sub-cases; concatenating the first message field sub-information with the first test sub-case to obtain test input data; concatenating the second message field sub-information with the second test sub-case to obtain expected test output data; and determining target test cases based on the test input data and the expected test output data.
[0107] This application also provides a computer program product, which, when executed on a data processing device, is adapted to perform the steps of a test case generation method.
[0108] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0109] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0110] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0111] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0112] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0113] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0114] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for generating test cases, characterized in that, include: Receive the target test request and determine the target transaction message field information based on the target test request; A target transaction message field vector is generated based on the target transaction message field information, and the target transaction message field vector is input into the test case generation model. The test case generation model is then used to output test cases. The test case is concatenated with the target transaction message field information to obtain the target test case.
2. The method according to claim 1, characterized in that, Generating a target transaction message field vector based on the target transaction message field information includes: Multiple message field terms are determined based on the target transaction message field information; The word vectors corresponding to each of the message domain words are obtained using a word mapping function, resulting in multiple word vectors. The target transaction message field vector is generated based on the multiple word vectors.
3. The method according to claim 1, characterized in that, The target transaction message field vector is input into the test case generation model, and the test cases are output using the test case generation model, including: Based on the text convolutional neural network module in the test case generation model, feature extraction is performed on the target transaction message domain vector to obtain message domain spatial features; The message domain spatial features are input into the long short-term memory neural network module in the test case generation model, and the message domain sequence features are output using the long short-term memory neural network module. The message domain sequence features are input into the multi-head latent attention mechanism module in the test case generation model, and the message domain attention fusion features are output using the multi-head latent attention mechanism module. The message domain attention fusion feature is input into the output layer of the test case generation model, and the test case is output using the output layer.
4. The method according to claim 1, characterized in that, The training steps for the test case generation model include: Obtain key-value pair data of multiple transaction messages, wherein each key-value pair data includes a key name and a key value, the key name includes a first subkey name and a first subkey value, and the key value includes a second subkey name and a second subkey value; The first subkey name and the second subkey name are concatenated to obtain the input sample, and the first subkey value and the second subkey value are concatenated to obtain the label corresponding to the input sample; The preset neural network model is trained using the input samples and their corresponding labels to obtain the test case generation model.
5. The method according to claim 4, characterized in that, The test case generation model is obtained by training a preset neural network model using the input samples and their corresponding labels, including: The preset neural network model is determined based on the text convolutional neural network module, the long short-term memory neural network module, and the multi-head latent attention mechanism module; The mean squared error loss function is determined as the target loss function, and the target optimization algorithm is determined based on the gradient optimization algorithm; Based on the input sample and the label corresponding to the input sample, the preset neural network model is trained by minimizing the target loss function to obtain the test case generation model, wherein the target optimization algorithm is used to update the parameters of the preset neural network model during the training process.
6. The method according to claim 1, characterized in that, By concatenating the test cases with the target transaction message field information, the target test cases are obtained, including: The first message field sub-information and the second message field sub-information are determined based on the target transaction message field information; The test cases are divided according to a preset separator to obtain a first test sub-case and a second test sub-case; The first message field sub-information is concatenated with the first test sub-case to obtain the test input data; The second message field sub-information is concatenated with the second test sub-case to obtain the expected test output data; The target test cases are determined based on the test input data and the expected test output data.
7. A test case generation device, characterized in that, include: An information determination unit is used to receive target test requirements and determine target transaction message field information based on the target test requirements; The test case generation unit is used to generate a target transaction message field vector based on the target transaction message field information, input the target transaction message field vector into the test case generation model, and output test cases using the test case generation model. The test case acquisition unit is used to concatenate the test case with the target transaction message field information to obtain the target test case.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored executable program, wherein, when the executable program is executed, it controls the device on which the computer-readable storage medium is located to perform the test case generation method according to any one of claims 1 to 6.
9. An electronic device, characterized in that, include: Memory, which stores executable programs; A processor for running the program, wherein the program, when running, executes the test case generation method according to any one of claims 1 to 6.
10. A computer program product comprising computer instructions, characterized in that, When the computer instructions are executed by the processor, they implement the steps of the test case generation method according to any one of claims 1 to 6.