Test case generation method and device, computer device and storage medium

By performing deep semantic analysis on natural language requirements documents, generating test semantic graphs and automatically generating test case scripts, the problem of low efficiency in traditional test case generation is solved, and efficient and comprehensive automatic test case generation is achieved.

CN121979796APending Publication Date: 2026-05-05CHERY AUTOMOBILE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHERY AUTOMOBILE CO LTD
Filing Date
2026-01-29
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

Traditional test case generation methods are inefficient, have insufficient coverage, rely on manual operation, and have poor adaptability, making them unable to cope with complex business logic and system changes.

Method used

By acquiring natural language requirements documents, performing deep semantic analysis to generate test semantic graphs, and combining them with large language models to automatically generate test case scripts, we can achieve automated and comprehensive scenario coverage of test elements.

Benefits of technology

It achieves easy-to-use and user-friendly automatic generation of test cases, improves build efficiency and adaptability, and solves the problems of low efficiency and incomplete coverage in traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121979796A_ABST
    Figure CN121979796A_ABST
Patent Text Reader

Abstract

The invention relates to a test case generation method and device, a computer device and a storage medium. Relates to a whole vehicle electronic appliance test technology, and solves the problems of poor adaptability and low construction efficiency caused by the fact that a test case is constructed depending on manual operation. The method comprises the steps of obtaining a natural language requirement file; performing deep semantic analysis on the natural language demand file to obtain a test semantic graph, the test semantic graph comprising test elements carried by the natural language demand file and a logical relationship among the test elements; and generating a test case script according to the test semantic graph. The technical scheme provided by the invention is suitable for construction of the test case of the whole vehicle test, and automatic, efficient and comprehensive scene coverage test case generation is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to vehicle electronic and electrical (ECU) testing technology, and more particularly to a test case generation method, apparatus, computer device, and storage medium. Background Technology

[0002] As the complexity of vehicle software systems continues to increase, traditional methods of manually writing test cases are becoming increasingly inefficient, have low coverage, and are costly to maintain. Existing automated testing tools mostly generate test cases based on rules or templates, lacking a deep understanding of the semantics of requirements and struggling to handle complex business logic and constantly changing system behavior.

[0003] Test generation tools based on code analysis, such as Selenium IDE and JUnit, rely on pre-set scripts and cannot automatically generate test logic based on natural language requirements. On the other hand, model-driven test generation methods, such as UML models, heavily rely on manual modeling, which is cumbersome and has poor adaptability.

[0004] In summary, the construction of test cases mainly relies on manually preset rules, which has poor adaptability. Summary of the Invention

[0005] To overcome the problems existing in related technologies, this disclosure provides a test case generation method, apparatus, computer device, and storage medium. It obtains a test semantic graph through semantic analysis of natural language requirements documents, and automatically generates test case scripts based on the semantics. This solves the problems of poor adaptability and low efficiency caused by manual test case construction, achieving automatic, efficient, and comprehensive test case generation.

[0006] According to a first aspect of the present disclosure, a test case generation method is provided, comprising: Obtain the natural language requirements document; Perform deep semantic analysis on the natural language requirement document to obtain a test semantic graph, which includes the test elements carried by the natural language requirement document and the logical relationships between the test elements; Based on the test semantic graph, test case scripts are generated.

[0007] Furthermore, the step of performing deep semantic analysis on the natural language requirement document to obtain a test semantic graph includes: Deep semantic analysis of the natural language requirements document is performed using a large language model to obtain at least one of the test elements, wherein the test element is any one of the following: Test objects, operations, preconditions, expected results, and performance metrics; Based on the logical relationships between the test elements, a structured test semantic graph is constructed, wherein the test semantic graph has the test elements as nodes and the logical relationships between the test elements as edges.

[0008] Furthermore, the step of generating test case scripts based on the test semantic graph includes: Obtain test case templates that match the test semantic graph; Based on the test semantic graph, the test elements are filled into the test case template to generate the test case script.

[0009] Furthermore, the step of filling the test elements into the test case template based on the test semantic graph to generate the test case script includes: After mapping the test elements indicating operational actions and / or expected results to the bus signals and / or service interfaces of the vehicle under test, they are populated into the test case template; For other test elements besides the indicated operation and expected result, directly fill them into the test case template; Generate the test case script.

[0010] Furthermore, the method also includes: The test case script is analyzed and evaluated using any one or more of the following methods: Rule checking and model scoring.

[0011] Furthermore, the method also includes: Collect execution data for at least one of the test case scripts, wherein the execution data includes at least one or more of the following: Successful execution results, failed execution results, code coverage, and annotation feedback; Based on the execution data, a fine-tuning dataset is constructed, and incremental fine-tuning training is performed on the large language model to update the large language model.

[0012] Furthermore, the method also includes: Synchronize the test case scripts to the test management platform and / or the continuous integration and continuous deployment pipeline test environment.

[0013] According to a second aspect of the embodiments of this disclosure, a test case generation apparatus is provided, comprising: The Natural Language Requirements Acquisition Module is used to acquire natural language requirements files. The semantic parsing module is used to perform deep semantic analysis on the natural language requirement document to obtain a test semantic graph, which includes the test elements carried by the natural language requirement document and the logical relationships between the test elements. The script generation module is used to generate test case scripts based on the test semantic graph.

[0014] According to a third aspect of the embodiments of this disclosure, a computer apparatus is provided, comprising: processor; Memory used to store processor-executable instructions; The processor is configured to execute the test case generation method described above.

[0015] According to a fourth aspect of the embodiments of the present disclosure, a non-transitory computer-readable storage medium is provided, wherein when instructions in the storage medium are executed by a computer's processor, the computer is able to execute the above-described test case generation method.

[0016] The technical solutions provided by the embodiments of this disclosure can include the following beneficial effects: obtaining a natural language requirement document; performing deep semantic analysis on the natural language requirement document to obtain a test semantic graph, the test semantic graph including the test elements carried by the natural language requirement document and the logical relationships between the test elements; and finally generating test case scripts based on the test semantic graph. The requirements are proposed in natural language, and semantic recognition is performed on the natural language requirements, and complete test case scripts are automatically generated based on this. This achieves easy-to-use, user-friendly, efficient, and widely applicable automatic generation of test cases, solving the problems of poor adaptability and low construction efficiency caused by relying on manual operation to build test cases.

[0017] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0018] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.

[0019] Figure 1 This is a flowchart illustrating a test case generation method according to an exemplary embodiment.

[0020] Figure 2 This is a flowchart illustrating yet another test case generation method according to an exemplary embodiment.

[0021] Figure 3 This is a flowchart illustrating yet another test case generation method according to an exemplary embodiment.

[0022] Figure 4 This is a flowchart illustrating yet another test case generation method according to an exemplary embodiment.

[0023] Figure 5 This is a flowchart illustrating yet another test case generation method according to an exemplary embodiment.

[0024] Figure 6 This is a block diagram illustrating a test case generation system according to an exemplary embodiment.

[0025] Figure 7 This is a flowchart illustrating yet another test case generation method according to an exemplary embodiment.

[0026] Figure 8 This is a block diagram illustrating a test case generation apparatus according to an exemplary embodiment. Detailed Implementation

[0027] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.

[0028] As the complexity of vehicle electronic and electrical systems continues to increase and the functions of in-vehicle software become more numerous, extremely high demands are placed on the comprehensiveness and efficiency of ECU functional testing and integration testing. Traditional test case writing methods mainly rely on test engineers manually analyzing requirements documents and writing test cases, which has the following drawbacks: 1. Inability to efficiently handle rapidly iterating vehicle feature requirements; manual writing of test cases is time-consuming, severely slowing down the software development cycle; 2. Due to human factors, it is difficult to guarantee the comprehensive coverage of the requirements specifications by test cases, and boundary conditions and abnormal scenarios are easily missed. 3. Manually adjusting and maintaining a massive number of test cases is inefficient, especially when vehicle functions are changed or upgraded, the work of updating test cases is heavy and prone to errors; 4. Static, pre-written test case libraries cannot adapt to new and unforeseen test scenarios that arise during vehicle operation.

[0029] Template- or rule-based test generation tools can generate partial test scripts from structured input, but these technologies heavily rely on preset rules and lack deep semantic understanding of natural language requirements, failing to achieve end-to-end intelligent generation from requirements documents to test cases. Therefore, there is an urgent need for an automated test generation system that integrates natural language processing and intelligent decision-making from large language models to achieve adaptive and high-coverage test case generation.

[0030] To address the aforementioned problems, embodiments of this disclosure provide a test case generation method. The process of identifying natural language requirements and automatically generating test cases using this method is as follows: Figure 1 As shown, it includes: Step 101: Obtain the natural language requirements document.

[0031] In this step, test requirements expressed in natural language are obtained. Specifically, a natural language requirements document is obtained. This document can be a requirements specification in various formats such as Word, PDF, and Excel. The natural language requirements document is then imported into the system to initiate the test case generation process.

[0032] According to one exemplary implementation, in this step, after obtaining the natural language requirement file, the natural language requirement file is preprocessed, including but not limited to: cleaning, word segmentation, noise reduction, key information enhancement, etc., to prepare for subsequent semantic parsing.

[0033] Step 102: Perform deep semantic analysis on the natural language requirements document to obtain a test semantic graph.

[0034] The test semantic graph includes the test elements carried in the self-language requirements document and the logical relationships between the test elements. The test elements include at least one or more of the following: Test object, operation action, preconditions, expected results, performance indicators.

[0035] According to one exemplary implementation, the test semantic graph is a directed attribute graph, such as a DAG. It consists of three parts: nodes, edges, and attributes. Nodes correspond to test elements; edges reflect the logical relationships between test elements, such as triggers and constraints; and attributes include specific descriptive information carried by each node or edge.

[0036] By constructing a test semantic graph, a basis for subsequent test case generation is provided. The test semantic graph can point to a test scenario, and multiple test elements and their logical relationships form a scenario logic, based on which the current test scenario can be determined.

[0037] According to one exemplary implementation, the large language model is a pre-trained model based on the Transformer architecture.

[0038] According to one exemplary implementation, the large language model is a general large model such as GPT or LLaMA.

[0039] According to one exemplary implementation, the large language model is a domain-specific large language model with a smaller parameter scale, specifically designed for vehicle testing. This model is pre-trained and fine-tuned using specialized corpora such as vehicle requirements specifications, test case libraries, CANoe configuration documents, and the AUTOSAR standard, enabling it to have a deeper understanding of specialized terms and logical relationships such as "ECU," "CAN signal," and "diagnostic services." This improves the accuracy and professionalism of semantic parsing, reduces computational requirements, and avoids domain-independent outputs that may occur with general-purpose models, thereby enhancing the system's reliability and determinism.

[0040] According to one exemplary implementation, before deep semantic analysis using a large language model, an expert system can pre-build grammatical rules and pattern libraries for the vehicle testing domain (e.g., rules for recognizing conditional sentences such as "if...then..." and "when..."). The expert system first performs preliminary structured parsing, followed by deep semantic disambiguation and element association using the large language model. This combines the determinism of rule-based methods with the flexibility of machine learning methods, ensuring the accuracy of basic scene parsing while handling complex and ambiguous natural language descriptions, making the system more robust.

[0041] Step 103: Generate test case scripts based on the test semantic graph.

[0042] In this step, based on the test semantic graph, a preset test case template is invoked to generate the test case script. The specific process is as follows: Figure 2 As shown, it includes: Step 201: Obtain a test case template that matches the test semantic graph.

[0043] In this step, template matching is performed based on the test semantic graph to obtain matching test case templates.

[0044] According to one exemplary implementation, multiple test case templates can be pre-configured. Each test case template is a structured format that can be parsed by a program and contains a general framework for test cases. Examples include Gherkin (Given-When-Then), JUnit, TestNG, and pytest.

[0045] Different test case templates can be set according to different test scenarios. Variables that can be dynamically filled (such as vehicle speed, CAN signal, etc.) can be reserved in the test case template to realize the filling of the test semantic graph into the test case template.

[0046] Different test case templates can also be set according to the test objectives.

[0047] Different test case templates can also be set according to the execution environment.

[0048] Step 202: Based on the test semantic graph, fill the test elements into the test case template to generate the test case script.

[0049] In this step, based on the test semantic graph, the corresponding test elements are extracted and populated into the matching test case template.

[0050] According to one exemplary implementation, the test elements indicating operational actions and / or expected results are mapped to the vehicle under test (V2T) before being populated into the test case template. The mapping to the V2T primarily converts the operational actions and expected results into test instructions that the V2T can recognize and execute, ensuring consistency between the test cases and the V2T's operational logic. Compatibility is ensured between the test logic and the vehicle's underlying configuration, which includes, but is not limited to, communication protocols and software standards.

[0051] Requirements are expressed in natural language. Semantic recognition is performed on the natural language requirements, and complete test case scripts are automatically generated based on this. This achieves easy-to-use, user-friendly, efficient, and widely applicable test case generation, solving the problems of poor adaptability and low efficiency caused by relying on manual operation to build test cases.

[0052] An exemplary embodiment of this disclosure also provides a test case generation method, the process of generating a test semantic graph using this method is as follows: Figure 3 As shown, it includes: Step 301: Perform deep semantic analysis on the natural language requirement document using a large language model to obtain at least one of the test elements.

[0053] The test element is any one of the following: Test object, operation action, preconditions, expected results, performance indicators.

[0054] The test object defines the object to be tested and limits the scope of the test.

[0055] Operation actions define the specific actions that trigger the test scenario or system response, such as user operations or system controls.

[0056] Preconditions define the constraints necessary for test execution, such as hardware and software configuration requirements and environmental conditions.

[0057] The expected result defines the normal outcome after the operation is performed, such as the status and behavior, and provides evaluation criteria for functional implementation testing.

[0058] Performance metrics define the functional metrics of the system during execution, such as execution time and accuracy.

[0059] Step 302: Construct a structured test semantic graph based on the logical relationships between the test elements.

[0060] The test semantic graph uses the test elements as nodes and the logical relationships between the test elements as edges.

[0061] According to one exemplary implementation, the test semantic graph is a directed attribute graph, such as a DAG. It consists of three parts: nodes, edges, and attributes. Nodes correspond to test elements; edges reflect the logical relationships between test elements, such as triggers and constraints; and attributes include specific descriptive information carried by each node or edge.

[0062] By testing semantic graphs, key information in user requirements is preserved, providing a foundation for subsequent processes such as test case generation and vehicle mapping.

[0063] An exemplary embodiment of this disclosure also provides a test case generation method, which uses this method to perform different processing on different test elements, and the process of generating test case scripts is as follows: Figure 4 As shown, it includes: Step 401: After mapping the test elements indicating the operation actions and / or expected results to the bus signals and / or service interfaces of the vehicle under test, populate them into the test case template.

[0064] For operational actions and expected results, test elements are mapped and associated with the vehicle's underlying bus signals and software interfaces, covering CAN bus signal mapping and AUTOSAR service interface mapping, to support the automated execution of test case scripts.

[0065] Step 402: For other test elements besides the indicated operation and the expected result, directly fill them into the test case template.

[0066] In this step, test elements other than operational actions and expected results can be directly extracted and populated into the test case template.

[0067] When populating test elements, you can either fill them in according to behavioral logic or code logic. Taking Gherkin as a test case template as an example, extract the test elements and logic from the test semantic graph and populate them. Taking pytest as a test case template as an example, convert the natural language logic into executable syntax before populating it.

[0068] Step 403: Generate the test case script.

[0069] In this step, test case scripts are generated based on the completed test case template.

[0070] Test case scripts are automatically generated through vehicle context mapping and template population.

[0071] An exemplary embodiment of this disclosure also provides a test case generation method. This method allows for evaluation, model feedback, and test case integration after test cases are generated, further improving the efficiency and quality of automatic test case generation. The specific process is as follows: Figure 5 As shown, it includes: Step 501: Obtain the natural language requirements document.

[0072] Step 502: Perform deep semantic analysis on the natural language requirements document to obtain a test semantic graph.

[0073] Step 503: Generate test case scripts based on the test semantic graph.

[0074] Steps 501 to 503 are implemented in the same way as steps 101 to 103, and will not be explained again here.

[0075] Step 504: Analyze and evaluate the test case scripts.

[0076] In this step, the test case script is analyzed and evaluated using any one or more of the following methods: Rule checking and model scoring.

[0077] Specifically, the generated test cases are initially assessed for quality through rule checks (such as syntax and structural integrity) and model scoring (such as similarity calculation based on historical high-quality test cases).

[0078] Step 505: Collect execution data of at least one of the test case scripts.

[0079] The execution data includes at least one or more of the following: Results of successful execution, results of failed execution, code coverage, and annotation feedback.

[0080] Step 506: Construct a fine-tuning dataset based on the execution data, perform incremental fine-tuning training on the large language model, and update the large language model.

[0081] Collect execution results (both pass and fail) and code coverage data, along with feedback from test engineers, during the test execution phase to fine-tune the large language model, forming a closed loop of continuous optimization.

[0082] According to one exemplary implementation, the large language model is a pre-trained model based on the Transformer architecture and fine-tuned using corpus from the vehicle testing domain.

[0083] Step 507: Synchronize the test case scripts to the test management platform and / or the continuous integration and continuous deployment pipeline test environment.

[0084] In this step, the generated test cases can be exported or synchronized to the test management platform with one click. The test case scripts are then bound to the ECU requirements, allowing for the management and execution of test tasks without manual input. Test execution results can also be sent back to the test management platform. Furthermore, standardized test reports can be automatically generated based on the test results for subsequent project reviews and other purposes.

[0085] Test case scripts can also be synchronized to continuous integration and continuous deployment pipeline testing environments (such as CI / CD). The continuous integration and continuous deployment pipeline automatically retrieves and executes the test case scripts, adapting to the rapid iteration needs of vehicle ECU software. When ECU code changes, continuous integration triggers tests, enabling timely detection of issues caused by the code changes. Automated retrieval and parallel execution of multiple test cases can shorten the testing cycle.

[0086] An exemplary embodiment of this disclosure also provides a test case generation system that enables intelligent parsing of natural language requirements and automatic generation of test cases, solving the problems of low efficiency, incomplete coverage, and difficult maintenance of traditional test case writing, and improving the automation and intelligence level of software testing.

[0087] A smart automated test case generation system, such as Figure 6 As shown, it includes: The requirement input and preprocessing module 601 is used to receive and preprocess natural language requirement documents, specifically including: Requirements document interface 6011: Supports importing requirements specifications in multiple formats such as Word, PDF, and Excel; Natural Language Preprocessing Unit 6012: Cleans, segments, denoises, and enhances key information of the required text to obtain a natural language requirement file, preparing for semantic parsing.

[0088] Semantic parsing and modeling module 602 is used to perform semantic analysis of requirements using a large language model and to build a test semantic graph. Specifically, it includes: The core unit 6021 of the large language model uses a pre-trained large language model (such as GPT, LLaMA, BERT, etc.) to perform deep semantic analysis on the pre-processed natural language requirement document, and identify key test elements such as test objects, operation actions, preconditions, expected results, and performance indicators. Test Semantic Graph Builder 6022: Constructs the parsed test elements and their logical relationships into a structured test semantic graph, clearly representing the relationship between test logic and scenarios.

[0089] Test case generation module 603 is used to generate structured test case scripts based on the test semantic graph by calling the test template library, specifically including: Test Template Library 6031: Stores various test case templates, such as Gherkin (Given-When-Then), JUnit, TestNG, pytest, etc. Test Case Synthesis Engine 6032: Based on the test semantic graph, it calls the corresponding test case templates and automatically populates and generates specific, executable test case scripts. Vehicle signal mapping unit 6033: used to map the logical operations and expected results in test cases to specific vehicle bus signals or software service interfaces.

[0090] Specifically, the abstract operations and expected results in the test case script can be mapped to specific vehicle bus signals (such as CAN ID, PDU, Signal) or AUTOSAR service interfaces.

[0091] The evaluation and optimization module 604 is used to evaluate the quality of the generated test case scripts and optimize the large language model using feedback data. It continuously fine-tunes the large language model through test execution results, code coverage data, and manual annotation, forming a closed-loop optimization. Specifically, it includes: Test Case Quality Evaluator 6041: Performs preliminary quality assessment on generated test cases through rule checks (such as syntax and structural completeness) and model scoring (such as similarity calculation based on historical high-quality test cases); Feedback Learning Unit 6042: Collects pass / fail results, code coverage data, and annotation feedback from test engineers during the test execution phase to fine-tune the large language model, forming a closed loop of continuous optimization.

[0092] Output and Integration Module 605 is used to export generated test cases to a test management platform or integrate them into a CI / CD pipeline, specifically including: Test Case Management Platform Interface 6051: Supports one-click export or synchronization of generated test cases to mainstream test management platforms (such as Jira and TestRail). CI / CD pipeline integration unit 6052: Automatically integrates the generated test scripts into continuous integration / continuous deployment processes such as Jenkins and GitLab CI.

[0093] The test case generation system receives natural language requirement files, performs format conversion and text preprocessing, completing requirement input and preprocessing. The large language model parses the requirements, extracts test elements such as entities, actions, conditions, and expected results, and constructs a test semantic graph to complete semantic parsing. Based on the test semantic graph, test case templates are populated to generate test case scripts, and the binding of specific vehicle signals and interfaces is completed, thus completing vehicle context mapping. The generated test cases are quality-assessed, and the large language model is continuously iterated and optimized based on test execution feedback to improve the quality of subsequently generated test cases.

[0094] Taking the voice control function test of a vehicle air conditioning system (HVAC) as an example, the specific process is as follows: Figure 7 As shown, it includes: Step 701, Input Requirements.

[0095] The natural language requirements document states that "when a user says 'I'm a little hot' in the cabin, the system should automatically lower the air conditioning temperature by 2 degrees Celsius and increase the airflow by one level." Step 702, semantic parsing.

[0096] The large language model resolved the following: Test subject: Air conditioning system; Triggering condition: User's voice command "I'm a little hot"; Expected action 1: Lower the temperature by 2°C; Expected action 2: Increase airflow by one level.

[0097] Step 703: Test case script generation.

[0098] The system invokes the Gherkin template and generates the following test case scripts: Feature: Voice-controlled automatic air conditioning adjustment Scenario: User voice expression of perceived heat Given that the air conditioning system is in operation When the user says the voice command "I'm a little hot" Then the air conditioner setting temperature should be lowered by 2 degrees Celsius. And the air conditioning fan speed rating should be increased by one level. At the same time, the corresponding test case script is generated, and the "set temperature decreases by 2 degrees Celsius" is mapped to the specific change in the value of the CAN bus signal "HVAC_Temp_Set".

[0099] Step 704: Execution and Optimization.

[0100] Test cases are executed on the HIL test bench or in a real vehicle. If the test fails due to interference from the ambient temperature sensor, the result is fed back to the system to optimize the model so that it can consider adding environmental condition verification when generating similar test cases in the future.

[0101] An exemplary embodiment of this disclosure also provides a test case generation apparatus, the structure of which is as follows: Figure 8 As shown, it includes: Natural Language Requirements Acquisition Module 801 is used to acquire natural language requirements files; The semantic parsing module 802 is used to perform deep semantic analysis on the natural language requirement document to obtain a test semantic graph, wherein the test semantic graph includes the test elements carried by the natural language requirement document and the logical relationships between the test elements; The script generation module 803 is used to generate test case scripts based on the test semantic graph.

[0102] The aforementioned devices can be integrated into the vehicle control system (such as ECU, vehicle bus), and the corresponding functions can be implemented by the vehicle control system.

[0103] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.

[0104] An exemplary embodiment of this disclosure also provides a computer apparatus, including: processor; Memory used to store processor-executable instructions; The processor is configured to execute the test case generation method provided in the embodiments of this disclosure.

[0105] An exemplary embodiment of this disclosure also provides a non-transitory computer-readable storage medium, wherein instructions in the storage medium, when executed by a computer's processor, enable the computer to perform the test case generation method provided in the embodiments of this disclosure.

[0106] This disclosure provides a test case generation method, apparatus, computer device, and storage medium. The method involves obtaining a natural language requirement document; performing deep semantic analysis on the natural language requirement document to obtain a test semantic graph, which includes the test elements carried in the natural language requirement document and the logical relationships between these elements; and finally generating test case scripts based on the test semantic graph. By proposing requirements in natural language, performing semantic recognition on the natural language requirements, and automatically generating complete test case scripts, this method achieves easy-to-use, user-friendly, efficient, and widely applicable automatic test case generation, solving the problems of poor adaptability and low efficiency caused by relying on manual test case construction.

[0107] Based on a large language model, this system enables intelligent parsing of natural language requirements and automatic generation of test cases, solving the problems of low efficiency, incomplete coverage, and difficult maintenance in traditional test case writing, and improving the automation and intelligence level of software testing.

[0108] Those skilled in the art will also understand that the various illustrative logical blocks and steps listed in the embodiments of this disclosure can be implemented by electronic hardware, computer software, or a combination of both. Whether such functionality is implemented in hardware or software depends on the specific application and the overall system design requirements. Those skilled in the art can implement the described functionality using various methods for each specific application, but such implementation should not be construed as exceeding the scope of protection of the embodiments of this disclosure.

[0109] Furthermore, the term “exemplary” is used herein to mean serving as an example, instance, or illustration. Any aspect or design described herein as “exemplary” is not necessarily to be construed as advantageous compared to other aspects or designs. Rather, the use of the term “exemplary” is intended to present the concept in a concrete manner. As used herein, the term “or” is intended to mean an inclusive “or” rather than an exclusive “or.” That is, unless otherwise specified or clear from the context, “X applies A or B” is intended to mean any of the natural inclusive arrangements. That is, “X applies A or B” satisfies any of the foregoing instances if X applies A; X applies B; or both X applies A and B. Additionally, unless otherwise specified or clear from the context to refer to the singular form, the articles “a” and “an” as used in this application and the appended claims are generally understood to mean “one or more.”

[0110] Similarly, although this disclosure has been shown and described with respect to one or more implementations, equivalent variations and modifications will occur to those skilled in the art upon reading and understanding this specification and the accompanying drawings. This disclosure includes all such modifications and variations and is limited only by the scope of the claims. In particular, with respect to the various functions performed by the components described above (e.g., elements, resources, etc.), unless otherwise indicated, the terminology used to describe such components is intended to correspond to any component (functionally equivalent) that performs the specific function of the described component, even if structurally not equivalent to the disclosed structure. Furthermore, although specific features of this disclosure may have been disclosed with respect to only one of several implementations, such features may be combined with one or more other features of other implementations, as may be desired and advantageous to any given or particular application. Moreover, with regard to the terms “comprising,” “owning,” “having,” “having,” or variations thereof as used in the detailed description or claims, such terms are intended to be inclusive in a manner similar to the term “including.”

[0111] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.

[0112] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.

Claims

1. A test case generation method, characterized in that, include: Obtain the natural language requirements document; Perform deep semantic analysis on the natural language requirement document to obtain a test semantic graph, which includes the test elements carried by the natural language requirement document and the logical relationships between the test elements; Based on the test semantic graph, test case scripts are generated.

2. The test case generation method according to claim 1, characterized in that, The step of performing deep semantic analysis on the natural language requirements document to obtain a test semantic graph includes: Deep semantic analysis of the natural language requirements document is performed using a large language model to obtain at least one of the test elements, wherein the test element is any one of the following: Test objects, operations, preconditions, expected results, and performance metrics; Based on the logical relationships between the test elements, a structured test semantic graph is constructed, wherein the test semantic graph has the test elements as nodes and the logical relationships between the test elements as edges.

3. The test case generation method according to claim 1, characterized in that, The step of generating test case scripts based on the test semantic graph includes: Obtain test case templates that match the test semantic graph; Based on the test semantic graph, the test elements are filled into the test case template to generate the test case script.

4. The test case generation method according to claim 3, characterized in that, The step of filling the test elements into the test case template according to the test semantic graph and generating the test case script includes: After mapping the test elements indicating operational actions and / or expected results to the bus signals and / or service interfaces of the vehicle under test, they are populated into the test case template; For other test elements besides the indicated operation and expected result, directly fill them into the test case template; Generate the test case script.

5. The test case generation method according to claim 1, characterized in that, The method further includes: The test case script is analyzed and evaluated using any one or more of the following methods: Rule checking and model scoring.

6. The test case generation method according to claim 1, characterized in that, The method further includes: Collect execution data for at least one of the test case scripts, wherein the execution data includes at least one or more of the following: Successful execution results, failed execution results, code coverage, and annotation feedback; Based on the execution data, a fine-tuning dataset is constructed, and incremental fine-tuning training is performed on the large language model to update the large language model.

7. The test case generation method according to claim 1, characterized in that, The method further includes: Synchronize the test case scripts to the test management platform and / or the continuous integration and continuous deployment pipeline test environment.

8. A test case generation device, characterized in that, include: The Natural Language Requirements Acquisition Module is used to acquire natural language requirements files. The semantic parsing module is used to perform deep semantic analysis on the natural language requirement document to obtain a test semantic graph, which includes the test elements carried by the natural language requirement document and the logical relationships between the test elements. The script generation module is used to generate test case scripts based on the test semantic graph.

9. A computer device, characterized in that, include: processor; Memory used to store processor-executable instructions; The processor is configured to execute the test case generation method as described in any one of claims 1-7.

10. A non-transitory computer-readable storage medium, characterized in that, When the instructions in the storage medium are executed by the processor of a computer, the computer is able to perform the test case generation method as described in any one of claims 1-7.