Test case generation method and device based on NLP, equipment and storage medium

By using NLP-based intelligent parsing and structured processing of requirement documents, test cases are automatically generated, solving the problem of time-consuming and labor-intensive manual writing of traditional test cases, and achieving efficient and accurate test coverage and continuous optimization.

CN121210318APending Publication Date: 2025-12-26SHENZHEN EWARE INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511389820.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-26
Publication Date
2025-12-26

AI Technical Summary

Technical Problem

Traditional software testing relies heavily on manually writing test cases, which is time-consuming, labor-intensive, and prone to errors. Especially when faced with complex and ever-changing requirements, it is difficult to guarantee the coverage and timeliness of test cases.

Method used

Using an NLP-based approach, test elements and logical rules are extracted from requirement documents through intelligent parsing and structured processing. Test models are then built, test data and paths are automatically generated, and diverse test scripts are synthesized by combining automated scripts. The model is optimized through closed-loop feedback.

Benefits of technology

It enables precise capture of functional points and business rules, improves the accuracy and completeness of requirement understanding, reduces the impact of human factors, significantly improves testing efficiency and quality, and ensures that testing methods are synchronized with business requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121210318A_ABST
    Figure CN121210318A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of software testing, and relates to an NLP-based test case generation method and device, computer equipment and a storage medium, and the method comprises the steps: obtaining a demand document, and carrying out intelligent analysis and structural processing on the demand document; performing test element and logic rule extraction on the demand document subjected to intelligent analysis and structured processing; constructing a test model based on the demand document after the test elements and the logic rules are extracted; generating test data and a test path based on the test model; based on the test data and the test path, automatically synthesizing diversified test scripts; and closed-loop feedback and model iterative optimization are carried out. The method can ensure that the test method is always synchronous with the business demand, and finally realizes the dual improvement of the test quality and efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of software testing, and particularly relates to a test case generation method and device based on NLP, computer equipment and a storage medium. BACKGROUND

[0002] Traditional software testing relies heavily on test engineers manually writing test cases, which is a time-consuming, labor-intensive and error-prone process. Especially in the face of complex and variable requirements, it is a great challenge to ensure the coverage and timeliness of test cases. SUMMARY

[0003] In order to solve the above technical problems, the present application provides a test case generation method based on NLP, which adopts the technical scheme as follows, including the steps of:

[0004] Obtaining a requirement document and intelligently analyzing and structuring the requirement document;

[0005] Extracting test elements and logical rules from the requirement document that has been intelligently analyzed and structured;

[0006] Based on the requirement document that has been extracted for test elements and logical rules, a test model is constructed;

[0007] Based on the test model, test data and test paths are generated;

[0008] Based on the test data and test paths, diversified test scripts are automatically synthesized;

[0009] Closed-loop feedback and model iteration optimization are performed.

[0010] Preferably, the step of obtaining a requirement document and intelligently analyzing and structuring the requirement document specifically includes:

[0011] Obtaining the requirement document;

[0012] Document preprocessing and sentence segmentation and word segmentation processing are performed on the requirement document;

[0013] Named entity recognition and key information extraction are performed;

[0014] Dependency syntax analysis is performed.

[0015] Preferably, the step of extracting test elements and logical rules from the requirement document that has been intelligently analyzed and structured specifically includes:

[0016] Test operations and object mapping are performed;

[0017] Condition logic and constraint normalization are performed;

[0018] The expected result assertion generation is performed.

[0019] Preferably, the step of constructing a test model based on the requirements document after extracting the test elements and logical rules comprises:

[0020] Generating a finite state machine or a control flow graph;

[0021] Constructing an input-output dependency model;

[0022] Using a combination test design method to cover the most parameter interaction combinations with the least number of test cases.

[0023] Preferably, the step of generating test data and test paths based on the test model comprises:

[0024] Based on constraint solving and boundary value analysis, automatically generate test data that meets the constraints defined in the requirements and can effectively detect boundary defects;

[0025] Based on the FSM or control flow graph, generate test execution paths that cover different scenarios;

[0026] In the generated test cases, according to the risk and importance factors, the test cases are prioritized.

[0027] Preferably, the step of automatically synthesizing diversified test scripts based on the test data and test paths comprises:

[0028] Define a script template library;

[0029] Perform model-to-code mapping and conversion;

[0030] Perform script optimization and beautification.

[0031] Preferably, the step of performing closed-loop feedback and model iteration optimization comprises:

[0032] Perform test execution result monitoring and analysis;

[0033] Perform requirement change and model drift detection;

[0034] Perform model enhancement and optimization based on coverage.

[0035] In order to solve the above technical problems, the application also provides a test case generation device based on NLP, which adopts the technical scheme as follows, comprising:

[0036] A processing module is configured to acquire a requirement document and intelligently analyze and structure the requirement document;

[0037] An extraction module is configured to extract test elements and logical rules from the requirement document after intelligent analysis and structured processing.

[0038] A construction module is configured to construct a test model based on the requirement document after extraction of test elements and logical rules.

[0039] A generation module is configured to generate test data and test paths based on the test model.

[0040] A synthesis module is configured to automatically synthesize diversified test scripts based on the test data and test paths.

[0041] An optimization module is configured to perform closed-loop feedback and model iteration optimization.

[0042] To solve the above technical problems, the present application also provides a computer device, which adopts the technical solution as follows: a memory and a processor, the memory stores computer readable instructions, and the processor executes the computer readable instructions to realize the steps of the NLP-based test case generation method.

[0043] To solve the above technical problems, the present application also provides a computer readable storage medium, which adopts the technical solution as follows: the computer readable storage medium stores computer readable instructions, and the computer readable instructions are executed by the processor to realize the steps of the NLP-based test case generation method.

[0044] Compared with the prior art, the present application has the following beneficial effects:

[0045] (1) The requirement document is intelligently analyzed and structured processed, which can accurately capture function points, boundary conditions and business rules, effectively solve the problem of incomplete test coverage caused by information omission or understanding deviation in traditional manual analysis, and improve the accuracy and integrity of requirement understanding.

[0046] (2) Test elements and logical rules can be automatically extracted and a standardized test model can be constructed, which converts unstructured requirements into executable logical framework, changes the test design from experience-driven to data-driven, significantly reduces the influence of human factors on test case quality, and improves the standardization and maintainability of test cases;

[0047] (3) Based on the model, diversified test data and paths are automatically generated, which can cover normal scenarios, abnormal scenarios and edge scenarios, realize exponential expansion of test cases through dynamic combination of input parameters and execution paths, and combined with automatic script synthesis technology, executable scripts suitable for different test frameworks (such as unit testing and interface testing) can be quickly generated, which greatly improves the test efficiency;

[0048] (4) Closed-loop feedback mechanism continuously collects test execution results and defect data to drive model iteration optimization. The NLP model can adjust the analysis strategy and rule extraction logic according to the actual feedback, form a continuous improvement closed loop of demand-test-feedback-optimization, ensure that the test method is always synchronized with the business requirements, and finally realize the double improvement of test quality and efficiency. BRIEF DESCRIPTION OF DRAWINGS

[0049] In order to more clearly illustrate the solutions in the present application, the drawings needed to be used in the description of the embodiments of the present application will be briefly introduced as follows. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor on the basis of these drawings.

[0050] Figure 1 is a flow chart of an embodiment of the test case generation method based on NLP of the present application;

[0051] Figure 2 is a structural schematic diagram of an embodiment of the test case generation device based on NLP of the present application;

[0052] Figure 3 is a structural schematic diagram of an embodiment of the computer device of the present application. DETAILED DESCRIPTION

[0053] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the present application belongs; the terminology used in the specification of the application is only for the purpose of describing specific embodiments and is not intended to limit the present application; the terms "include" and "have" and any variations thereof in the specification and claims of the present application and the above description of drawings are intended to cover non-exclusive inclusion. The terms "first", "second" and the like in the specification and claims of the present application or the above description of drawings are used to distinguish different objects, not to describe a specific order.

[0054] In this paper, "embodiment" means that the specific features, structures or characteristics described in conjunction with the embodiment can be included in at least one embodiment of the present application. The phrase appears at various places in the specification does not necessarily refer to the same embodiment, nor is it independent or alternative to other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0055] In order to enable those skilled in the art to better understand the solutions of the present application, the technical solutions in the embodiments of the present application will be described clearly and completely in conjunction with the drawings.

[0056] It should be noted that the NLP-based test case generation method provided in the embodiments of the present application is generally executed by a server / terminal device, and accordingly, the NLP-based test case generation apparatus is generally arranged in the server / terminal device.

[0057] It should be understood that the number of terminal devices, networks and servers is only illustrative. According to the implementation needs, there can be any number of terminal devices, networks and servers.

[0058] Example One

[0059] Please refer to Figure 1 , a flowchart of one embodiment of the NLP-based test case generation method of the present application is shown. The NLP-based test case generation method comprises the following steps:

[0060] Step S1, obtaining a requirement document, and intelligently analyzing and structuring the requirement document.

[0061] In this embodiment, the electronic device (such as a server / terminal device) on which the NLP-based test case generation method runs can receive the NLP-based test case generation request through a wired connection or a wireless connection. It should be noted that the wireless connection can include but is not limited to 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAXX connection, Zigbee connection, UWB (ultra wideband) connection, and other now known or future developed wireless connection methods.

[0062] Natural Language Processing (NLP for short) is a key branch of artificial intelligence, which is committed to enabling computers to understand, analyze, generate and manipulate human language. It integrates knowledge from linguistics, computer science, mathematics and other disciplines, and through algorithms and models, it gives computers the ability to "understand" human language, and realizes natural and smooth communication between man and machine.

[0063] NLP has many significant advantages. First, it is highly efficient in information processing. In the face of massive text data such as news reports, social media content, etc., NLP can quickly extract key information, classify and summarize, helping users quickly obtain the required content, saving a lot of time and effort. Second, it improves the convenience and accuracy of communication. In the intelligent customer service scenario, NLP-driven chat robots can answer user questions in real time, provide accurate services, are not limited by time and space, and can avoid misunderstandings that may occur in human communication. Third, NLP helps personalized services. Through the analysis of user language data, it can deeply understand user needs and preferences, providing customized content recommendations such as music, movies, and goods, enhancing user experience. In addition, NLP plays an important role in cross-language communication, breaking down language barriers and promoting global information sharing and cooperation. In summary, NLP is profoundly changing people's way of life and work, and driving various industries towards intelligence.

[0064] Step S1 is the basis of the entire process, and the goal is to convert unstructured natural language requirement documents into structured data formats that can be understood and processed by machines. It is not simply keyword extraction, but a combination of various NLP techniques to deeply understand the semantics of requirements.

[0065] In this embodiment, step S1, obtaining the requirement document, and intelligently parsing and structuring the requirement document specifically includes the following steps:

[0066] S11, obtaining the requirement document.

[0067] Project management tools can be used to collect requirement documents. Many enterprises use professional project management software such as Jira, Trello, etc., and project members will upload and update requirement documents in these tools. By accessing these tools, the latest and complete requirement documents can be obtained.

[0068] S12, document preprocessing and sentence segmentation and word segmentation processing of the requirement document.

[0069] First, format uniformity: convert different formats of documents such as PDF, Word, etc. into pure text, and remove irrelevant noise such as headers, footers, page numbers, etc.

[0070] Then, sentence boundary detection: use NLP tools (such as NLTK, spaCy) to cut the text into independent sentences according to periods, question marks, line breaks, etc. Each sentence usually corresponds to an independent function description or constraint condition.

[0071] Finally, word segmentation and part-of-speech tagging: further divide each sentence into words or tokens, and tag each token with its part of speech (such as noun, verb, adjective), which helps identify the key components in the sentence.

[0072] Step S12 aims to clean and standardize the original requirement document, preparing for the subsequent in-depth analysis. It cuts the continuous text stream into discrete, meaningful analysis units (sentences and words).

[0073] S13, perform named entity recognition and key information extraction.

[0074] First, predefine entity types: according to the field characteristics of software testing, predefine the entity types that need to be recognized, such as UI elements (Buttn_Lgin, TextField_Username), data entities (User, Order, Product), domain values (Email, PhoneNumber), operations (Click, Submit, Calculate), etc.

[0075] Then, model recognition: use pre-trained NER models (such as BERT-based NER) or rule-based methods to identify these pre-defined entities in the tokenized text.

[0076] Finally, preliminary relationship linking: preliminarily establish the relationship between entities, for example, the verb "input" is usually associated with a UI element entity and a domain value entity.

[0077] The role of step S13 is to identify specific and important entity information in the requirement document, which are usually the operation objects or important parameters in the testing process. This is a key step to "anchor" natural language to specific software elements.

[0078] S14, perform dependency syntax analysis.

[0079] First, build dependency tree: use dependency syntax analyzer (such as spaCy's Parser) to process each sentence and generate a dependency tree. This tree shows the subject-predicate-object, condition-action-result, etc. relationship between words.

[0080] Second, extract logical triples: based on the dependency tree, extract structured (subject, predicate, object) or (condition, action, result) triples.

[0081] Example: for the sentence "If the username is valid and the password is correct, the system should allow the user to log in."

[0082] Extract: Condition: (username, valid), (password, correct); Action: allow; Result: (user, login).

[0083] Finally, identify logical operators: identify conjunctions (e.g. "and", "or", "if…then") in the sentence and convert them into logical operators (AND, OR, IF…THEN), laying the foundation for subsequent construction of logical judgment tree.

[0084] Step S14: Analyze the grammatical dependencies between words in the sentence to accurately understand "who did what to whom", "what is the condition", "what is the result". This is the core of understanding the logic of requirements.

[0085] Step S2, test elements and logical rule extraction is carried out on the requirement document which has been intelligently parsed and structured.

[0086] Step S2, the structured information obtained in the previous step is further refined and classified to form the core elements and rules of the test case.

[0087] In this embodiment, step S2, test elements and logical rule extraction is carried out on the requirement document which has been intelligently parsed and structured, specifically including the following steps:

[0088] S21, test operation and object mapping is carried out.

[0089] First, verb-entity pairing is carried out: based on the results of dependency analysis, the verbs representing actions (such as click, input, select, drag) are accurately paired with the previously identified UI elements or data entities. Form (action, object) pairs, such as (input, TextField_Username), (click, Buttn_Lgin).

[0090] Second, operation parameterization is carried out: identify parameters related to actions, especially for "input" type operations. For example, "username" in "input username" is a parameter, whose value needs to be parameterized for subsequent generation of multiple test data.

[0091] Finally, generate operation sequence: according to the sequence or logical flow of the requirement description, combine discrete (action, object) pairs into a preliminary operation sequence.

[0092] The function of step S21 is to clearly identify the specific operations to be performed in the test and the objects to which these operations are applied, providing materials for "action statements" in the test script.

[0093] S22, condition logic and constraint normalization is carried out.

[0094] First, identify conditional clauses: use the results of syntactic analysis to locate conditional leading words (such as "if", "when", "unless") and their jurisdictional clause range.

[0095] Second, logical expression conversion: convert the conditions from sentences to standard logical expressions.

[0096] Example: "Username length greater than 6 characters and contains letters" -> LEN(Username) > 6 AND CONTAINS_ALPHA(Username)

[0097] Example: "User role is either administrator or super user" -> User.Role == ADMIN OR User.Role == SUPER_USER

[0098] Finally, build a decision tree: for complex nested conditions (if-else if-else), build a tree structure to represent all the logical branch paths.

[0099] Step S22 is to convert the natural language described conditions and constraints into standard, computer processable logical expressions. This is the key to generating branch test cases.

[0100] S23, generate expected result assertion.

[0101] First, result sentence recognition: identify the words and sentences that represent the expected results, such as "should display", "will", "jump to", "prompt" and so on.

[0102] Second, construct the assertion statement: convert the expected results into assertion statements.

[0103] Example: "The system should display the welcome page" -> assert current_page == WelcomePage

[0104] Example: "The order status should be updated to 'paid'" -> assert order.status == PAID

[0105] Finally, result value normalization: identify and standardize specific values in the expected results, such as "success message", "error code 123", etc., and use them as expected values for assertion statements.

[0106] Step S23 is to define the expected correct utcme of test execution, which is the source of assertion (Assertin) statements in the test script, used to judge whether the test passes or not.

[0107] Step S3, based on the requirements document extracted from the test elements and logical rules, build a test model.

[0108] Step S3 is the theoretical core of the method of the embodiment, which integrates all elements extracted in the previous two steps into an abstract and semantic-rich test model. This model is the blueprint for generating specific test cases.

[0109] In the embodiment, step S3, based on the requirement document extracted by the test elements and the logical rules, constructing the test model specifically includes the steps of:

[0110] S31, generating a finite state machine or a control flow graph.

[0111] First, state node definition: define the "results" or "interfaces" identified from the requirements as states (States), such as login page, home page, payment success page, error popup.

[0112] Second, edge and trigger event definition: define the (action, object) pair as the event (Events / Transitins) that triggers the state transition, connecting two state nodes.

[0113] Finally, build FSM graph: combine all states and transitions to form a complete FSM. Generating test cases is equivalent to transforming into a problem that covers all states and transition paths of the FSM.

[0114] For state transition systems (such as UI navigation, workflow), finite state machine (FSM) is the best modeling tool. It describes how the system switches from one state to another and the events (actions) that trigger the switch.

[0115] S32, build input-output dependency model.

[0116] First, define the input domain: collect all parameterized input operations and their constraint conditions to form the value range of the input.

[0117] Second, define the output domain: collect all output results involved in the assertions.

[0118] Finally, establish the mapping relationship: use conditional logic to describe how different input combinations map to different output results. This can be regarded as a function: utput=F(Input1,Input2,...,InputN).

[0119] The role of step S32 is to clarify the relationship between test input and expected output, especially for computing and processing functions (non-UI operations). This model is the basis for generating parameterized testing and data-driven testing.

[0120] S33, adopt the combinatorial test design method to cover the most parameter interaction combinations with the least number of test cases.

[0121] First, parameter and value range extraction: extract all input parameters and their possible values from the input-output dependency model (e.g., UserRole = {Admin, User, Guest}; Age = {Child, Adult}).

[0122] Second, generate combination table: use CTD algorithm (e.g., IP, graph-based algorithm) to generate a pairwise combination (or N-wise combination) coverage table.

[0123] The goal of the combination test design is to minimize the number of test cases N while meeting the coverage strength t:

[0124]

[0125] where C is a test configuration, which is a set of parameters and their value ranges, t is the coverage strength (e.g., t = 2 represents pairwise coverage), N is the total number of generated test cases, P is an arbitrary subset of size t of parameters, v is an arbitrary valid value combination of parameters in P, and T is a test case, which is a combination of parameter values.

[0126] Objective: Minimize N, where for all valid value combinations of any t parameters of all parameters, at least one test case appears.

[0127] Finally, model enhancement: integrate the generated combination table into the test model to guide the generation of subsequent test data.

[0128] The purpose of step S33 is to solve the problem of input parameter combination explosion by using CTD (e.g., IP, graph-based algorithm) to cover the most parameter interaction combinations with the least number of test cases, thereby significantly improving test efficiency while ensuring high coverage.

[0129] Pairwise / All-Pairs technique) to cover the most parameter interaction combinations with the least number of test cases, thereby significantly improving test efficiency while ensuring high coverage.

[0130] Step S4, based on the test model, generates test data and test paths.

[0131] Step S4 uses the constructed test model to automatically generate specific test input data and test scenarios that cover different logical paths.

[0132] In this embodiment, step S4, based on the test model, generates test data and test paths specifically includes the steps:

[0133] S41, based on constraint solving and boundary value analysis, automatically generates test data that meets the constraints defined in the requirements and can effectively detect boundary defects.

[0134] First, constraint collection: extract all constraints on input parameters from conditional logic (e.g. age >= 18, name!= "")

[0135] Second, valid value resolution: use a constraint solver (Z3 Therem Prver) to generate a valid value for each parameter that satisfies all constraints (e.g. generate 25 for age).

[0136] Finally, boundary value generation: for each parameter, automatically calculate boundary values and invalid values that slightly exceed the boundary, based on its constraints.

[0137] Example: for age >= 18, generate 17 (invalid), 18 (boundary valid), 19 (valid).

[0138] The role of step S41 is to automatically generate test data that not only meets the constraints defined in the requirements, but also effectively detects boundary defects.

[0139] S42, based on FSM or control flow graph, generate test execution paths that cover different scenarios.

[0140] First, path coverage criteria selection: select path generation strategies according to test coverage requirements, such as edge coverage (cover all transitions), path coverage (cover all simple paths), baseline path coverage, etc.

[0141] Second, generate algorithm to generate paths: use graph theory algorithms (such as depth-first search DFS, breadth-first search BFS) or special path generation algorithms for FSM (such as Chinese Pstman Prblem fr transitin cverage) to traverse the model and generate a series of path sequences (state->(action)->state->...).

[0142] Finally, path and data binding: bind the test data generated in step S41 to the corresponding input actions in the path to form a complete, executable test scenario.

[0143] S43, in the generated test cases, according to risk, importance factors, test case priority sorting.

[0144] First, define priority indicators: establish a sorting model, indicators can include: path complexity (the more conditions, the higher the priority), requirement importance (extracted from requirement documents), code change impact analysis (if access to code library), input combination rarity (use cases that cover rare interactions have high priority).

[0145] Second, calculate priority score: calculate a comprehensive priority score for each test case.

[0146] Formula (Weighted Priority Score): Priority_Score i = w1 · Complexity i + w2 ·

[0147] Requirement_Criticality i + w3 · Change_Impact i ; where, Priority_Score i : the priority score of the ith test case, w1, w2, w3: the weight of each index, satisfying w1 + w2 + w3 = 1.

[0148] Complexity i : the normalized complexity (e.g. McCabe cyclomatic complexity) of the ith test case path.

[0149] Requirement_Criticality i : the functional importance level (e.g. 1-5) of the requirement covered by the test case.

[0150] Change_Impact i : the recent change impact (if any) of the code covered by the test case.

[0151] Finally, rank the test case set: according to Priority_Score i , rank all generated test cases in descending order.

[0152] Step S43 is to: in the generated many test cases, according to the risk, importance and other factors for sorting, in order to in the limited time, priority to execute the test case which is most likely to find defects.

[0153] Step S5, based on test data and test path, automatically synthesize diversified test script.

[0154] Step S5 compiles the abstract test model and the specific test data / path into a specific script that can be executed for different test frameworks and platforms.

[0155] In this embodiment, step S5, based on test data and test path, automatically synthesizes diversified test script specifically includes steps:

[0156] S51, define script template library.

[0157] First, define atomic operation templates: define code snippet templates for each common test operation (e.g. click, input_text, select_drpdwn) corresponding to different test frameworks (Selenium, Appium, Cypress, JUnit).

[0158] Second, define assertion templates: define code templates for common assertion types (e.g. assert_equal, assert_cntains, assert_visible).

[0159] Finally, define control flow templates: define templates for conditional statements (if-else), loops, and other logical structures.

[0160] Step S51 serves to provide a set of reusable code templates for different operations, assertions, and flow controls, decoupling test logic from specific programming languages.

[0161] S52, perform model-to-code mapping and conversion.

[0162] First, perform element mapping: map (action, object) pairs in the test model to atomic operation templates, and fill in specific UI element locators (ID, XPath) and test data into template placeholders.

[0163] Second, perform logic structure injection: use control flow templates to organize different operation sequences according to the conditional branches in the test path.

[0164] Finally, perform assertion injection: at the end of the path, map the expected results to the assertion templates and inject them into the script.

[0165] Step S52 serves to fill in the various components of the test case (operation sequence, test data, assertion point) into the corresponding code templates, synthesizing a complete test script.

[0166] S53, perform script optimization and beautification.

[0167] First, follow the code specifications: apply code formatting tools (e.g. Prettier, Black) to make the generated script conform to the project's coding specifications (indentation, naming, etc.).

[0168] Second, introduce the Page bject pattern: if the model is complex, you can abstract the UI element locators into Page bject classes at a high level, then call the methods of these classes in the script, greatly improving the maintainability of the script.

[0169] Finally, eliminate redundant operations: analyze the operation sequence, eliminate repeated and unnecessary operations (such as multiple initializations on the same page).

[0170] The role of step S53 is to ensure that the generated script not only functions correctly, but also has good readability and maintainability, making it easy for developers to view and debug.

[0171] Step S6, closed-loop feedback and model iterative optimization.

[0172] Step S6 makes the entire system an intelligent agent that can learn and improve itself, rather than just a one-time code generator.

[0173] In this embodiment, step S6, closed-loop feedback and model iterative optimization specifically includes the steps of:

[0174] S61, test execution result monitoring and analysis.

[0175] First, capture the results: monitor the test execution process, capture the pass / fail status of each test case, error information when failing, screenshots, logs, etc.

[0176] Second, classify failed test cases: preliminarily analyze the failed test cases and classify the failure reasons (such as product defects, environmental problems, script defects, requirement changes).

[0177] Finally, associate the results with the model: feedback and mark the execution results to the corresponding paths, conditions or data in the test model.

[0178] The role of step S61 is to collect the results after running the automated test script and associate them with the initial requirement model.

[0179] S62, requirement change and model drift detection.

[0180] First, perform a text difference comparison: use the diff tool to compare the new and old versions of the requirement document to find out the added, deleted, and modified sentences.

[0181] Second, perform impact analysis: map the text differences to the test model and analyze which function points, operations, conditions or results are affected.

[0182] Finally, make changes: report the detected model differences and potential impact range to the test engineer, and suggest the test cases that need to be updated.

[0183] The role of step S62 is to automatically or semi-automatically identify the change points when the requirement document changes, and prompt to update the test model.

[0184] S63, perform model enhancement and optimization based on coverage.

[0185] The role of step S63 is to find out the possible omissions of the test model according to the feedback information such as code coverage, so as to supplement the test cases and achieve higher coverage.

[0186] First, collect coverage data: collect code coverage reports (line coverage, branch coverage, etc.) during test execution.

[0187] Second, analyze coverage gaps: compare and analyze low-coverage or uncovered code modules with the test model to find out whether the model is missing the corresponding requirement description or the test data fails to trigger a specific branch.

[0188] Finally, model completion and regeneration: according to the analysis results, supplement or correct the test model (for example, add a missed conditional branch), and then trigger the process to regenerate test cases that cover the gap.

[0189] Although coverage itself is a percentage, the optimization process can be seen as maximizing the coverage gain. The coverage feedback gain formula is: Gain = Coverage_new - Coverage_old, where Coverage_old is the code coverage of the original test case set, Coverage_new is the code coverage after adding new test cases generated according to the coverage gap analysis, and Gain is the coverage gain. The goal of the system is to continuously iterate to make Gain approach 0 (i.e., close to 100% coverage).

[0190] The implementation of this embodiment has the following beneficial effects:

[0191] (1) Through intelligent analysis and structured processing of requirement documents, it can accurately capture function points, boundary conditions and business rules, effectively solve the problem of incomplete test coverage caused by information omission or understanding deviation in traditional manual analysis, and improve the accuracy and integrity of requirement understanding;

[0192] (2) It can automatically extract test elements and logical rules and build a standardized test model. This process converts unstructured requirements into executable logical framework, making test design from experience-driven to data-driven, significantly reducing the impact of human factors on test case quality, while improving the standardization and maintainability of test cases;

[0193] (3) Based on the model, it can automatically generate diversified test data and paths, covering normal scenarios, abnormal scenarios and edge scenarios. Through dynamic combination of input parameters and execution paths, it realizes exponential expansion of test cases. Combined with automatic script synthesis technology, it can quickly generate executable scripts that adapt to different test frameworks (such as unit testing, interface testing), greatly improving test efficiency;

[0194] (4) Closed-loop feedback mechanism drives model iterative optimization by continuously collecting test execution results and defect data, and the NLP model can adjust the analysis strategy and rule extraction logic according to the actual feedback, forming a continuous improvement closed loop of demand-test-feedback-optimization, ensuring that the test method is always synchronized with the business requirements, and ultimately achieving the dual improvement of test quality and efficiency.

[0195] The application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld devices or portable devices, tablet devices, multi-processor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The application can also be practiced in a distributed computing environment in which tasks are performed by remote processing devices connected by a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media, including storage devices.

[0196] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by computer-readable instructions instructing related hardware, and the computer-readable instructions can be stored in a computer-readable storage medium. The program, when executed, can include the processes of the above-mentioned embodiments. The storage medium can be a non-volatile storage medium such as a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0197] It should be understood that although each step in the flowchart of the accompanying drawings is shown in sequence according to the direction of the arrow, these steps are not necessarily executed in sequence according to the direction of the arrow. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and they can be executed in other orders. Moreover, at least part of the steps in the flowchart of the accompanying drawings can include multiple sub-steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence is not necessarily sequential, but can be alternately or alternately executed with at least part of other steps or sub-steps or stages of other steps.

[0198] Example Two

[0199] Further referring to Figure 2 , as an implementation of the method shown in the above Figure 1 , the present application provides an embodiment of an NLP-based test case generation device, which corresponds to the method embodiment shown in Figure 1 , and the device can be specifically applied to various electronic devices.

[0200] As shown in Figure 2 , the NLP-based test case generation device 70 of the present embodiment comprises a processing module 71, an extraction module 72, a construction module 73, a generation module 74, a synthesis module 75 and an optimization module 76.

[0201] Among them:

[0202] The processing module 71 is configured to obtain a requirement document and intelligently parse and structure process the requirement document;

[0203] The extraction module 72 is configured to extract test elements and logical rules from the requirement document that has been intelligently parsed and structured processed;

[0204] The construction module 73 is configured to construct a test model based on the requirement document that has been extracted for test elements and logical rules;

[0205] The generation module 74 is configured to generate test data and test paths based on the test model;

[0206] The synthesis module 75 is configured to automatically synthesize diversified test scripts based on the test data and test paths;

[0207] The optimization module 76 is configured to perform closed-loop feedback and model iteration optimization.

[0208] Implementing the present embodiment has the following beneficial effects:

[0209] (1) By intelligently parsing and structuring processing the requirement document, the functional points, boundary conditions and business rules can be accurately captured, effectively solving the problem of incomplete test coverage caused by information omission or understanding deviation in traditional manual parsing, and improving the accuracy and integrity of requirement understanding;

[0210] (2) Test elements and logical rules can be automatically extracted and a standardized test model can be constructed, which converts unstructured requirements into an executable logical framework, enabling the test design to shift from experience-driven to data-driven, significantly reducing the impact of human factors on test case quality, while improving the standardization and maintainability of test cases;

[0211] (3) Based on the model, it automatically generates diverse test data and paths, which can cover normal scenarios, abnormal scenarios and edge scenarios. By dynamically combining input parameters and execution paths, it can achieve exponential expansion of test cases. Combined with automated script synthesis technology, it can quickly generate executable scripts that are compatible with different test frameworks (such as unit testing and interface testing), which greatly improves test efficiency.

[0212] (4) The closed-loop feedback mechanism drives the model iterative optimization by continuously collecting test execution results and defect data. The NLP model can adjust the parsing strategy and rule extraction logic according to the actual feedback, forming a continuous improvement closed loop of requirements-testing-feedback-optimization, ensuring that the testing method always keeps pace with business requirements, and ultimately achieving a dual improvement in test quality and efficiency.

[0213] Example Three

[0214] To address the aforementioned technical problems, embodiments of the present invention also provide a computer device. Please refer to [link / reference needed]. Figure 3 , Figure 3 This is a basic structural block diagram of the computer device in this embodiment.

[0215] The aforementioned computer device 8 includes a memory 81, a processor 82, and a network interface 83 that are interconnected via a system bus. It should be noted that only the computer device 8 with components 81, 82, and 83 is shown in the figure; however, it should be understood that it is not required to implement all the shown components, and more or fewer components can be implemented alternatively. Those skilled in the art will understand that the computer device described herein is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0216] The aforementioned computer devices can be desktop computers, laptops, handheld computers, and cloud servers, among other computing devices. These devices can facilitate human-computer interaction with users through keyboards, mice, remote controls, touchpads, or voice-activated devices.

[0217] The memory 81 includes at least one type of readable storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., an SD or DX memory, etc.), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the memory 81 can be an internal storage unit of the computer device 8, such as a hard disk or a memory of the computer device 8. In other embodiments, the memory 81 can also be an external storage device of the computer device 8, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device 8. Of course, the memory 81 can also include both the internal storage unit and the external storage device of the computer device 8. In this embodiment, the memory 81 is generally used to store an operating system and various application software installed on the computer device 8, such as computer readable instructions of the NLP-based test case generation method, etc. In addition, the memory 81 can also be used to temporarily store various data that have been output or will be output.

[0218] The processor 82 can be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip in some embodiments. The processor 82 is generally used to control the overall operation of the computer device 8. In this embodiment, the processor 82 is used to run computer readable instructions or process data stored in the memory 81, such as computer readable instructions of the NLP-based test case generation method.

[0219] The network interface 83 can include a wireless network interface or a wired network interface, and is generally used to establish a communication connection between the computer device 8 and other electronic devices.

[0220] By implementing this embodiment, the following beneficial effects can be achieved:

[0221] (1) By intelligently analyzing and structurally processing the requirement document, the functional points, boundary conditions and business rules can be accurately captured, the problem of incomplete test coverage caused by information omission or understanding deviation in traditional manual analysis can be effectively solved, and the accuracy and integrity of requirement understanding can be improved;

[0222] (2) can automatically extract test elements and logical rules, and build a standardized test model, which converts unstructured requirements into executable logical framework, changes test design from experience-driven to data-driven, significantly reduces the influence of human factors on test case quality, and improves the standardization and maintainability of test cases;

[0223] (3) based on the model, automatically generate diversified test data and paths, which can cover normal scenarios, abnormal scenarios and edge scenarios, realize exponential expansion of test cases through dynamic combination of input parameters and execution paths, and combined with automatic script synthesis technology, can quickly generate executable scripts suitable for different test frameworks (such as unit testing, interface testing), greatly improve the test efficiency;

[0224] (4) the closed-loop feedback mechanism drives model iteration optimization by continuously collecting test execution results and defect data, the NLP model can adjust the analysis strategy and rule extraction logic according to the actual feedback, forms a continuous improvement closed loop of requirement-test-feedback-optimization, ensures that the test method is always synchronized with the business requirements, and finally realizes the double improvement of test quality and efficiency.

[0225] Example Four

[0226] The application also provides another embodiment, that is, a computer readable storage medium storing computer readable instructions, the computer readable instructions can be executed by at least one processor to make the at least one processor execute the steps of the NLP-based test case generation method as described above.

[0227] The embodiment is implemented, and has the beneficial effects that:

[0228] (1) through intelligent analysis and structured processing of requirement documents, the function points, boundary conditions and business rules can be accurately captured, the problem of incomplete test coverage caused by information omission or understanding deviation in traditional manual analysis can be effectively solved, and the accuracy and integrity of requirement understanding are improved;

[0229] (2) can automatically extract test elements and logical rules, and build a standardized test model, which converts unstructured requirements into executable logical framework, changes test design from experience-driven to data-driven, significantly reduces the influence of human factors on test case quality, and improves the standardization and maintainability of test cases;

[0230] (3) Based on the model, diversified test data and paths are automatically generated, which can cover normal scenarios, abnormal scenarios and edge scenarios. Through dynamic combination of input parameters and execution paths, exponential expansion of test cases is realized. Combined with automatic script synthesis technology, executable scripts suitable for different test frameworks (such as unit testing and interface testing) can be quickly generated, and the test efficiency is greatly improved;

[0231] (4) The closed-loop feedback mechanism continuously collects test execution results and defect data to drive model iteration and optimization. The NLP model can adjust the analysis strategy and rule extraction logic according to the actual feedback, forming a continuous improvement closed loop of demand-testing-feedback-optimization, ensuring that the test method always keeps pace with business requirements, and ultimately achieving double improvement of test quality and efficiency.

[0232] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be realized by means of software and the necessary general hardware platform, of course, they can also be realized by hardware, but in many cases the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes a plurality of instructions for making a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) execute the various embodiment methods of the present application.

[0233] Obviously, the above-described embodiments are only some of the embodiments of the present application, not all the embodiments, and the preferred embodiments of the present application are given in the drawings, but do not limit the patent scope of the present application. The present application can be realized in many different forms, and on the contrary, the purpose of providing these embodiments is to make the disclosure of the present application more thorough and comprehensive. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments, or equivalently replace some of the technical features. Any equivalent structure made by using the contents of the present application specification and drawings, directly or indirectly applied to other related technical fields, is also within the patent protection scope of the present application.

Claims

1. A method for generating test cases based on NLP, characterized in that, The method comprises the following steps: obtaining a requirement document and intelligently analyzing and structuring the requirement document; extracting test elements and logical rules from the requirement document after intelligent analysis and structured processing; constructing a test model based on the requirement document after test element and logical rule extraction; generating test data and test paths based on the test model; automatically synthesizing diversified test scripts based on the test data and test paths; performing closed-loop feedback and model iteration optimization.

2. The NLP based test case generation method as claimed in claim 1, wherein, The step of obtaining a requirement document and intelligently analyzing and structuring the requirement document comprises: obtaining the requirement document; performing document preprocessing and sentence segmentation and word segmentation processing on the requirement document; performing named entity recognition and key information extraction; performing dependency syntax analysis.

3. The NLP based test case generation method as claimed in claim 1, wherein, The step of extracting test elements and logical rules from the requirement document after intelligent analysis and structured processing comprises: performing test operation and object mapping; performing conditional logic and constraint normalization; generating expected result assertion.

4. The NLP based test case generation method as claimed in claim 1, wherein, The step of constructing a test model based on the requirement document after test element and logical rule extraction comprises: generating a finite state machine or a control flow graph; constructing an input-output dependency model; adopting a combination test design method to cover the most parameter interaction combinations with the least number of test cases.

5. The NLP based test case generation method as claimed in claim 1, wherein, The step of generating test data and test paths based on the test model comprises: automatically generating test data that meets the constraint conditions defined in the requirement and can effectively detect boundary defects based on constraint solving and boundary value analysis; generating test execution paths covering different scenarios based on the FSM or control flow graph; performing test case priority sorting according to risk and importance factors among the generated test cases.

6. The NLP based test case generation method as claimed in claim 1, wherein, The step of automatically synthesizing diversified test scripts based on the test data and test paths comprises: defining a script template library; performing model-to-code mapping and conversion; performing script optimization and beautification.

7. The NLP-based test case generation method according to any one of claims 1 to 6, characterized in that, The step of performing closed-loop feedback and model iteration optimization comprises: performing test execution result monitoring and analysis; performing requirement change and model drift detection; performing model enhancement and optimization based on coverage.

8. A NLP based test case generation apparatus, characterized by, The method comprises: a processing module for obtaining a requirement document and intelligently analyzing and structuring the requirement document; an extraction module for extracting test elements and logical rules from the requirement document after intelligent analysis and structured processing; a construction module for constructing a test model based on the requirement document after test element and logical rule extraction; a generation module for generating test data and test paths based on the test model; a synthesis module for automatically synthesizing diversified test scripts based on the test data and test paths; an optimization module for performing closed-loop feedback and model iteration optimization.

9. A computer device, comprising: The method comprises a memory and a processor, the memory stores computer readable instructions, and the processor executes the computer readable instructions to realize the steps of the NLP-based test case generation method in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer readable instructions, which, when executed by a processor, implement the steps of the NLP-based test case generation method according to any one of claims 1 to 7.