Test requirement and test case alignment detection method and device and electronic equipment
By rewriting test requirements and test cases and constructing a vector database, a generative model is used for bidirectional semantic alignment detection, which solves the problem of difficulty in aligning test requirements and test cases in existing technologies. This achieves efficient coverage and detection of unrelated test cases, reducing resource waste and manpower costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TRAVELSKY TECHNOLOGY LIMITED
- Filing Date
- 2026-03-11
- Publication Date
- 2026-06-19
Smart Images

Figure CN122240479A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and more specifically, to a method, apparatus, and electronic device for aligning test requirements with test cases. Background Technology
[0002] In software development, existing coverage testing technologies (including keyword matching and simple vector retrieval schemes) typically segment SRS (Software Requirements Specification) documents directly. However, in real-world engineering, SRS documents often suffer from vague descriptions, complex logic, and non-standardized structures. For example, a single paragraph might contain multiple functional points and non-functional constraints. Directly embedding and retrieving such low-quality text generates noisy vectors, making it impossible to correctly match corresponding test cases. Furthermore, current technologies mostly employ a one-way flow of "requirement → test case" testing, only answering "has this requirement been tested?" As projects iterate, requirements are deleted or modified, but the corresponding old test cases are often left in the repository. One-way testing cannot discover redundant test cases, which become zombie code, wasting maintenance and execution resources.
[0003] There is currently no effective solution to the above problems. Summary of the Invention
[0004] This invention provides a method, apparatus, and electronic device for aligning test requirements and test cases, to at least solve the technical problem in related technologies that cannot achieve bidirectional semantic alignment detection between test requirements and test cases, thus wasting computational resources.
[0005] According to one aspect of the embodiments of this application, an alignment detection method for test requirements and test cases is provided, comprising: rewriting an initial test requirement document and multiple initial test cases to obtain multiple atomic test requirements and multiple test cases; constructing a vector database based on all atomic test requirements and all test cases, and constructing a requirement index structure and a test case index structure based on the vector database, wherein the requirement index structure and the test case index structure are constructed based on a preset search algorithm, the requirement index structure is used to retrieve atomic test requirement vectors, and the test case index structure is used to retrieve test case vectors; performing alignment detection on all atomic test requirements and all test cases based on the requirement index structure and the test case index structure to obtain a detection result, wherein the alignment detection includes at least: forward detection and reverse detection, the forward detection is used to detect the coverage of each atomic test requirement based on all test cases, and the reverse detection is used to detect test cases that are not associated with any atomic test requirements.
[0006] Furthermore, the steps of rewriting the initial test requirement document and multiple initial test cases to obtain multiple atomic test requirements and multiple test cases include: cleaning the initial test requirement document to obtain a cleaned document, and dividing the cleaned document to obtain minimal semantic text; detecting whether each minimal semantic text is a text title; if the minimal semantic text is a text title, using the position of the minimal semantic text in the cleaned document as a split point to obtain multiple title texts; splitting and rewriting all texts to obtain atomic test requirements; and normalizing each initial test case to obtain test cases.
[0007] Further, the steps of segmenting and rewriting all text to obtain the atomic test requirements include: identifying each minimum semantic text except for the text title as the target semantic text; calculating the semantic similarity between any two target semantic texts, and segmenting the two target semantic texts corresponding to the semantic similarity in the text if the semantic similarity is less than a preset semantic threshold, to obtain the segmented text; and rewriting all the segmented texts to obtain the atomic test requirements.
[0008] Furthermore, the detection results include at least: positive detection results and negative detection results. The step of performing alignment detection on all atomic test requirements and all test cases based on the requirement index structure and the test case index structure to obtain the detection results includes: performing positive detection on all atomic test requirements and all test cases based on the requirement index structure and the test case index structure to obtain positive detection results; and performing negative detection on all atomic test requirements and all test cases based on the requirement index structure and the test case index structure to obtain negative detection results.
[0009] Furthermore, based on the requirement index structure and test case index structure, the steps for performing positive detection on all atomic test requirements and all test cases to obtain positive detection results include: traversing each atomic test requirement vector, determining multiple test case vectors based on the test case index structure, and identifying the test cases corresponding to each test case vector as candidate test cases; constructing a first prompt word template based on the atomic test requirements corresponding to the atomic test requirement vectors and all candidate test cases; and inputting the first prompt word template into the generative model for inference to obtain positive detection results. The generative model uses a self-attention mechanism to semantically encode the text in the first prompt word template and analyzes the semantic encoding to generate positive detection results.
[0010] Furthermore, based on the requirement index structure and test case index structure, the steps for performing negative detection on all atomic test requirements and all test cases to obtain negative detection results include: traversing each test case vector, determining multiple atomic test requirement vectors based on the requirement index structure, and identifying the atomic test requirement corresponding to each atomic test requirement vector as a candidate test requirement; constructing a second prompt word template based on the test cases corresponding to the test case vectors and all candidate test requirements; and inputting the second prompt word template into the generative model for inference to obtain negative detection results. The generative model uses a self-attention mechanism to semantically encode the text in the second prompt word template and analyzes the semantic encoding to generate negative detection results.
[0011] Furthermore, after performing alignment detection on all atomic test requirements and all test cases based on the requirement index structure and test case index structure, and obtaining the detection results, the process also includes: constructing a bidirectional semantic network graph based on the detection results, wherein the types of nodes in the bidirectional semantic network graph include at least atomic test requirements and test cases, and the types of edges in the bidirectional semantic network graph include at least semantic similarity and coverage score; analyzing the bidirectional semantic network graph to obtain analysis results; and generating modification strategies for atomic test requirements and test cases based on the analysis results.
[0012] According to another aspect of the embodiments of this application, an alignment detection device for test requirements and test cases is also provided, comprising: a rewriting unit, configured to rewrite an initial test requirement document and multiple initial test cases to obtain multiple atomic test requirements and multiple test cases; a construction unit, configured to construct a vector database based on all atomic test requirements and all test cases, and construct a requirement index structure and a test case index structure based on the vector database, wherein the requirement index structure and the test case index structure are constructed based on a preset search algorithm, the requirement index structure is used to retrieve atomic test requirement vectors, and the test case index structure is used to retrieve test case vectors; and a detection unit, configured to perform alignment detection on all atomic test requirements and all test cases based on the requirement index structure and the test case index structure to obtain a detection result, wherein the alignment detection includes at least: forward detection and reverse detection, the forward detection is used to detect the coverage of each atomic test requirement based on all test cases, and the reverse detection is used to detect test cases that are not associated with any atomic test requirements.
[0013] Furthermore, the rewriting unit includes: a first cleaning module, used to clean the initial test requirement document to obtain a cleaned document, and to divide the cleaned document to obtain minimal semantic text; a first detection module, used to detect whether each minimal semantic text is a text title; a first processing module, used to, when the minimal semantic text is a text title, use the position of the minimal semantic text in the cleaned document as a segmentation point to obtain text for multiple titles; a first rewriting module, used to segment and rewrite all text to obtain atomic test requirements; and a first normalization processing module, used to normalize each initial test case to obtain test cases.
[0014] Furthermore, the first rewriting module includes: a first determining submodule, used to determine each of the minimum semantic texts except for the text title as the target semantic text; a first calculation submodule, used to calculate the semantic similarity between any two target semantic texts, and if the semantic similarity is less than a preset semantic threshold, to segment the two target semantic texts corresponding to the semantic similarity in the text to obtain the segmented text; and a first rewriting submodule, used to rewrite all the segmented texts to obtain the atomic test requirements.
[0015] Furthermore, the detection results include at least: positive detection results and negative detection results. The detection unit includes: a second detection module, used to perform positive detection on all atomic test requirements and all test cases based on the requirement index structure and the test case index structure, to obtain positive detection results; and a third detection module, used to perform negative detection on all atomic test requirements and all test cases based on the requirement index structure and the test case index structure, to obtain negative detection results.
[0016] Furthermore, the second detection module includes: a second determination submodule, used to traverse each atomic test requirement vector, determine multiple test case vectors based on the test case index structure, and determine the test cases corresponding to each test case vector as candidate test cases; a first construction submodule, used to construct a first prompt word template based on the atomic test requirements corresponding to the atomic test requirement vector and all candidate test cases; and a first inference submodule, used to input the first prompt word template into the generative model for inference to obtain a positive detection result, wherein the generative model performs semantic encoding on the text in the first prompt word template through a self-attention mechanism, analyzes the semantic encoding, and generates a positive detection result.
[0017] Furthermore, the third detection module includes: a third determination submodule, used to traverse each test case vector, determine multiple atomic test requirement vectors based on the requirement index structure, and determine the atomic test requirement corresponding to each atomic test requirement vector as a candidate test requirement; a second construction submodule, used to construct a second prompt word template based on the test cases corresponding to the test case vectors and all candidate test requirements; and a second inference submodule, used to input the second prompt word template into the generative model for inference to obtain negative detection results. The generative model performs semantic encoding on the text in the second prompt word template through a self-attention mechanism, analyzes the semantic encoding, and generates negative detection results.
[0018] Furthermore, the alignment detection device for test requirements and test cases also includes: a first construction module, used to perform alignment detection on all atomic test requirements and all test cases based on the requirement index structure and the test case index structure, and after obtaining the detection results, construct a bidirectional semantic network graph based on the detection results, wherein the types of nodes in the bidirectional semantic network graph include at least: atomic test requirements and test cases, and the types of edges in the bidirectional semantic network graph include at least: semantic similarity and coverage score; a first analysis module, used to analyze the bidirectional semantic network graph and obtain analysis results; and a first generation module, used to generate modification strategies for atomic test requirements and test cases based on the analysis results.
[0019] According to another aspect of the embodiments of this application, a computer program product is also provided, including a non-volatile computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the alignment detection method for any of the above-mentioned test requirements and test cases.
[0020] According to another aspect of the embodiments of this application, an electronic device is also provided, including one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors cause the one or more processors to implement any of the above-described alignment detection methods for test requirements and test cases.
[0021] In this invention, the initial test requirement document and multiple initial test cases are rewritten to obtain multiple atomic test requirements and multiple test cases. Based on all atomic test requirements and all test cases, a vector database is constructed, and based on the vector database, a requirement index structure and a test case index structure are constructed. Based on the requirement index structure and the test case index structure, alignment detection is performed on all atomic test requirements and all test cases to obtain the detection results. The alignment detection includes at least: forward detection and reverse detection. Forward detection is used to detect the coverage of each atomic test requirement based on all test cases, and reverse detection is used to detect test cases that are not associated with any atomic test requirements. This solves the technical problem in related technologies that it is impossible to achieve bidirectional semantic alignment detection between test requirements and test cases, which wastes computing resources.
[0022] In this invention, the initial test requirement document and multiple initial test cases are semantically parsed and structurally rewritten to extract and generate a series of semantically clear and logically independent atomic test requirements and standardized test cases. Based on all atomic test requirements and standardized test cases, a semantic encoding model finely tuned from a software engineering corpus is used for semantic encoding to generate corresponding dense vector representations, and a unified vector database is constructed. Further, based on this vector database, a requirement index structure and a test case index structure are constructed, respectively. Both the requirement index structure and the test case index structure are established using a preset approximate nearest neighbor search algorithm to achieve efficient retrieval of atomic test requirement vectors and test case vectors. Then, based on the above bidirectional index structure, all atomic... Test requirements and all test cases undergo bidirectional alignment checks, which include forward coverage analysis and reverse validity verification. Forward checks involve traversing each atomic test requirement, retrieving the set of candidate test cases with the closest semantics in the test case index structure, and using retrieval enhancement generation and thought chain reasoning mechanisms to determine whether the requirement is adequately covered. Reverse checks involve traversing each test case, retrieving potentially related atomic test requirements in the requirement index structure. If the semantic similarity of a test case with all existing requirements is below a preset threshold, or if the large language model determines that its verification logic has no corresponding basis in the requirement document, it is identified as an unrelated test case. This achieves dual verification and closed-loop evaluation of the completeness of requirement coverage and the validity of test assets. Attached Figure Description
[0023] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this invention, illustrate exemplary embodiments of the invention and are used to explain the invention, but do not constitute an undue limitation of the invention. In the drawings:
[0024] Figure 1A hardware structure block diagram of a computer terminal (or mobile device) for implementing an alignment detection method for test requirements and test cases is shown.
[0025] Figure 2 This is a flowchart of the alignment detection method between test requirements and test cases according to Embodiment 1 of this application;
[0026] Figure 3 This is a schematic diagram of a system architecture for an optional alignment detection method for test requirements and test cases according to an embodiment of this application;
[0027] Figure 4 This is a flowchart of an optional alignment detection of test requirements and test cases according to an embodiment of this application;
[0028] Figure 5 This is a schematic diagram of an optional test requirement and test case alignment detection device according to an embodiment of this application;
[0029] Figure 6 This is a structural block diagram of an electronic device according to an embodiment of this application. Detailed Implementation
[0030] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0031] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0032] It should be noted that all related information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, and displayed data) collected and involved in this invention are information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of related data all comply with the relevant laws, regulations, and standards of the relevant regions, and necessary confidentiality measures have been taken. These measures do not violate public order and good morals, and corresponding operation entry points are provided for users to choose to authorize or refuse. For example, this system has an interface with relevant users or organizations. Before obtaining relevant information, a request to obtain the information needs to be sent to the aforementioned user or organization through the interface. After receiving consent from the aforementioned user or organization, the relevant information is obtained. If the user chooses to refuse, the process proceeds to an expert decision-making process.
[0033] In this invention, by transforming unstructured documents into standardized atomic propositions, matching requirements and test case intent is achieved. This not only identifies the semantic equivalence of similar statements but also distinguishes the essential differences between "block registration" (negative path) and "registration successful" (positive path) through logical reasoning, reducing false positive and false negative rates and preventing a large number of invalid links due to a lack of semantic understanding. In current software engineering, the maintenance of requirement sourcing matrices is often manual and lagging, and is prone to failure with the rapid iteration of agile development. This invention constructs an end-to-end automated pipeline from unstructured document parsing, vectorized indexing, bidirectional retrieval to coverage determination. It not only outputs a quantitative similarity score but, more importantly, generates a natural language analysis explanation and a clear list of coverage gaps (e.g., "This test case only verified normal input and lacked verification of password length boundary values"). Without the need for manual maintenance of large tables, analysis is automatically triggered upon code submission or requirement update, transforming the maintenance of the requirement sourcing matrix from "labor-intensive" to "computation-intensive," significantly reducing labor costs and ensuring the real-time nature of sourcing data. Meanwhile, instead of full fine-tuning, a retrieval-enhanced generation architecture is adopted. When SRS documents change, only incremental updates to the vector database are needed through the atomic and vectorization modules. This decouples the knowledge base from the reasoning capabilities, enabling seamless integration into the pipeline and adapting to scenarios with frequent changes in requirements during agile development.
[0034] The present invention will now be described in detail with reference to various embodiments.
[0035] Example 1
[0036] According to an embodiment of this application, an embodiment of a method for aligning test requirements and test cases is also provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0037] The method embodiment provided in Embodiment 1 of this application can be executed on a mobile terminal, computer terminal, or similar computing device. Figure 1 A hardware block diagram of a computer terminal (or mobile device) for implementing an alignment detection method between test requirements and test cases is shown. Figure 1 As shown, computer terminal 10 (or mobile device) may include one or more ( Figure 1 The processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions may also be included. In addition, it may include: a display, a keyboard, a cursor control device, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of a BUS bus), a network interface, a power supply, and / or a camera, wherein the network interface can be connected to wired and / or wireless networks. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0038] It should be noted that the aforementioned one or more processors 102 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 10 (or mobile device). As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).
[0039] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the alignment detection method of test requirements and test cases in the embodiments of this application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby realizing the above-mentioned alignment detection method of test requirements and test cases. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the computer terminal 10 via a network. Examples of the above-mentioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0040] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0041] The display may be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 10 (or mobile device).
[0042] Under the aforementioned operating environment, this application provides the following: Figure 2 The method for aligning test requirements with test cases is shown. Figure 2 This is a flowchart of the alignment detection method between test requirements and test cases according to Embodiment 1 of this application, as shown below. Figure 2 As shown, the method includes the following steps:
[0043] Step S201: Rewrite the initial test requirement document and multiple initial test cases to obtain multiple atomic test requirements and multiple test cases.
[0044] In this embodiment of the invention, the initial test requirement document is an unprocessed raw SRS document, containing colloquial, vague, and complex logical natural language descriptions, resulting in poor quality and a messy structure. Initial test cases are historically accumulated test cases with inconsistent formats, containing user interface operation details, and non-standard semantics. Atomic test requirements are the smallest semantically independent requirement units rewritten using EARS (Easy Approach to Requirements Syntax), formatted as "While / When / The System Shall...". Test cases are standardized test descriptions that have undergone normalization, removing fine-grained user interface operations while retaining business logic.
[0045] In this embodiment of the invention, a large language model combined with EARS syntax can be used to perform semantic parsing, decomposition, standardization, and completion of subjects and constraints on the initial test requirement document, thereby eliminating semantic noise and rewriting the initial test requirement document to obtain multiple atomic test requirements. Furthermore, each initial test case can be standardized to obtain test cases.
[0046] For example, the following instruction can be sent to the large language model: "Please break down the following natural language description into multiple independent atomic requirements and rewrite them strictly using EARS syntax. The natural language description is: The system should allow new users to register with an email address. The large language model output (normalized RU) is: RU-001 (Function): When a new user submits a valid email and a compliant password, the System shall create a new user account. RU-002 (Constraint): When a user submits an email with an invalid format, the System shall reject the registration request. RU-003 (Constraint): When a user submits a password shorter than 8 characters, the System shall display a 'Password too short' error. RU-004 (Exception): When a user submits an email that already exists in the database, the System shall display a 'User already exists' error."
[0047] Alternatively, subject-verb-object structures can be extracted based on rules, regular expressions, or syntactic dependency parsing trees. However, this method has extremely low implementation costs, is fully interpretable, cannot handle unstructured or natural language-described documents, and has poor generalization ability.
[0048] Step S202: Based on all atomic test requirements and all test cases, construct a vector database, and based on the vector database, construct a requirement index structure and a test case index structure. The requirement index structure and the test case index structure are constructed based on a preset search algorithm. The requirement index structure is used to retrieve atomic test requirement vectors, and the test case index structure is used to retrieve test case vectors.
[0049] In this embodiment of the invention, a pre-trained semantic embedding model (e.g., a general text embedding model or a model fine-tuned with software engineering corpus) can be used to vectorize and encode atomic test requirements and test cases respectively, generating high-dimensional dense vector representations to obtain a vector database. To further alleviate the matching difficulties caused by semantically similar but significantly different expressions, a contrastive learning strategy can be introduced during the semantic embedding model fine-tuning stage. By constructing positive and negative sample pairs between requirements and test cases, semantically related texts become closer in the vector space, while irrelevant texts maintain sufficient distinguishability. Then, based on a preset search algorithm (e.g., HNSW (Hierarchical Navigable Small World, a graph structure indexing algorithm for efficient approximate nearest neighbor retrieval)), a requirement index and a test case index can be constructed on the vectors in the vector database to establish a bidirectional index structure (i.e., a requirement index structure and a test case index structure), which can improve retrieval accuracy and speed. For example, all atomic test requirement vectors can be stored in Index_RU (requirement index structure), and all test case vectors can be stored in Index_TC (test case index structure). Based on Index_TC, the test case "closest to the semantics of the atomic test requirement" can be quickly retrieved, and based on Index_RU, the requirement "most likely associated with the semantics of the test case" can be quickly retrieved.
[0050] Optionally, when dealing with requirements containing specific error codes, proper nouns, or abbreviations, a hybrid retrieval strategy can be adopted, combining dense vector retrieval (i.e., performing nearest neighbor search in the vector space through similarity (e.g., cosine similarity, Euclidean distance, dot product, etc.) to capture semantic equivalence relationships (e.g., "login" and "authentication")) and sparse vector retrieval (a retrieval method based on word frequency statistics) for keyword matching, and finally performing weighted merging through a reciprocal ranking fusion algorithm.
[0051] Step S203: Based on the requirement index structure and the test case index structure, perform alignment detection on all atomic test requirements and all test cases to obtain the detection results. The alignment detection includes at least: forward detection and reverse detection. Forward detection is used to detect the coverage of each atomic test requirement based on all test cases, and reverse detection is used to detect test cases that are not associated with any atomic test requirements.
[0052] Optionally, two parallel processes can be executed: forward coverage analysis (i.e., forward detection) and reverse validity analysis (i.e., reverse detection) to achieve bidirectional alignment detection between requirements and tests. In forward coverage analysis, for each atomic test requirement vector, the set of candidate test cases corresponding to the most semantically similar candidate test case vector is retrieved from the test case index. Then, a large language model is used as the decision maker to perform joint reasoning on the atomic test requirements and candidate test cases. Unlike coarse-grained matching that only relies on vector similarity, this mechanism can simulate the analysis process of experts, judging the sufficiency of test cases in covering atomic test requirements from dimensions such as functional path, boundary conditions, and abnormal scenarios, and outputting a quantitative coverage score and a specific description of test gaps.
[0053] In reverse validity analysis, starting with test cases, the potential corresponding requirements in the requirement index are retrieved, and the large language model determines whether the test truly verifies a certain atomic test requirement. For test cases that cannot establish a credible semantic association with any requirement, they can be marked as "unrelated test cases" (i.e. test cases with a semantic similarity to any requirement below a preset threshold). Furthermore, it can identify whether there are any functions that are not defined in the atomic test requirements and generate improvement suggestions.
[0054] Alternatively, a small model specifically trained on a natural language inference dataset can be used, taking the requirement as a "premise" and the test cases as "hypotheses," predicting whether the relationship is "implied," "contradictory," or "neutral." This approach is suitable for private deployments due to its low inference latency, inability to perform complex logical boundary analysis, and inability to generate improvement suggestions.
[0055] Figure 3 This is a schematic diagram of a system architecture for an optional alignment detection method for test requirements and test cases according to an embodiment of this application, such as... Figure 3As shown, it mainly includes four modules: intelligent preprocessing and standardization module, bidirectional vector index construction module, bidirectional alignment inference engine, and difference diagnosis and closed-loop feedback module. The intelligent preprocessing and standardization module first performs document parsing and cleaning, then uses a large language model for semantic segmentation and structural inheritance (i.e., preserving chapter levels (e.g., "3.1 Security"), inheriting parent node constraints (e.g., "All operations require authentication") to child nodes, and using prompt words to identify independent logic within paragraphs), and rewriting unstructured SRS text into atomic test requirements (i.e., standard atomic requirements). For example, "The system supports login, and locks after 3 failed attempts" is broken down into: RU_01 (Login): The user can enter the system by entering the correct credentials. RU_02 (Lock): Account lock is triggered after 3 consecutive failures. The large language model automatically completes the omitted subjects for independent logic, corrects ambiguous expressions, and generates standard atomic requirements. It can also standardize original test cases in the historical test case library to obtain standardized test cases. The bidirectional vector index building module can map standardized data to a high-dimensional vector space: First, two independent index structures are established, such as a requirement index and a use case index. At the same time, an embedding model fine-tuned by the software engineering corpus can be used to make "login" and "authentication" close in the vector space. The bidirectional aligned inference engine can perform a dual verification process: forward analysis (coverage detection) and reverse analysis (irrelevant test case identification). Forward analysis checks whether a requirement has been detected (i.e., whether it is fully covered by at least one test case). By traversing each standard atomic requirement and using the semantic vector of that requirement as the query, the top-K candidate test case vectors are retrieved in the test case index structure. The candidate test cases corresponding to each candidate test case vector can be determined. The decision maker analyzes whether the steps and expected results of each candidate test case logically imply the functional points and constraints of the requirement. Reverse analysis checks the validity of the test cases and the completeness of the requirements. By traversing each standardized test case and using the semantic vector of that test case as the query, the top-K candidate requirement vectors are retrieved in the requirement index structure. The decision maker determines whether the standardized test case belongs to the verification range of any candidate requirement vector. That is, if the semantic similarity of a standardized test case with all candidate requirement vectors is lower than the threshold, or the decision maker determines that its test logic has no corresponding description in the SRS, it is marked as an irrelevant test case. The difference diagnosis and feedback module is used to generate actionable improvement suggestions and quality reports based on the coverage gap analysis and unrelated use case reports output by the decision maker.
[0056] In summary, firstly, a large language model combined with EARS grammar is used to standardize and rewrite ambiguous original requirement documents and test cases, generating clearly structured and semantically independent atomic test requirements and standardized test cases, eliminating linguistic ambiguity. Then, based on a fine-tuned semantic embedding model and the HNSW algorithm, requirement index structures and test case index structures are constructed respectively, improving semantic retrieval speed. Finally, a bidirectional alignment detection mechanism is used—forward detection evaluates the coverage completeness of each atomic test requirement based on test cases, and backward detection identifies unrelated test cases that have no semantic connection to any requirement. The large language model, combined with thought chain reasoning, generates executable gap analysis and cleanup suggestions, thus solving the technical problem of wasted computational resources in related technologies that cannot achieve bidirectional semantic alignment detection between test requirements and test cases.
[0057] To accurately obtain atomic test requirements and test cases, the alignment detection method for test requirements and test cases provided in Embodiment 1 of this application involves cleaning the initial test requirement document to obtain a cleaned document, dividing the cleaned document into minimal semantic texts, detecting whether each minimal semantic text is a text title, using the position of the minimal semantic text in the cleaned document as a segmentation point to obtain multiple title texts, segmenting and rewriting all texts to obtain atomic test requirements, and normalizing each initial test case to obtain test cases.
[0058] In this embodiment of the invention, the SRS document and historical test case library can be accessed via application programming interface or file stream, and a unified data cleaning operation can be performed, such as automatically removing headers and footers, version control tables, semantically meaningless placeholders, and redundant formatting tags. For requirement descriptions containing non-textual information such as flowcharts and screenshots, OCR (Optical Character Recognition) technology and multimodal large model can be used to parse the text and logical relationships in the images and convert them into supplementary explanatory text, thereby obtaining a cleaned document.
[0059] The cleaned document can be divided into sections. It's important to note that this division differs from segmentation. The purpose is to distinguish each paragraph within the document, obtaining the minimum semantic text (e.g., comma-separated or period-separated statements). This is used to calculate the similarity between statements. Then, it's checked whether each minimum semantic text is a text title (e.g., starting with characters like "3.1" or "4.2," or a bolded, centered paragraph). If the minimum semantic text is a text title, the document is divided into multiple title-level texts. For example, "3.1 Security" can be used as the title, and all paragraphs under it can be considered sub-texts of that title. The purpose is to inherit constraints from the parent node (e.g., the text description "All operations require authentication" under the 3.1 section title) to the child nodes (i.e., all sub-texts under that section). In this case, authentication is a general requirement; all statements under that section need to undergo authentication, improving the semantic context integrity. Finally, by segmenting and rewriting all the text, the atomic test requirements are obtained.
[0060] Because test cases have inconsistent styles, they can be standardized by extracting the title, execution steps, and expected results from the test cases and combining them into a semantically complete test description. At the same time, user interface operation information that is irrelevant to business logic is removed to generate a standardized test case representation, thereby ensuring that requirements and tests are comparable at the semantic level.
[0061] To improve the accuracy of atomic test requirements, in the alignment detection method between test requirements and test cases provided in Embodiment 1 of this application, each minimum semantic text other than the text title is determined as a target semantic text; the semantic similarity between any two target semantic texts is calculated, and if the semantic similarity is less than a preset semantic threshold, the two target semantic texts corresponding to the semantic similarity are segmented in the text to obtain the segmented text; all segmented texts are rewritten to obtain the atomic test requirements.
[0062] In this embodiment of the invention, unlike the method of segmenting text by a fixed length, this embodiment can determine semantic continuity by calculating the semantic vector similarity of adjacent sentences or paragraphs.
[0063] By calculating the semantic similarity of all target semantic texts pairwise, when the similarity between any two adjacent target semantic texts is lower than a preset semantic threshold (e.g., 0.45), it can be determined that a semantic topic jump has occurred between them, that is, a transition from one functional point to another independent functional point. At this time, a segmentation marker is inserted at the natural break point between the two, splitting the original continuous text into two independent segmented texts. For example, the original paragraph: "The system supports email login, and the account is locked after three failed login attempts. At the same time, users can modify personal information, such as avatar and nickname." The semantic similarity between the two paragraphs "The system supports email login, and the account is locked after three failed login attempts" and "At the same time, users can modify personal information, such as avatar and nickname" is calculated to be 0.32, which is lower than the preset semantic threshold. Therefore, it can be segmented before "at the same time" to obtain two independent texts (i.e., the segmented texts). Then, the large language model is called, combined with a few-sample prompting strategy, to uniformly rewrite the vague, complex, or colloquial requirement descriptions into atomic requirement units (i.e., atomic test requirements) that conform to the EARS specification. Specifically, the model is constrained to express requirements in a standard sentence structure: "While (precondition), When (triggering event), The system shall (system response)". When a requirement contains multiple logical judgments (such as "and" or "or"), it can be automatically broken down into multiple independent atomic test requirements. Ultimately, each atomic test requirement can be assigned a unique identifier and associated with its source text and key semantic entities, providing a data foundation for subsequent source tracing analysis.
[0064] The detection results include at least positive detection results and negative detection results. In order to accurately obtain negative detection results, in the alignment detection method of test requirements and test cases provided in Embodiment 1 of this application, positive detection is performed on all atomic test requirements and all test cases based on the requirement index structure and the test case index structure to obtain positive detection results; negative detection is performed on all atomic test requirements and all test cases based on the requirement index structure and the test case index structure to obtain negative detection results.
[0065] In this embodiment of the invention, a dual verification process (i.e., alignment detection is performed on atomic test requirements and test cases) can be executed. The detection results include at least positive detection results and negative detection results. To ensure the accuracy of negative detection results, an independent and parallel dual-path reasoning mechanism can be adopted to execute positive detection and negative detection separately, avoiding mutual interference and improving the reliability of detection.
[0066] To accurately generate positive detection results, in the alignment detection method for test requirements and test cases provided in Embodiment 1 of this application, each atomic test requirement vector is traversed, and multiple test case vectors are determined based on the test case index structure. The test cases corresponding to each test case vector are determined as candidate test cases. Based on the atomic test requirements corresponding to the atomic test requirement vectors and all candidate test cases, a first prompt word template is constructed. The first prompt word template is input into the generative model for inference to obtain positive detection results. The generative model performs semantic encoding on the text in the first prompt word template through a self-attention mechanism and analyzes the semantic encoding to generate positive detection results.
[0067] In this embodiment of the invention, for each atomic test requirement, an approximate nearest neighbor search is performed in the test case index structure. This retrieves the K semantically closest (e.g., K=5) test case vectors, and the test case corresponding to each test case vector is determined as a candidate test case. Approximate nearest neighbor search avoids full database matching, improving search efficiency. Then, for each atomic test requirement and its corresponding multiple candidate test cases, a first prompt word template can be dynamically constructed, and a generative model can be called for logical reasoning to obtain a positive detection result. The positive detection result includes at least: reasoning steps and coverage score. For example, atomic test requirement: RU-003 (password shorter than 8 characters should report an error), candidate test case: TC-REG-01 (verification of successful registration process, password length 11 characters), the first prompt word template could be: determining whether the candidate test case covers the boundary conditions of the atomic test requirement. The generative model can perform inference, with the following steps: "TC-REG-01 verifies the Happy Path (successful path), and the password it uses, password123, meets the length requirement. This candidate test case did not attempt to input a password shorter than 8 characters to verify the system's rejection behavior." Therefore, the coverage score is: Coverage Score: 0, indicating a missing negative test case for the password length boundary value. It can also generate a detection report, marking RU-003 in red (uncovered) and automatically generating a suggestion: Suggested supplementary test case: Input a 7-digit password and verify whether the system displays an error message.
[0068] Alternatively, a dataset of triples consisting of requirements, use cases, and coverage labels can be constructed, and a dual-tower model or cross-encoder (such as BERT (Bidirectional Encoder Representations from Transformers) or RoBERTa (Robustly Optimized BERT Pretraining Approach)) can be fine-tuned. This encoder concatenates the requirements and use cases as input and directly outputs a coverage probability value for a given interval. This approach offers faster inference speed and lower computational cost, but lacks the ability to generate natural language justifications and gap descriptions, and its generalization ability to new domain data is weak.
[0069] To accurately generate negative detection results, in the alignment detection method for test requirements and test cases provided in Embodiment 1 of this application, each test case vector is traversed, and multiple atomic test requirement vectors are determined based on the requirement index structure. The atomic test requirement corresponding to each atomic test requirement vector is determined as a candidate test requirement. Based on the test cases corresponding to the test case vectors and all candidate test requirements, a second prompt word template is constructed. The second prompt word template is input into the generative model for inference to obtain negative detection results. The generative model performs semantic encoding on the text in the second prompt word template through a self-attention mechanism and analyzes the semantic encoding to generate negative detection results.
[0070] In this embodiment of the invention, each test case vector is traversed, and the K atomic test requirement vectors with the closest semantics are retrieved in the requirement index structure. The atomic test requirement corresponding to each atomic test requirement vector is determined as a candidate test requirement. Similarly, for each test case and its corresponding multiple candidate test requirements, a second prompt word template is dynamically constructed, and a generative model is called to perform reasoning to obtain a negative detection result. The negative detection result includes at least: reasoning steps and judgment result.
[0071] For example, consider this scenario: a financial software version 2.0 changed the "SMS verification code login" function to "QR code login" and "biometric login," but the test library still contains a large number of old SMS-related test cases. For instance, test case TC-SMS-05 states: "The SMS verification code expires after 60 seconds; the user needs to click the resend button." In this case, the latest test requirements document can be loaded to build a new requirements index structure. This new index structure no longer contains any atomic test requirements related to "SMS" or "verification code." Based on the test case vector of the test case to be tested, the most similar atomic test requirement found in the requirement index structure is RU-LOGIN-02 (user login with password), but the semantic similarity is only 0.35 (below the set effective threshold, such as 0.6). At this time, the second prompt word template can be: "Test case: Verify SMS verification code resending after expiration, related requirement: user login with password. Determine whether this test case is a necessary step to verify the test requirement." The generative model reasoning steps are: "The requirement only describes password login and does not mention the SMS verification code process. The test case tests a functional interaction that does not exist in the requirement (SMS expiration logic)". The judgment result is: Orphan Case (an unrelated test case), and the test case TC-SMS-05 is marked as gray (recommended to delete or abandon) in the detection report, with the reason: the function has been removed from the current version of the requirement and is an invalid test asset.
[0072] Optionally, in cases where there are incremental or reduction requirements, incremental insertions or deletions can be performed on the requirement index structure.
[0073] To accurately generate modification strategies, in the alignment detection method for test requirements and test cases provided in Embodiment 1 of this application, a bidirectional semantic network graph is constructed based on the detection results. The types of nodes in the bidirectional semantic network graph include at least atomic test requirements and test cases, and the types of edges in the bidirectional semantic network graph include at least semantic similarity and coverage score. The bidirectional semantic network graph is analyzed to obtain analysis results. Based on the analysis results, modification strategies for atomic test requirements and test cases are generated.
[0074] Optionally, semantic similarity represents the numerical similarity between test cases and atomic test requirements in the vector space, and coverage score is a quantitative evaluation derived from generative model inference.
[0075] In this embodiment of the invention, forward and reverse detection results can be uniformly summarized to construct a bidirectional correlation matrix between requirements and tests (this matrix is not a sparse binary table, but a complex semantic network graph with weights (semantic similarity, coverage score), i.e., a bidirectional semantic network graph, or a semantic-level topological structure), and the overall quality status can be presented through visualization and statistical analysis. Specifically, a coverage heatmap with requirements and tests as the axis can be generated to intuitively reflect the coverage intensity of different areas. At the same time, combined with the analysis results of the bidirectional correlation matrix, an actionable list of improvement suggestions (i.e., modification strategies) can be automatically generated, including test points that need to be added and redundant test cases that are suggested to be cleaned up. Defect reports and optimization suggestions can be generated and can be directly synchronized to the R&D management system to form a closed-loop feedback mechanism from analysis to execution.
[0076] Figure 4 This is a flowchart illustrating an optional alignment detection method for test requirements and test cases according to an embodiment of this application, such as... Figure 4As shown, the process can be divided into four consecutive stages: intelligent preprocessing and standardization, bidirectional vector space construction, end-to-end bidirectional traceability analysis, and dynamic feedback and result report generation. Each stage is connected via a standardized intermediate representation, gradually mapping unstructured natural language requirements and test assets into computable, reasonable, and auditable analytical objects. First, the intelligent preprocessing and standardization stage accesses the SRS document (i.e., the original test document) and test case library through API (Application Programming Interface) interfaces or file streams, and cleans the original test document and test library data. After basic cleaning, a dynamic segmentation mechanism based on semantic density is further used to segment the documents. Through an atomic rewriting mechanism based on EARS syntax, a large language model is invoked, and a few-shot prompting strategy is combined to uniformly rewrite ambiguous, complex, or colloquial requirement descriptions into atomic requirement units that conform to the EARS specification. Considering that test cases also have inconsistent styles, test cases can also be standardized. After standardization, domain-adaptive vector embedding is first performed. Then, requirement indexes and test case indexes are built in the vector database to establish a bidirectional index structure. Supported by a unified vector space, two parallel processes, forward coverage analysis and reverse validity analysis, are executed. The decision maker determines coverage and unrelated test cases to achieve bidirectional alignment between requirements and tests. Subsequently, the positive coverage results and negative validity judgments are uniformly summarized to construct a two-way correlation matrix between requirements and testing. The overall quality status is presented through visualization and statistical analysis. At the same time, an actionable improvement suggestion list is automatically generated based on the analysis results, including test points that need to be added and redundant test cases that are suggested to be cleaned up. Defect reports and optimization suggestions are generated and directly synchronized to the R&D management system to form a closed-loop feedback mechanism from analysis to execution.
[0077] For example, the input-output relationship of each stage is shown in Table 1.
[0078] Table 1
[0079]
[0080] The alignment detection method for test requirements and test cases provided in this application firstly eliminates text noise through dynamic segmentation and reconstruction based on semantic similarity, and then standardizes ambiguous requirements and test cases into atomic test requirements and standardized test cases using a large language model. Next, a bidirectional vector index structure is constructed, and positive coverage detection and negative validity detection are performed respectively through a generative model combined with a self-attention mechanism to accurately identify coverage gaps and unrelated test cases. Finally, a bidirectional semantic network graph is constructed based on the detection results, automatically analyzing the quality situation and generating executable modification strategies. This achieves bidirectional semantic alignment and closed-loop optimization of requirements and tests, improves the quality of test assets, and saves computational resources by reducing the execution of invalid test cases.
[0081] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0082] Example 2
[0083] This application also provides an alignment detection device for test requirements and test cases. It should be noted that this alignment detection device can be used to execute the alignment detection method for test requirements and test cases provided in this application. The alignment detection device for test requirements and test cases provided in this application will be described below.
[0084] According to an embodiment of this application, an apparatus for implementing the above-described alignment detection method for test requirements and test cases is also provided. Figure 5 This is a schematic diagram of an optional alignment detection device for test requirements and test cases according to an embodiment of this application, as shown below. Figure 5 As shown, the alignment detection device between the test requirements and test cases may include: a rewrite unit 50, a construction unit 51, and a detection unit 52.
[0085] Among them, the rewriting unit 50 is used to rewrite the initial test requirement document and multiple initial test cases to obtain multiple atomic test requirements and multiple test cases.
[0086] Building unit 51 is used to build a vector database based on all atomic test requirements and all test cases, and to build a requirement index structure and a test case index structure based on the vector database. The requirement index structure and the test case index structure are built based on a preset search algorithm. The requirement index structure is used to retrieve atomic test requirement vectors, and the test case index structure is used to retrieve test case vectors.
[0087] The detection unit 52 is used to perform alignment detection on all atomic test requirements and all test cases based on the requirement index structure and the test case index structure to obtain the detection results. The alignment detection includes at least forward detection and reverse detection. Forward detection is used to detect the coverage of each atomic test requirement based on all test cases, and reverse detection is used to detect test cases that are not associated with any atomic test requirements.
[0088] The alignment detection device for test requirements and test cases provided in this application embodiment can rewrite the initial test requirement document and multiple initial test cases through the rewriting unit 50 to obtain multiple atomic test requirements and multiple test cases. It can construct a vector database based on all atomic test requirements and all test cases through the construction unit 51, and construct a requirement index structure and a test case index structure based on the vector database. It can then perform alignment detection on all atomic test requirements and all test cases based on the requirement index structure and the test case index structure to obtain the detection result.
[0089] Optionally, the rewriting unit 50 includes: a first cleaning module, used to clean the initial test requirement document to obtain a cleaned document, and to divide the cleaned document to obtain minimal semantic text; a first detection module, used to detect whether each minimal semantic text is a text title; a first processing module, used to, when the minimal semantic text is a text title, use the position of the minimal semantic text in the cleaned document as a segmentation point to obtain text for multiple titles; a first rewriting module, used to segment and rewrite all text to obtain atomic test requirements; and a first normalization processing module, used to normalize each initial test case to obtain test cases.
[0090] Optionally, the first rewriting module includes: a first determining submodule, used to determine each of the minimum semantic texts except for the text title as the target semantic text; a first calculating submodule, used to calculate the semantic similarity between any two target semantic texts, and if the semantic similarity is less than a preset semantic threshold, to segment the two target semantic texts corresponding to the semantic similarity in the text to obtain the segmented text; and a first rewriting submodule, used to rewrite all the segmented texts to obtain the atomic test requirements.
[0091] Optionally, the detection results include at least: positive detection results and negative detection results. The detection unit 52 includes: a second detection module, used to perform positive detection on all atomic test requirements and all test cases based on the requirement index structure and the test case index structure, to obtain positive detection results; and a third detection module, used to perform negative detection on all atomic test requirements and all test cases based on the requirement index structure and the test case index structure, to obtain negative detection results.
[0092] Optionally, the second detection module includes: a second determination submodule, used to traverse each atomic test requirement vector, determine multiple test case vectors based on the test case index structure, and determine the test cases corresponding to each test case vector as candidate test cases; a first construction submodule, used to construct a first prompt word template based on the atomic test requirements corresponding to the atomic test requirement vector and all candidate test cases; and a first inference submodule, used to input the first prompt word template into the generative model for inference to obtain a positive detection result, wherein the generative model performs semantic encoding on the text in the first prompt word template through a self-attention mechanism, analyzes the semantic encoding, and generates a positive detection result.
[0093] Optionally, the third detection module includes: a third determination submodule, used to traverse each test case vector, determine multiple atomic test requirement vectors based on the requirement index structure, and determine the atomic test requirement corresponding to each atomic test requirement vector as a candidate test requirement; a second construction submodule, used to construct a second prompt word template based on the test cases corresponding to the test case vectors and all candidate test requirements; and a second inference submodule, used to input the second prompt word template into the generative model for inference to obtain a negative detection result, wherein the generative model performs semantic encoding on the text in the second prompt word template through a self-attention mechanism, analyzes the semantic encoding, and generates a negative detection result.
[0094] Optionally, the alignment detection device for test requirements and test cases further includes: a first construction module, used to perform alignment detection on all atomic test requirements and all test cases based on the requirement index structure and the test case index structure, and after obtaining the detection results, construct a bidirectional semantic network graph based on the detection results, wherein the types of nodes in the bidirectional semantic network graph include at least: atomic test requirements and test cases, and the types of edges in the bidirectional semantic network graph include at least: semantic similarity and coverage score; a first analysis module, used to analyze the bidirectional semantic network graph and obtain analysis results; and a first generation module, used to generate modification strategies for atomic test requirements and test cases based on the analysis results.
[0095] The above-mentioned test requirement and test case alignment detection device may also include a processor and a memory. The above-mentioned rewrite unit 50, construction unit 51, detection unit 52, etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize the corresponding functions.
[0096] The aforementioned processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured. By adjusting kernel parameters, alignment checks are performed on all atomic test requirements and all test cases based on the requirement index structure and test case index structure to obtain the check results. The alignment checks include at least two methods: forward checking and backward checking. Forward checking is used to check the coverage of each atomic test requirement based on all test cases, while backward checking is used to detect test cases that are not associated with any of the atomic test requirements.
[0097] The aforementioned memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0098] It should be noted that the rewriting unit 50, the construction unit 51, and the detection unit 52 mentioned above correspond to steps S201 to S203 in Embodiment 1. The instances and application scenarios implemented by the above units and the corresponding steps are the same, but are not limited to the content disclosed in Embodiment 1. It should be noted that the above units can be hardware or software components stored in memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b, ..., 102n). The above units can also be part of a device and run in the computer terminal 10 provided in Embodiment 1.
[0099] Example 3
[0100] Embodiments of this application may provide a computer terminal, which may be any computer terminal device in a group of computer terminals. Optionally, in this embodiment, the aforementioned computer terminal may also be replaced with a mobile terminal or an electronic device, etc.
[0101] Optionally, in this embodiment, the computer terminal may be located in at least one of a plurality of network devices in a computer network.
[0102] In this embodiment, the aforementioned computer terminal can execute the program code for the following steps in the alignment detection method for test requirements and test cases: rewriting the initial test requirement document and multiple initial test cases to obtain multiple atomic test requirements and multiple test cases; constructing a vector database based on all atomic test requirements and all test cases, and constructing a requirement index structure and a test case index structure based on the vector database, wherein the requirement index structure and the test case index structure are constructed based on a preset search algorithm, the requirement index structure is used to retrieve atomic test requirement vectors, and the test case index structure is used to retrieve test case vectors; performing alignment detection on all atomic test requirements and all test cases based on the requirement index structure and the test case index structure to obtain detection results, wherein the alignment detection includes at least: forward detection and reverse detection, the forward detection is used to detect the coverage of each atomic test requirement based on all test cases, and the reverse detection is used to detect test cases that are not associated with any atomic test requirements.
[0103] Optionally, the aforementioned computer terminal can execute the program code for the following steps in the alignment detection method between test requirements and test cases: cleaning the initial test requirement document to obtain a cleaned document, and dividing the cleaned document to obtain minimal semantic text; detecting whether each minimal semantic text is a text title; if the minimal semantic text is a text title, using the position of the minimal semantic text in the cleaned document as a split point to obtain text for multiple titles; splitting and rewriting all text to obtain atomic test requirements; and normalizing each initial test case to obtain test cases.
[0104] Optionally, the aforementioned computer terminal can execute the program code for the following steps in the alignment detection method between test requirements and test cases: determining each of the minimum semantic texts, excluding the text title, as the target semantic text; calculating the semantic similarity between any two target semantic texts, and if the semantic similarity is less than a preset semantic threshold, segmenting the two target semantic texts corresponding to the semantic similarity in the text to obtain the segmented text; rewriting all the segmented texts to obtain the atomic test requirements.
[0105] Optionally, the aforementioned computer terminal can execute program code for the following steps in the alignment detection method for test requirements and test cases: performing positive detection on all atomic test requirements and all test cases based on the requirement index structure and the test case index structure to obtain positive detection results; and performing negative detection on all atomic test requirements and all test cases based on the requirement index structure and the test case index structure to obtain negative detection results.
[0106] Optionally, the aforementioned computer terminal can execute the following steps in the alignment detection method for test requirements and test cases: traversing each atomic test requirement vector, determining multiple test case vectors based on the test case index structure, and identifying the test cases corresponding to each test case vector as candidate test cases; constructing a first prompt word template based on the atomic test requirements corresponding to the atomic test requirement vectors and all candidate test cases; inputting the first prompt word template into a generative model for inference to obtain a positive detection result, wherein the generative model performs semantic encoding on the text in the first prompt word template through a self-attention mechanism, analyzes the semantic encoding, and generates a positive detection result.
[0107] Optionally, the aforementioned computer terminal can execute the program code for the following steps in the alignment detection method between test requirements and test cases: traversing each test case vector, determining multiple atomic test requirement vectors based on the requirement index structure, and identifying the atomic test requirement corresponding to each atomic test requirement vector as a candidate test requirement; constructing a second prompt word template based on the test cases corresponding to the test case vectors and all candidate test requirements; inputting the second prompt word template into a generative model for inference to obtain a negative detection result, wherein the generative model performs semantic encoding on the text in the second prompt word template through a self-attention mechanism, analyzes the semantic encoding, and generates a negative detection result.
[0108] Optionally, the aforementioned computer terminal can execute program code for the following steps in the alignment detection method for test requirements and test cases: based on the detection results, construct a bidirectional semantic network graph, wherein the types of nodes in the bidirectional semantic network graph include at least: atomic test requirements and test cases, and the types of edges in the bidirectional semantic network graph include at least: semantic similarity and coverage score; analyze the bidirectional semantic network graph to obtain analysis results; and based on the analysis results, generate modification strategies for atomic test requirements and test cases.
[0109] Optionally, Figure 6 This is a structural block diagram of an electronic device according to an embodiment of this application. Figure 6 As shown, the electronic device may include: one or more ( Figure 6 (Only one is shown) Processor 602, memory 604, memory controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.
[0110] The memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the alignment detection method and apparatus for test requirements and test cases in the embodiments of this application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, thereby realizing the aforementioned alignment detection method for test requirements and test cases. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory remotely located relative to the processor, and these remote memories can be connected to the terminal via a network. Examples of the aforementioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0111] The processor can access the information and application programs stored in the memory via the transmission device to execute the steps described above in the alignment detection method for the test requirements and test cases.
[0112] This application provides a scheme for aligning test requirements and test cases. By standardizing unstructured requirements and test texts into atomic test requirements and standardized test cases, a bidirectional vector index structure is constructed. Based on a generative model and a self-attention mechanism, positive coverage reasoning and negative attribution determination are performed. Finally, the detection results are fused to generate a bidirectional semantic network graph and output an executable modification strategy. This enables deep alignment of semantic intent between requirements and tests, accurate location of coverage gaps, and automatic identification of redundant test cases. It achieves bidirectional detection of tests and requirements, thus solving the technical problem in related technologies that cannot achieve bidirectional semantic alignment detection of test requirements and test cases, resulting in wasted computing resources.
[0113] Those skilled in the art will understand that Figure 6 The structure shown is for illustrative purposes only. Electronic devices can also be terminal devices such as smartphones, tablets, PDAs, and mobile internet devices (MIDs). Figure 6 This does not limit the structure of the aforementioned electronic device. For example, electronic devices may also include components that are more... Figure 6 The more or fewer components shown (such as network interfaces, display devices, etc.), or having the same Figure 6 The different configurations shown.
[0114] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0115] Example 4
[0116] Embodiments of this application also provide a storage medium. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the alignment detection method for test requirements and test cases provided in Embodiment 1.
[0117] Optionally, in this embodiment, the storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.
[0118] This application also provides a computer program product that, when executed on a data processing device, is suitable for performing alignment detection method steps of test requirements and test cases.
[0119] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0120] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0121] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0122] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0123] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0124] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0125] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for aligning test requirements with test cases, characterized in that, include: The initial test requirements document and multiple initial test cases were rewritten to obtain multiple atomic test requirements and multiple test cases; Based on all the atomic test requirements and all the test cases, a vector database is constructed, and based on the vector database, a requirement index structure and a test case index structure are constructed. The requirement index structure and the test case index structure are constructed based on a preset search algorithm. The requirement index structure is used to retrieve atomic test requirement vectors, and the test case index structure is used to retrieve test case vectors. Based on the requirement index structure and the test case index structure, alignment detection is performed on all atomic test requirements and all test cases to obtain detection results. The alignment detection includes at least forward detection and reverse detection. The forward detection is used to detect the coverage of each atomic test requirement based on all test cases, and the reverse detection is used to detect test cases that are not associated with any of the atomic test requirements.
2. The alignment detection method for test requirements and test cases according to claim 1, characterized in that, The steps to rewrite the initial test requirements document and multiple initial test cases to obtain multiple atomic test requirements and multiple test cases include: The initial test requirement document is cleaned to obtain a cleaned document, and the cleaned document is divided to obtain the minimum semantic text. Detect whether each of the minimum semantic texts is a text title; When the minimum semantic text is the text title, the position of the minimum semantic text in the cleaned document is used as the segmentation point to obtain text for multiple titles; All the text is segmented and rewritten to obtain the atomic test requirements; Each of the initial test cases is normalized to obtain the test cases.
3. The alignment detection method between test requirements and test cases according to claim 2, characterized in that, The steps of segmenting and rewriting all the text to obtain the atomic test requirements include: Each of the minimum semantic texts, excluding the text title, is identified as the target semantic text. Calculate the semantic similarity between any two target semantic texts, and if the semantic similarity is less than a preset semantic threshold, segment the two target semantic texts corresponding to the semantic similarity in the text to obtain the segmented text; The atomic test requirements are obtained by rewriting all the segmented text.
4. The alignment detection method between test requirements and test cases according to claim 1, characterized in that, The detection results include at least: positive detection results and negative detection results. The step of performing alignment detection on all atomic test requirements and all test cases based on the requirement index structure and the test case index structure to obtain the detection results includes: Based on the requirement index structure and the test case index structure, the forward detection is performed on all the atomic test requirements and all the test cases to obtain the forward detection result; Based on the requirement index structure and the test case index structure, negative detection is performed on all atomic test requirements and all test cases to obtain the negative detection results.
5. The alignment detection method between test requirements and test cases according to claim 4, characterized in that, Based on the requirement index structure and the test case index structure, the step of performing the forward detection on all atomic test requirements and all test cases to obtain the forward detection result includes: Traverse each of the atomic test requirement vectors, determine multiple test case vectors based on the test case index structure, and determine the test case corresponding to each test case vector as a candidate test case; Based on the atomic test requirements corresponding to the atomic test requirement vector and all the candidate test cases, a first prompt word template is constructed. The first prompt word template is input into the generative model for inference to obtain the positive detection result. The generative model performs semantic encoding on the text in the first prompt word template through a self-attention mechanism, analyzes the semantic encoding, and generates the positive detection result.
6. The alignment detection method between test requirements and test cases according to claim 4, characterized in that, Based on the requirement index structure and the test case index structure, the step of performing negative detection on all atomic test requirements and all test cases to obtain the negative detection result includes: Traverse each test case vector, determine multiple atomic test requirement vectors based on the requirement index structure, and determine the atomic test requirement corresponding to each atomic test requirement vector as a candidate test requirement; Based on the test cases corresponding to the test case vector and all the candidate test requirements, a second prompt word template is constructed. The second prompt word template is input into the generative model for inference to obtain the negative detection result. The generative model performs semantic encoding on the text in the second prompt word template through a self-attention mechanism, analyzes the semantic encoding, and generates the negative detection result.
7. The alignment detection method between test requirements and test cases according to claim 1, characterized in that, After performing alignment checks on all atomic test requirements and all test cases based on the requirement index structure and the test case index structure, and obtaining the detection results, the process further includes: Based on the detection results, a bidirectional semantic network graph is constructed, wherein the types of nodes in the bidirectional semantic network graph include at least: atomic test requirements and test cases, and the types of edges in the bidirectional semantic network graph include at least: semantic similarity and coverage score. The bidirectional semantic network graph was analyzed to obtain the analysis results; Based on the analysis results, a modification strategy is generated for the atomic testing requirements and the test cases.
8. A device for aligning test requirements with test cases, characterized in that, include: The rewrite unit is used to rewrite the initial test requirement document and multiple initial test cases to obtain multiple atomic test requirements and multiple test cases; A construction unit is used to construct a vector database based on all the atomic test requirements and all the test cases, and to construct a requirement index structure and a test case index structure based on the vector database. The requirement index structure and the test case index structure are constructed based on a preset search algorithm. The requirement index structure is used to retrieve atomic test requirement vectors, and the test case index structure is used to retrieve test case vectors. The detection unit is configured to perform alignment detection on all atomic test requirements and all test cases based on the requirement index structure and the test case index structure to obtain a detection result. The alignment detection includes at least forward detection and reverse detection. The forward detection is used to detect the coverage of each atomic test requirement based on all the test cases. The reverse detection is used to detect test cases that are not associated with any of the atomic test requirements.
9. A computer program product, characterized in that, The method includes a non-volatile computer-readable storage medium storing a computer program that, when executed by a processor, implements the alignment detection method for test requirements and test cases as described in any one of claims 1 to 7.
10. An electronic device, characterized in that, It includes one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the alignment detection method for test requirements and test cases as described in any one of claims 1 to 7.