Test case generation method and device, electronic equipment and storage medium
By integrating semantic and image information to generate test cases, the problems of low efficiency, insufficient coverage, and high maintenance costs in writing test cases for vehicle software are solved, achieving efficient and comprehensive test case generation.
Patent Information
- Application Number
- CN202511600949.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-04
- Publication Date
- 2026-02-27
AI Technical Summary
Vehicle software test case generation is inefficient, has insufficient coverage, and is costly to maintain, issues that are difficult to effectively address with existing technologies.
By acquiring requirements documents and system design diagrams, semantic and image information are fused using language processing and image processing models, knowledge base is retrieved, and an initial test case set is generated. The target test case set is then optimized using a genetic algorithm.
It improved the efficiency of test case generation, expanded the scenario coverage, and reduced maintenance costs.
Smart Images

Figure CN121579339A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of vehicles, in particular to a test case generation method and device, electronic equipment and a storage medium. BACKGROUND
[0002] As a key link to ensure quality, software testing faces challenges such as diverse test scenarios, complex interaction logic, and stringent safety requirements. The rapid development of intelligent vehicles has put forward higher requirements for the completeness, accuracy, and generation efficiency of test cases.
[0003] The related art has the following test case generation schemes: (1) an automated tool based on a template (such as an Excel macro script) that generates test cases in batches through a preset format; (2) a static code analysis tool that extracts program control flow and generates basic path coverage test cases; and (3) an artificial intelligence (AI) scheme that uses a natural language processing (NLP) model to analyze requirement documents to automatically generate test logic.
[0004] However, the related art has the following defects: (1) low efficiency: the related art usually needs to analyze requirement documents one by one, manually design input parameters and expected results, and has low output efficiency; (2) incomplete scenario coverage: complex interaction scenarios (such as multi-ECU collaboration and sensor failure in extreme environments) are difficult to exhaust manually, resulting in missing key test items; (3) high version iteration cost: after software updates, test cases need to be re-matched, and manual maintenance is time-consuming and prone to errors; and (4) waste of historical data: existing test cases and fault records are not structured for reuse, and cannot form knowledge accumulation. SUMMARY
[0005] The present application provides a test case generation method, device, electronic equipment and storage medium to solve the problems of low efficiency, insufficient coverage and high maintenance cost of vehicle software test case writing. The present application can provide test case generation efficiency, expand scenario coverage and reduce maintenance cost.
[0006] The first aspect of the present application provides a test case generation method, comprising the following steps: obtaining a requirement document and a system design diagram; processing the requirement document using a preset language processing model to obtain semantic information, and processing the system design diagram using a preset image processing model to obtain image information, and fusing the semantic information and the image information to obtain target fusion information; retrieving a preset knowledge base according to the target fusion information to obtain a retrieval result, and inputting the target fusion information and the retrieval result into a preset test case generation model to obtain an initial test case set, and optimizing the initial test case using a preset genetic algorithm to obtain a target test case set.
[0007] Optionally, in some embodiments, the fusing the semantic information and the image information obtains target fusion information, including: aligning the semantic information and the image information based on a preset term mapping rule and a preset semantic similarity model, to obtain a mapping relationship between text entities and image elements, fusing the semantic information and the image information based on the corresponding relationship between the text entities and the image elements to obtain the target fusion information.
[0008] Optionally, in some embodiments, after aligning the semantic information and the image information based on a preset term mapping rule and a preset semantic similarity model, the mapping relationship between text entities and image elements is obtained, including: determining whether there is a mapping conflict in the mapping relationship; if there is a mapping conflict in the mapping relationship, generating an abnormality reminding instruction, and performing abnormality reminding based on the abnormality reminding instruction.
[0009] Optionally, in some embodiments, before inputting the target fusion information and the search result into the preset test case generation model, further comprising: obtaining a historical test case data set, and constructing a data set based on the historical test case data set; dividing the data set into a training set, a validation set and a test set based on a preset division ratio; constructing a target neural network, inputting the training set into the target neural network for training to obtain initial model parameters; based on the initial model parameters, inputting the validation set into the target neural network for performance evaluation, and adjusting the initial model parameters according to the performance evaluation result until the joint loss function of the validation set converges, to obtain optimal model parameters; based on the optimal model parameters, inputting the test set into the target neural network for model testing, and obtaining the preset test case generation model when the test result meets the preset requirements.
[0010] The second aspect embodiment of the present application provides a test case generation device, comprising: an acquisition module configured to acquire a requirement document and a system design diagram; a fusion module configured to process the requirement document using a preset language processing model to obtain semantic information, process the system design diagram using a preset image processing model to obtain image information, and fuse the semantic information and the image information to obtain target fusion information; The generating module is configured to retrieve a preset knowledge base according to the target fusion information to obtain a retrieval result, input the target fusion information and the retrieval result into a preset test case generation model to obtain an initial test case set, and optimize the initial test case set by using a preset genetic algorithm to obtain a target test case set.
[0011] Optionally, in some embodiments, the fusion module is configured to: align the semantic information and the image information based on a preset term mapping rule and a preset semantic similarity model to obtain a mapping relationship between text entities and image elements, fuse the semantic information and the image information based on the corresponding relationship between the text entities and the image elements to obtain the target fusion information.
[0012] Optionally, in some embodiments, the fusion module is further configured to: determine whether there is a mapping conflict in the mapping relationship; if there is a mapping conflict in the mapping relationship, generate an abnormality reminding instruction and perform abnormality reminding based on the abnormality reminding instruction.
[0013] Optionally, in some embodiments, before the target fusion information and the retrieval result are input into the preset test case generation model, the generating module is further configured to: obtain a historical test case data set and construct a data set based on the historical test case data set; divide the data set into a training set, a validation set and a test set based on a preset division ratio; construct a target neural network, input the training set into the target neural network to obtain initial model parameters by training; input the validation set into the target neural network based on the initial model parameters to perform performance evaluation, and adjust the initial model parameters according to the performance evaluation result until a joint loss function of the validation set converges to obtain optimal model parameters; input the test set into the target neural network based on the optimal model parameters to perform model testing, and obtain the preset test case generation model when a test result meets a preset requirement.
[0014] The third aspect of the embodiments of the present application provides an electronic device, which comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor executes the program to implement the test case generation method as described in the above embodiments.
[0015] The fourth aspect of the present application provides a computer readable storage medium, which stores a computer program. The program is executed by a processor to implement the test case generation method according to the above-mentioned embodiments.
[0016] Therefore, by obtaining the requirement document and the system design diagram, processing the requirement document by using the preset language processing model to obtain semantic information, processing the system design diagram by using the preset image processing model to obtain image information, fusing the semantic information and the image information to obtain target fusion information, searching the preset knowledge base according to the target fusion information to obtain a search result, inputting the target fusion information and the search result into the preset test case generation model to obtain an initial test case set, and optimizing the initial test case by using the preset genetic algorithm to obtain a target test case set, the problem of low efficiency, insufficient coverage and high maintenance cost of vehicle software test case writing is solved, the test case generation efficiency is provided, the scene coverage is expanded, and the maintenance cost is reduced.
[0017] Additional aspects and advantages of the present application will be in part apparent and in part pointed out hereinafter. BRIEF DESCRIPTION OF DRAWINGS
[0018] The above and / or additional aspects and advantages of the present application will become apparent and be readily appreciated from the following description, including the accompanying drawings, wherein: Figure 1 A flowchart of a test case generation method according to an embodiment of the present application is provided. Figure 2 A principle schematic diagram of a test case generation method according to an embodiment of the present application is provided. Figure 3 A text and image requirement analysis and alignment flowchart according to an embodiment of the present application is provided. Figure 4 A training flowchart of a preset test case generation model according to an embodiment of the present application is provided. Figure 5 A block schematic diagram of a test case generation apparatus according to an embodiment of the present application is provided. Figure 6 A structural schematic diagram of an electronic device according to an embodiment of the present application is provided. DETAILED DESCRIPTION
[0019] Embodiments of the present application are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference signs represent the same or similar elements or elements having the same or similar functions throughout. The embodiments described below are exemplary and are intended to explain the present application, and cannot be understood as a limitation of the present application.
[0020] A test case generation method, device, electronic equipment and storage medium are described below with reference to the accompanying drawings. In view of the low efficiency, insufficient coverage and high maintenance cost of vehicle software test case writing mentioned in the background art, the present application provides a test case generation method. In the method, the requirement document and system design diagram are obtained, and the semantic information is obtained by processing the requirement document using a preset language processing model, and the image information is obtained by processing the system design diagram using a preset image processing model, the target fusion information is obtained by fusing the semantic information and the image information, the retrieval result is obtained by retrieving the preset knowledge base according to the target fusion information, and the target fusion information and the retrieval result are input into the preset test case generation model to obtain the initial test case set, and the target test case set is obtained by optimizing the initial test case using a preset genetic algorithm. Thus, the problems of low efficiency, insufficient coverage and high maintenance cost of vehicle software test case writing are solved, and the test case generation efficiency, the scene coverage and the maintenance cost are reduced.
[0021] Specifically, Figure 1 A flowchart of a test case generation method provided by an embodiment of the present application.
[0022] As Figure 1 shown, the test case generation method includes the following steps: In step S101, the requirement document and the system design diagram are obtained.
[0023] The requirement document refers to a text file written in natural language describing the function logic and technical requirements of the vehicle-mounted software; and the system design diagram can be a graphical design file of the physical architecture and communication relationship of the vehicle-mounted electronic system.
[0024] Specifically, as shown in Figure 2 , the present application receives the requirement document and the system design diagram corresponding to the vehicle-mounted software to be tested through an input interface as the basic data source for subsequent multi-modal analysis. The requirement document is used to extract functional semantic information, such as "ESP needs to be activated when the vehicle speed exceeds 120 km / h"; and the system design diagram is used to analyze the hardware topology and signal interface relationship, such as "CAN communication link between camera ECU and ADAS controller". The two types of data enter the text processing channel and the image processing channel respectively, providing original input for subsequent semantic analysis and cross-modal alignment.
[0025] Thus, the present application simultaneously obtains the requirement document and the system design diagram, realizes dual data acquisition of the function logic and the physical architecture of the vehicle-mounted software, provides complete input basis for subsequent fusion analysis, avoids information loss caused by relying on only a single text or drawing, ensures that the function requirements and system structure can be considered during the test case generation process, and improves the completeness and consistency of the input data.
[0026] In step S102, the requirement document is processed by using a preset language processing model to obtain semantic information, and the system design diagram is processed by using a preset image processing model to obtain image information, and the target fusion information is obtained by fusing the semantic information and the image information.
[0027] Specifically, as shown in the figure, the embodiment of the application first processes the requirement document by using a preset language processing model to extract key information such as function description, input and output parameters, and various constraint conditions. At the same time, the system design diagram is analyzed by using a preset image processing model to identify various components and their connection relationship with each other. Then, through a specific fusion algorithm, the above two parts of information are integrated to form the target fusion information. This fusion not only includes one-to-one correspondence between text description and graphical identification, but also involves logical association matching to ensure that the final information set accurately reflects the core content of the original data. Figure 3
[0028] In actual execution process, the embodiment of the application can use a pre-trained bidirectional long short-term memory network (Bi-LSTM) and conditional random field (CRF) model to extract key entities from the requirement document, including: ECU modules (such as power control unit, sensor node); signal parameters (such as vehicle speed threshold, voltage range); constraint conditions (such as response time, fault tolerance mechanism) For example, for the requirement description “when the vehicle speed exceeds 120 km / h, the electronic stability program (ESP) needs to be activated within 200 ms”, the system will extract “vehicle speed > 120 km / h” as the trigger condition, “ESP activation” as the action, and “response time ≤ 200 ms” as the constraint.
[0029] The embodiment of the application can also extract text labels in the design diagram through optical character recognition (OCR) and analyze the topological structure by using graph neural network (GNN).
[0030] For example: when analyzing the CAN bus topology diagram, the communication relationship between ECU nodes is automatically identified, and interface test cases are generated (such as verifying the transmission delay of a specific signal on the bus).
[0031] Therefore, by combining data sources in both text and image forms, the limitations that may exist in a single mode can be overcome, which helps to reduce the possibility of human error, for example, reducing the mistakes that may occur in the manual transcription and interpretation process.
[0032] Optionally, in some embodiments, the fusing of the semantic information and the image information obtains target fusion information, including: aligning the semantic information and the image information based on a preset term mapping rule and a preset semantic similarity model, to obtain a mapping relationship between the text entities and the image elements, and fusing the semantic information and the image information to obtain the target fusion information according to the corresponding relationship between the text entities and the image elements.
[0033] Further, in some embodiments, after aligning the semantic information and the image information based on the preset term mapping rule and the preset semantic similarity model, the mapping relationship between the text entities and the image elements is obtained, including: judging whether there is a mapping conflict in the mapping relationship; if there is a mapping conflict in the mapping relationship, an abnormality reminding instruction is generated, and abnormality reminding is performed based on the abnormality reminding instruction.
[0034] The preset term mapping rule can be a pre-configured vehicle-mounted field special term correspondence table, which is used to establish the relationship between the function description in the requirement document and the graphic identification in the system design diagram, and the preset semantic similarity model can be a calculation model constructed based on a lightweight text embedding algorithm (such as Sentence-BERT), which is used to measure the similarity degree of the text entities and the image labels in the semantic space, and assist in realizing fuzzy matching.
[0035] Specifically, first, the text entities such as function modules and signal parameters extracted from the requirement document and the image elements such as ECU nodes and signal interfaces identified in the design diagram are preliminarily matched based on the preset term mapping rule; for entities that are not directly hit in the rule library, the preset semantic similarity model is called to calculate the vector similarity, so as to judge whether an effective corresponding relationship is constituted, so as to obtain the mapping relationship between the text entities and the image elements. Subsequently, according to the mapping relationship, the function logic and the physical topology are bound to generate target fusion information containing trigger conditions, system actions and communication paths. Further, after alignment, the system automatically judges whether there is a conflict in the mapping relationship, such as “the text description exists radar module but the image has no corresponding node” or “VCU and PCU naming is inconsistent” and the like, if such a conflict is detected, an abnormality reminding instruction is generated, and a prompt is issued through a visual interface or a log.
[0036] In actual execution process, the embodiment of the application can perform cross-modal alignment to obtain the mapping relationship of multiple text entities and image elements, for example, the “ESP control module” mentioned in the text is associated with the “ESP_Node” identification in the design diagram, to ensure the consistency of requirement analysis.
[0037] If a conflict is detected (such as the ECU name in the image does not match the text description), the system will mark the abnormality and trigger the manual review process.
[0038] Therefore, by introducing terminology mapping rules and semantic similarity models for cross-modal alignment, accurate entity correspondences can be established between text and images, improving the automation of the fusion process. Simultaneously, conflict detection and anomaly alerts generated through the aligned mapping relationships can promptly identify inconsistencies between requirements documents and system design diagrams regarding module completeness, naming consistency, or connectivity, avoiding test omissions or misjudgments due to inconsistencies between text and images. This mechanism helps ensure the accuracy and consistency of input data, providing a reliable data foundation for subsequent test case generation.
[0039] In step S103, the target fusion information is retrieved from a preset knowledge base to obtain the retrieval results. The target fusion information and the retrieval results are then input into a preset test case generation model to obtain an initial test case set. Finally, a preset genetic algorithm is used to optimize the initial test cases to obtain the target test case set.
[0040] The preset knowledge base is a pre-built and stored structured database containing historical test cases, common fault modes (such as FMEA records), and vehicle communication protocol standards (such as DBC files and AUTSAR specifications) to support the reuse and retrieval of test knowledge. The preset test case generation model refers to a model built based on intelligent algorithms such as reinforcement learning, which can generate test cases with functional coverage based on the input context information (such as requirement logic and system structure).
[0041] Specifically, the system uses target fusion information as query conditions to retrieve data related to the currently tested function from a pre-set knowledge base. This data includes historical test cases for similar scenarios, known fault modes, and corresponding signal parameter configurations, forming search results. Subsequently, the target fusion information and search results are input into a pre-set test case generation model. This model combines functional logic, physical topology, and historical experience to generate an initial test case set covering various input combinations. Next, a pre-set genetic algorithm optimizes this initial set. Through fitness evaluation (e.g., the trade-off between the number of covered requirements and execution cost), crossover and mutation operations, redundant or inefficient test cases are eliminated, ultimately outputting an optimized target test case set.
[0042] Therefore, by retrieving knowledge bases based on target-fused information, existing testing experience and fault data can be reused, improving the relevance of test case generation. Inputting both target-fused information and retrieval results into the generation model helps incorporate historically effective parameter combinations in the initial stage, improving the relevance of test cases. Optimizing the initial test case set using a genetic algorithm can reduce the number of test cases while ensuring functional coverage, thus lowering test execution overhead. This process automates the test case generation and optimization process, improving the quality and execution efficiency of the test case set.
[0043] It should be noted that, in conjunction with Figure 4, the preset test case generation model architecture in this application embodiment includes: a state space (S): including currently covered requirements, code branches, and historical failure modes; an action space (A): selecting test parameter combinations (such as input value range, timing conditions, and environment variables); and a reward function (R): calculated as follows: R = 0.6 × requirement coverage + 0.3 × failure detection rate + 0.1 × execution efficiency.
[0044] The preset test case generation model in this application embodiment can interact with the environment simulator to gradually optimize the strategy to maximize the cumulative reward.
[0045] The model architecture of the genetic algorithm in this application embodiment may include: chromosome encoding, which encodes the test steps into a binary sequence, with each bit representing a parameter selection; fitness evaluation, which calculates the fitness value based on test case coverage and execution cost; and evolutionary operation, which generates a new population through crossover and mutation, and iteratively approximates the Pareto optimal solution set.
[0046] In this embodiment, the pre-defined knowledge base can be stored in a hierarchical manner, including: a historical test case library: stored according to functional modules and test types; a fault mode library: based on FMEA analysis, recording failure scenarios and solutions; a protocol standard library: integrating specifications such as Autosar templates and DBC signal definitions; and data augmentation technology: using generative adversarial networks (GANs) to simulate edge scenarios (such as sensor noise under extreme temperatures) to expand the coverage of test cases.
[0047] Optionally, in some embodiments, before inputting the target fusion information and retrieval results into the preset test case generation model, the method further includes: obtaining a historical test case dataset and constructing a dataset based on the historical test case dataset; dividing the dataset into a training set, a validation set, and a test set based on a preset partitioning ratio; constructing a target neural network, inputting the training set into the target neural network for training to obtain initial model parameters; based on the initial model parameters, inputting the validation set into the target neural network for performance evaluation, and adjusting the initial model parameters according to the performance evaluation results until the joint loss function of the validation set converges to obtain the optimal model parameters; based on the optimal model parameters, inputting the test set into the target neural network for model testing, and obtaining the preset test case generation model when the test results meet the preset requirements.
[0048] Among them, the historical test case dataset refers to the collection of completed test cases collected from historical in-vehicle software testing projects, containing structured information such as input conditions, expected results, related requirements, and execution results, used for model training and validation; the training set, validation set, and test set are three parts of the dataset divided according to a preset ratio, used for model parameter learning, hyperparameter tuning, and performance evaluation, respectively; the target neural network refers to the deep learning network architecture used to implement the test case generation task; and the joint loss function is a comprehensive indicator used during model training to measure the difference between the predicted output and the true label. Specifically, before inputting the target fusion information and retrieval results into the test case generation model, the model needs to be built and trained in advance. First, obtain the historical test case dataset, clean and structure it to build a training dataset with a unified format; then, divide the dataset into training, validation, and test sets according to a preset ratio; next, build the target neural network model, input the training set into the model for forward propagation and backward optimization to obtain the initial model parameters; then, use the validation set to evaluate the model performance, adjusting parameters such as the learning rate and weights according to the changes in the joint loss function until the loss function converges to obtain the optimal model parameters; finally, input the test set into the trained model for final testing. After the generated results meet the preset accuracy and completeness requirements, the model is confirmed as a pre-set test case generation model that can be put into use.
[0049] The test case generation method based on the embodiments of this application was tested, and the following test results were obtained: (1) Efficiency improvement: the test case writing time was shortened from 4 person-days to 0.7 person-days, and the efficiency was improved by 82%; (2) Coverage improvement: the requirement coverage increased from 68% to 95%, and the coverage of boundary conditions and fault scenarios increased by 40%; (3) Maintenance cost reduction: when the software version is iterated, the workload of test case adjustment is reduced by 76%.
[0050] This application uses an ADAS lane keeping system test as an example to illustrate the implementation process of the test case generation method in this application.
[0051] 1. Input data: (1) Requirements document: "Within the range of vehicle speed 60-150km / h, the system needs to maintain the lane center offset of no more than ±0.3 meters." (2) System design diagram: including the topology connection diagram of the camera and the steering control ECU.
[0052] 2. Generation process: (1) Requirements analysis: Extract vehicle speed range, offset threshold, and associated ECU (camera, steering control). (2) Knowledge base retrieval: Match similar scenarios in historical use cases (such as lane departure warning test) to obtain parameter combination patterns. (3) Use case generation: The reinforcement learning model generates 100 sets of candidate use cases, covering vehicle speed segments (60 / 90 / 120 / 150km / h), lighting conditions (day / night), and road surface conditions (dry / slippery). The genetic algorithm removes redundant use cases and retains 20 high-value use cases. (4) Output results: Each use case includes preset conditions, input parameters, expected results, and associated requirement clause numbers.
[0053] In summary, the embodiments of this application employ a multimodal requirement parsing engine, combining natural language processing, image recognition, and knowledge graph technologies to achieve accurate parsing and alignment of requirement documents and design drawings; a hybrid optimization generation algorithm is used, integrating reinforcement learning and genetic algorithms, to extract patterns from historical data and generate a high-coverage test case set; and a closed-loop feedback mechanism is adopted to dynamically adjust the generation strategy based on test execution results, thereby achieving continuous optimization of the test case library.
[0054] The test case generation method proposed in this application involves acquiring a requirements document and a system design diagram. The requirements document is processed using a preset language processing model to obtain semantic information, and the system design diagram is processed using a preset image processing model to obtain image information. The semantic and image information are then fused to obtain target fusion information. A preset knowledge base is retrieved based on the target fusion information to obtain retrieval results. The target fusion information and retrieval results are then input into a preset test case generation model to obtain an initial test case set. Finally, a preset genetic algorithm is used to optimize the initial test cases to obtain a target test case set. This method solves the problems of low efficiency, insufficient coverage, and high maintenance costs in writing test cases for vehicle software. This application can improve test case generation efficiency, expand scenario coverage, and reduce maintenance costs.
[0055] Next, the test case generation apparatus proposed according to the embodiments of this application is described with reference to the accompanying drawings.
[0056] Figure 5 This is a block diagram of a test case generation device according to an embodiment of this application.
[0057] like Figure 5 As shown, the test case generation device 10 includes: an acquisition module 100, a fusion module 200, and a generation module 300.
[0058] The acquisition module 100 is used to acquire requirements documents and system design diagrams.
[0059] The fusion module 200 is used to process the requirement document using a preset language processing model to obtain semantic information, and to process the system design drawing using a preset image processing model to obtain image information, and to fuse the semantic information and image information to obtain target fusion information.
[0060] The generation module 300 is used to retrieve the target fusion information from a preset knowledge base to obtain the retrieval results, and input the target fusion information and retrieval results into a preset test case generation model to obtain an initial test case set. The initial test cases are then optimized using a preset genetic algorithm to obtain the target test case set.
[0061] Optionally, in some embodiments, the fusion module 200 is used to: align semantic information and image information based on preset term mapping rules and preset semantic similarity models to obtain the mapping relationship between text entities and image elements, and fuse semantic information and image information to obtain target fusion information according to the correspondence between text entities and image elements.
[0062] Optionally, in some embodiments, the fusion module 200 is further configured to: determine whether there is a mapping conflict in the mapping relationship; if there is a mapping conflict in the mapping relationship, generate an abnormal reminder instruction and provide an abnormal reminder based on the abnormal reminder instruction.
[0063] Optionally, in some embodiments, before inputting the target fusion information and retrieval results into the preset test case generation model, the generation module 300 is further configured to: acquire a historical test case dataset and construct a dataset based on the historical test case dataset; divide the dataset into a training set, a validation set, and a test set based on a preset partitioning ratio; construct a target neural network, input the training set into the target neural network for training to obtain initial model parameters; based on the initial model parameters, input the validation set into the target neural network for performance evaluation, and adjust the initial model parameters according to the performance evaluation results until the joint loss function of the validation set converges to obtain the optimal model parameters; based on the optimal model parameters, input the test set into the target neural network for model testing, and when the test results meet the preset requirements, obtain the preset test case generation model.
[0064] It should be noted that the foregoing explanation of the test case generation method embodiment also applies to the test case generation device of this embodiment, and will not be repeated here.
[0065] The test case generation device proposed in this application obtains a requirements document and a system design diagram. It processes the requirements document using a preset language processing model to obtain semantic information and processes the system design diagram using a preset image processing model to obtain image information. The semantic and image information are then fused to obtain target fusion information. A preset knowledge base is retrieved based on the target fusion information to obtain retrieval results. The target fusion information and retrieval results are input into a preset test case generation model to obtain an initial test case set. A preset genetic algorithm is then used to optimize the initial test cases to obtain a target test case set. This solves the problems of low efficiency, insufficient coverage, and high maintenance costs in writing test cases for vehicle software. This application can improve test case generation efficiency, expand scenario coverage, and reduce maintenance costs.
[0066] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device may include: The memory 601, the processor 602, and the computer program stored on the memory 601 and capable of running on the processor 602.
[0067] When the processor 602 executes the program, it implements the test case generation method provided in the above embodiments.
[0068] Furthermore, electronic devices also include: Communication interface 603 is used for communication between memory 601 and processor 602.
[0069] The memory 601 is used to store computer programs that can run on the processor 602.
[0070] The memory 601 may include high-speed RAM (Random Access Memory) memory, and may also include non-volatile memory, such as at least one disk storage.
[0071] If the memory 601, processor 602, and communication interface 603 are implemented independently, then the communication interface 603, memory 601, and processor 602 can be interconnected via a bus to complete communication between them. The bus can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 6 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0072] Optionally, in a specific implementation, if the memory 601, processor 602, and communication interface 603 are integrated on a single chip, then the memory 601, processor 602, and communication interface 603 can communicate with each other through an internal interface.
[0073] The processor 602 may be a CPU (Central Processing Unit), an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of this application.
[0074] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the test case generation method described above.
[0075] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0076] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0077] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more N executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.
[0078] It should be understood that the various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, the N steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (FPGAs), field-programmable gate arrays (FPGAs), etc.
[0079] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.
[0080] Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of this application.
Claims
1. A test case generation method, characterized in that, Includes the following steps: Obtain requirements documents and system design diagrams; The requirement document is processed using a preset language processing model to obtain semantic information, and the system design diagram is processed using a preset image processing model to obtain image information. The semantic information and the image information are then fused to obtain target fusion information. The target fusion information is retrieved from a preset knowledge base to obtain retrieval results. The target fusion information and the retrieval results are then input into a preset test case generation model to obtain an initial test case set. A preset genetic algorithm is then used to optimize the initial test cases to obtain a target test case set.
2. The method according to claim 1, characterized in that, The process of fusing the semantic information and the image information to obtain target fusion information includes: Based on preset terminology mapping rules and preset semantic similarity models, the semantic information and the image information are aligned to obtain the mapping relationship between text entities and image elements. Based on the correspondence between the text entities and image elements, the semantic information and the image information are fused to obtain the target fusion information.
3. The method according to claim 2, characterized in that, The method, based on preset terminology mapping rules and a preset semantic similarity model, aligns the semantic information and the image information to obtain the mapping relationship between text entities and image elements, including: Determine whether there is a mapping conflict in the mapping relationship; If a mapping conflict exists in the mapping relationship, an exception alert instruction is generated, and an exception alert is issued based on the exception alert instruction.
4. The method according to claim 1, characterized in that, Before inputting the target fusion information and the retrieval results into the preset test case generation model, the method further includes: Obtain the historical test case dataset and construct a dataset based on the historical test case dataset; Based on a preset partitioning ratio, the dataset is divided into a training set, a validation set, and a test set. Construct a target neural network by inputting the training set into the target neural network for training to obtain initial model parameters; Based on the initial model parameters, the validation set is input into the target neural network for performance evaluation, and the initial model parameters are adjusted according to the performance evaluation results until the joint loss function of the validation set converges to obtain the optimal model parameters. Based on the optimal model parameters, the test set is input into the target neural network for model testing, and when the test results meet the preset requirements, the preset test case generation model is obtained.
5. A test case generation device, characterized in that, include: The acquisition module is used to acquire requirements documents and system design diagrams; The fusion module is used to process the requirement document using a preset language processing model to obtain semantic information, and to process the system design diagram using a preset image processing model to obtain image information, and to fuse the semantic information and the image information to obtain target fusion information; The generation module is used to retrieve the target fusion information from a preset knowledge base to obtain the retrieval results, input the target fusion information and the retrieval results into a preset test case generation model to obtain an initial test case set, and use a preset genetic algorithm to optimize the initial test cases to obtain a target test case set.
6. The apparatus according to claim 5, characterized in that, The fusion module is used for: Based on preset terminology mapping rules and preset semantic similarity models, the semantic information and the image information are aligned to obtain the mapping relationship between text entities and image elements. Based on the correspondence between the text entities and image elements, the semantic information and the image information are fused to obtain the target fusion information.
7. The apparatus according to claim 6, characterized in that, The fusion module is also used for: Determine whether there is a mapping conflict in the mapping relationship; If a mapping conflict exists in the mapping relationship, an exception alert instruction is generated, and an exception alert is issued based on the exception alert instruction.
8. The apparatus according to claim 5, characterized in that, Before inputting the target fusion information and the retrieval results into the preset test case generation model, the generation module is further configured to: Obtain the historical test case dataset and construct a dataset based on the historical test case dataset; Based on a preset partitioning ratio, the dataset is divided into a training set, a validation set, and a test set. Construct a target neural network by inputting the training set into the target neural network for training to obtain initial model parameters; Based on the initial model parameters, the validation set is input into the target neural network for performance evaluation, and the initial model parameters are adjusted according to the performance evaluation results until the joint loss function of the validation set converges to obtain the optimal model parameters. Based on the optimal model parameters, the test set is input into the target neural network for model testing, and when the test results meet the preset requirements, the preset test case generation model is obtained.
9. An electronic device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, the processor executing the program to implement the test case generation method as described in any one of claims 1-4.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, The program is executed by the processor to implement the test case generation method as described in any one of claims 1-4.