Test case generation method and system, storage medium and program product
By performing image processing and optical character recognition on the state machine diagram, test cases are generated, which solves the problems of low manual operation efficiency and insufficient scene coverage in software testing, and realizes automatic test case generation, which improves efficiency and coverage.
Patent Information
- Application Number
- CN202411311233.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2024-12-17
AI Technical Summary
During the software testing process, especially in the requirements analysis step, manual operation is required, resulting in low testing efficiency and difficult to cover all possible test scenarios by manual testing, increasing the risk of missing potential problems.
By obtaining the current and historical state machine diagrams of the object to be tested, performing image processing and optical character recognition, extracting transformation feature groups, and inputting them into the language model to generate test cases, reducing manual participation and improving the efficiency of test case generation.
Test cases can be generated without manual participation, which improves the efficiency of test case generation, reduces costs, covers more test scenarios, and reduces the pressure and test barriers of testers.
Smart Images

Figure CN119149426A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a test case generation method, system, storage medium and program product. Background Art
[0002] Software testing is a vital part of the software development life cycle (SDLC). Its main goal is to discover and correct defects in the software through systematic methods and technical means to ensure that the software meets the requirements and user expectations. Software testing not only helps to improve the quality and stability of the software, but also reduces development costs and enhances user satisfaction.
[0003] The software testing process usually includes steps such as requirements analysis, test planning, test case design, test environment setting, test execution and defect management.
[0004] However, in steps such as demand analysis, testers are required to perform corresponding operations manually, which results in low testing efficiency. Summary of the invention
[0005] In order to solve one of the above technical problems, the present disclosure provides a test case generation method, system, storage medium and program product.
[0006] According to one aspect of the present disclosure, a test case generation method is provided, comprising: Obtain the current state machine diagram corresponding to the current requirement document of the object to be tested and the historical state machine diagram corresponding to the historical requirement document; Performing image processing on the current state machine diagram and the historical state machine diagram respectively to obtain a current conversion element group and a historical conversion element group; The current conversion element group and the historical conversion element group are input into a language model to obtain a test case for the object to be tested.
[0007] According to a test case generation method provided by at least one embodiment of the present disclosure, the image processing is performed on the current state machine diagram and the historical state machine diagram respectively to obtain the current transition element group and the historical transition element group, including: Searching for contours from the current state machine diagram and the historical state machine diagram respectively to obtain a current contour set and a historical contour set; performing optical character recognition on the current state machine diagram and the historical state machine diagram respectively to obtain a current character set and a historical character set; Perform layout analysis on the current state machine diagram according to the positions of contours in the current contour set, the positions of characters in the current character set and the first layout rule to obtain a current conversion element group: Perform layout analysis on the historical state machine diagram according to the positions of contours in the historical contour set, the positions of characters in the historical character set and the second layout rule to obtain a historical conversion element group.
[0008] According to the test case generation method provided by at least one embodiment of the present disclosure, the searching for the profile from the current state machine diagram and the historical state machine diagram respectively includes: Preprocessing the current state machine diagram and the historical state machine diagram respectively to obtain a current processing diagram and a historical processing diagram; The contour is searched from the current processing graph and the historical processing graph respectively.
[0009] According to at least one embodiment of the present disclosure, a test case generation method is provided. The performing layout analysis on the current state machine diagram according to the positions of the contours in the current contour set, the positions of the characters in the current character set and the first layout rule to obtain the current conversion element group includes: performing layout analysis on the current state machine diagram according to the positions of the contours in the current contour set, the positions of the characters in the current character set and the first layout rule to obtain the current analysis group; performing arrow detection on the current state machine diagram to obtain the current arrow direction; optimizing the current analysis group according to the current arrow direction to obtain the current conversion element group; and / or The historical state machine diagram is subjected to layout analysis according to the positions of contours in the historical contour set, the positions of characters in the historical character set and the second layout rule to obtain a historical conversion element group, including: performing layout analysis on the historical state machine diagram according to the positions of contours in the historical contour set, the positions of characters in the historical character set and the second layout rule to obtain a historical analysis group; performing arrow detection on the historical state machine diagram to obtain a historical arrow direction; optimizing the historical analysis group according to the historical arrow direction to obtain a historical conversion element group.
[0010] According to a test case generation method provided by at least one embodiment of the present disclosure, the inputting the current conversion element group and the historical conversion element group into a language model includes: Obtaining the project document corresponding to the object to be tested; The current conversion element group, the historical conversion element group and the project document are input into a language model.
[0011] According to a test case generation method provided by at least one embodiment of the present disclosure, the inputting the current conversion element group, the historical conversion element group and the project document into a language model comprises: Acquire transition element information corresponding to the transition element of the state machine diagram from the project document; The current conversion element group, the historical conversion element group, and the conversion element information are input into a language model.
[0012] According to a test case generation method provided by at least one embodiment of the present disclosure, the inputting the current conversion element group and the historical conversion element group into a language model includes: Performing content verification on the current conversion element group and the historical conversion element group respectively to obtain verification results; Update the current conversion element group and the historical conversion element group according to the verification result; The updated current conversion element group and the updated historical conversion element group are input into the language model.
[0013] According to another aspect of the present disclosure, a test case generation system is provided, comprising: a memory storing execution instructions; and A processor, wherein the processor executes the execution instructions stored in the memory, so that the processor executes the test case generation method provided by any embodiment of the present disclosure.
[0014] According to another aspect of the present disclosure, a readable storage medium is provided, wherein the readable storage medium stores execution instructions, and when the execution instructions are executed by a processor, the test case generation method provided in any embodiment of the present disclosure is implemented.
[0015] According to another aspect of the present disclosure, a computer program is provided. When the computer program is executed by a processor, the test case generating method provided in any embodiment of the present disclosure is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings illustrate exemplary embodiments of the present disclosure and together with the description serve to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification.
[0017] Figure 1 It is a schematic flowchart of a test case generation method provided according to an embodiment of the present disclosure.
[0018] Figure 2 It is a flowchart of the test case generation method provided in Example 1 of the present disclosure.
[0019] Figure 3 yes Figure 2 The flowchart of the method for obtaining element groups in the test case generation method shown.
[0020] Figure 4 yes Figure 3 The flowchart of the method for finding contours in the feature group acquisition method is shown.
[0021] Figure 5 yes Figure 3 The flowchart of the method for obtaining the current feature group in the feature group obtaining method shown.
[0022] Figure 6 yes Figure 3 A flowchart of a method for obtaining a historical feature group in a feature group obtaining method is shown.
[0023] Figure 7 yes Figure 2 The flow of the model input method in the test case generation method shown Figure 1 .
[0024] Figure 8 yes Figure 2 The flow of the model input method in the test case generation method shown Figure 2 .
[0025] Fig. 9 yes Figure 8 Flowchart of the document input method in the model input method shown.
[0026] Fig.10 yes Figure 2 The flow of the model input method in the test case generation method shown Figure 3 .
[0027] Fig.11 This is a schematic diagram of the structure of the test case generation system provided in Example 2 of the present disclosure. Figure 1 .
[0028] Fig.12 This is a schematic diagram of the structure of the test case generation system provided in Example 2 of the present disclosure. Figure 2 . DETAILED DESCRIPTION
[0029] The present disclosure is further described in detail below in conjunction with the accompanying drawings and examples. It is understood that the specific examples described herein are only used to explain the relevant content, rather than to limit the present disclosure. It should also be noted that, for ease of description, only the parts related to the present disclosure are shown in the accompanying drawings.
[0030] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in the present disclosure can be combined with each other. The technical solution of the present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0031] Iterative testing is a method in the software development and testing process, which involves dividing software development into multiple stages, and testing is performed at each stage to ensure that the software meets the predetermined quality requirements in each iteration cycle. It is usually combined with agile development methods, and an iterative approach is adopted in the software development life cycle (SDLC) for development and testing. The core concept of iterative testing is to complete the development and testing of a part of the functions in each iteration cycle to ensure the quality and stability of this part of the functions. Traditional version iteration testing usually relies on a lot of human resources, including test engineers and quality assurance (QA) team members. As the complexity and functionality of software increase, version iteration testing becomes more and more time-consuming and costly. In addition, manual testing may not cover all possible test scenarios, thereby increasing the risk of missing potential problems.
[0032] Figure 1 A schematic flowchart of a test case generation method according to an embodiment of the present disclosure is shown. Figure 1 The detailed description is for a clearer understanding of the technical solution of the present disclosure and should not be considered as a limitation of the protection scope of the present disclosure. In the process of implementing the technical idea of the present disclosure, one or some steps may be omitted, or other alternatives may be adopted.
[0033] Step S110, obtaining a current state machine diagram corresponding to a current requirement document of the object to be tested and a historical state machine diagram corresponding to a historical requirement document.
[0034] In some embodiments of the present disclosure, the object to be tested in step S110 may be any software or system that needs to be tested to verify its function, performance or other characteristics; the object to be tested may be a mobile application (such as a social application, a game application, a health monitoring application, etc.), a Web application (such as an e-commerce website, an online banking system, a content management system, etc.), a desktop software (such as an office suite, an image editor, a database management tool, etc.), an embedded system (such as an automotive electronic control system, a household appliance control system, etc.), a network device (such as a router, a switch, a firewall, etc.), an operating system (such as Windows, macOS, Linux, etc.), a middleware (such as a message queue service, a transaction processing monitor, etc.), an API and a microservice (such as a RESTful API, a GraphQL interface, etc.), an IoT device (such as a smart watch, a smart home device, etc.), and a game engine (such as Unity, Unreal Engine, etc.).
[0035] The current or historical state machine diagram in step S110, also called a state diagram or state transition diagram, is a graphical representation method of the state of a system and its transitions, and is mainly used to describe the behavior of an object in different states and the events it responds to. The state machine diagram is part of the Unified Modeling Language (UML) and is widely used in software engineering and system design. The current requirement document in step S110 is the requirement document of the current version of the object to be tested, and the historical requirement document is the requirement document of the previous version of the object to be tested. The current or historical state machine diagram can be generated in advance by the user based on the current requirement document (or the current code corresponding to the current requirement document) and the historical requirement document (or the historical code corresponding to the historical requirement document).
[0036] Step S111, pre-processing the current state machine diagram and the historical state machine diagram respectively to obtain the current processing diagram and the historical processing diagram.
[0037] In some embodiments of the present disclosure, in order to improve the efficiency and accuracy of subsequent image processing, before performing subsequent image processing, the current state machine diagram and the historical state machine diagram can be first preprocessed through step S120 to simplify the data, enhance useful information and remove unnecessary noise.
[0038] Step S112, searching for contours from the current processing graph and the historical processing graph respectively to obtain a current contour set and a historical contour set.
[0039] In some embodiments of the present disclosure, step S112 can search for contours from the current processing graph and the historical processing graph through a contour detection function; in particular, when searching for contours, the search can be combined with the representation of the state machine diagram. For example, the state machine diagram usually represents the state through a rectangular box, so the focus can be on searching for rectangular contours, etc.
[0040] Step S113, performing optical character recognition on the current processing graph and the historical processing graph respectively to obtain a current character set and a historical character set.
[0041] Step S114, performing layout analysis on the current processing graph according to the positions of the contours in the current contour set, the positions of the characters in the current character set and the first layout rule to obtain a current analysis group.
[0042] Step S115, performing arrow detection on the current processing graph to obtain the current arrow direction.
[0043] Step S116, optimizing the current analysis group according to the current arrow direction to obtain the current conversion element group.
[0044] Step S117 , performing layout analysis on the historical processing graph according to the positions of the contours in the historical contour set, the positions of the characters in the historical character set and the second layout rule to obtain a historical analysis group.
[0045] In some embodiments of the present disclosure, the first layout rule in step S114 and the second layout rule in step S117 may be the same layout rule (eg, both are from left to right), or different rules (eg, one is from left to right and the other is from top to bottom).
[0046] Step S118, performing arrow detection on the historical state machine diagram to obtain the historical arrow direction.
[0047] Step S119, optimizing the historical analysis group according to the direction of the historical arrow to obtain a historical conversion element group.
[0048] In some embodiments of the present disclosure, the transition elements in the current or historical transition element group in step S116 and step S119 include a source state (the state before the event occurs), a target state (the state entered after the event occurs), and an event (the condition that triggers the change from the source state to the target state). Among them, the event can be an external transition event, that is, an event that causes a transition from one state to another; it can also be an internal transition event, that is, an event that occurs inside a state and does not cause a state change. The source state and target state of the internal transition event are the same.
[0049] Step S120, performing content verification on the current conversion element group and the historical conversion element group respectively to obtain verification results.
[0050] Step S121, updating the current conversion element group and the historical conversion element group according to the verification result.
[0051] Step S122: compare the updated current conversion element group with the updated historical conversion element group to obtain element change information.
[0052] Step S123, obtaining the project document corresponding to the object to be tested.
[0053] In some embodiments of the present disclosure, the project document in step S121 is a document used to guide test activities, define test scope and test strategy. The project document may be a requirement document, a software design document, an interface specification document, and the like.
[0054] Step S124, obtaining the transition element information corresponding to the transition element of the state machine diagram from the project document.
[0055] Step S125, input the element change information and the conversion element information into the language model to obtain a test case of the object to be tested.
[0056] In some embodiments of the present disclosure, the language model in step S123 can be a traditional language model, such as a statistical language model (N-gram model, maximum entropy model, hidden Markov model, etc.), a neural network-based language model, etc.; it can also be a pre-trained model with a large number of parameters, such as a GPT series model (such as GPT-1, GPT-2, etc.), a BERT series model (such as BERT, RoBERTa, ALBERT, etc.), an M6 model, a Tongyi Qianwen model, etc.
[0057] Combine the following Figures 2 to 10 The test case generation method disclosed in the present invention is described in detail.
[0058] Embodiment 1: Figure 2 The present invention is a flowchart of a test case generation method according to an embodiment of the present invention.
[0059] refer to Figure 2 The test case generation method M200 of this embodiment includes: Step S210, obtaining a current state machine diagram corresponding to a current requirement document of the object to be tested and a historical state machine diagram corresponding to a historical requirement document.
[0060] Step S220, performing image processing on the current state machine diagram and the historical state machine diagram respectively to obtain a current conversion element group and a historical conversion element group.
[0061] Step S230: input the current conversion element group and the historical conversion element group into the language model to obtain a test case of the object to be tested.
[0062] The test case generation method provided by the present disclosure processes the current state machine diagram and the historical state machine diagram of the object to be tested to obtain the current conversion element group and the historical conversion element group, and then inputs the current conversion element group and the historical conversion element group into the language model to obtain the test case of the object to be tested. The test case generation method can improve the efficiency of test case generation and reduce costs without manual participation, and solves the problem that the tester needs to manually perform corresponding operations in the steps of demand analysis and the like in the prior art, and the test efficiency is low. In addition, since the language model is usually trained with massive text data, a variety of test cases can be generated through the language model, which helps to cover different scenarios and edge cases, and can solve the problem that manual testing may not cover all possible test scenarios, thereby increasing the risk of missing potential problems. And the method does not require the tester to be familiar with the specific logic of the project before outputting the corresponding test plan, which can reduce the variance of the tester's test ability, reduce the test barrier, and reduce the pressure of the tester.
[0063] In some embodiments of the present disclosure, the object to be tested in step S210 may be software or a system to be tested; such as mobile applications (such as social applications, game applications, health monitoring applications, etc.), Web applications (such as e-commerce websites, online banking systems, content management systems, etc.), desktop software (such as office suites, image editors, database management tools, etc.), embedded systems (such as automotive electronic control systems, household appliance control systems, etc.), network equipment (such as routers, switches, firewalls, etc.), operating systems (such as Windows, macOS, Linux, etc.), middleware (such as message queue services, transaction processing monitors, etc.), APIs and microservices (such as RESTful APIs, GraphQL interfaces, etc.), IoT devices (such as smart watches, smart home devices, etc.), and game engines (such as Unity, Unreal Engine, etc.).
[0064] In step S210, the current requirement document is the requirement document of the current version of the object to be tested, and the historical requirement document is the requirement document of any historical version of the object to be tested; in particular, in order to improve the pertinence and efficiency of the test, the historical requirement document can be a requirement document of the previous version of the current version; taking an e-commerce website as an example, assuming that its initial version is 1.0, after version 1.1 and version 1.2, the current version of the object to be tested is version 1.3, then the current state machine diagram is the state machine diagram corresponding to version 1.3, the historical state machine diagram can be the state machine diagram corresponding to version 1.0 or version 1.1, and the historical state machine diagram is preferably the state machine diagram corresponding to version 1.2.
[0065] In some embodiments of the present disclosure, the image processing in step S220 may be image detection, optical character recognition, etc., to obtain a current transition element group and a historical transition element group. The transition elements of the state machine diagram refer to specific elements of how the states change, including the source state (the state before the event occurs), the target state (the state entered after the event occurs), and the event (the condition that triggers the change from the source state to the target state). In particular, in order to simplify data, enhance useful information, and remove unnecessary noise, the image may also be preprocessed before specific image processing.
[0066] In some embodiments of the present disclosure, the language model may be a traditional language model; or a pre-trained model with a large number of parameters, and the language model analyzes and converts the current conversion element group and the historical conversion element group into test cases. In order for the language model to correctly output test cases, in addition to the current conversion element group and the historical conversion element group, prompt information (prompt) may also be input; the prompt information may be a simple test case generation prompt, such as "please generate a test case based on the current conversion element group and the historical conversion element group"; in addition to the test case generation prompt, prompts such as the project background and / or the case generation process may also be input so that the language model can more accurately understand and generate the required output.
[0067] like Figure 3 As shown, step S220 may include: step S221, searching for contours from the current state machine diagram and the historical state machine diagram, respectively, to obtain a current contour set and a historical contour set; step S222, performing optical character recognition on the current state machine diagram and the historical state machine diagram, respectively, to obtain a current character set and a historical character set; step S223, performing layout analysis on the current state machine diagram according to the positions of contours in the current contour set, the positions of characters in the current character set, and the first layout rule, to obtain a current conversion element group; step S224, performing layout analysis on the historical state machine diagram according to the positions of contours in the historical contour set, the positions of characters in the historical character set, and the second layout rule, to obtain a historical conversion element group.
[0068] Among them, in order to enhance useful information and remove unnecessary noise, such as Figure 4 As shown, step S221 may include: step S2211, preprocessing the current state machine diagram and the historical state machine diagram respectively to obtain the current processing diagram and the historical processing diagram; step S2212, searching for contours from the current processing diagram and the historical processing diagram respectively. At this time, in order to improve the accuracy of image analysis, the current state machine diagram and the historical state machine diagram in steps S222 to S224 may also be specifically the current processing diagram and the historical processing diagram after preprocessing. The preprocessing may be one or more of grayscale (converting the image into a grayscale image, which can reduce the computational complexity and the amount of data), binarization (converting the grayscale image into a black and white image with only two possible values (usually black and white or 0 and 1); it can simplify the image, highlight important features, and reduce the computational complexity of subsequent processing) and denoising (the process of reducing or eliminating noise in the image, which can improve the image quality, improve the visual effect of the image, and also improve the performance of subsequent image processing). Grayscale conversion can be achieved through OpenCV's cvtColor method, binarization can be achieved through OpenCV's threshold method, and noise reduction can be achieved through filtering methods such as OpenCV's median filtering method, medianBlur.
[0069] When performing optical character recognition through step S222, text-related feature information can be extracted through features such as geometric features and contour features for use in text recognition; in particular, in order to improve the accuracy of optical character recognition, features can also be extracted from images through deep learning models such as convolutional neural networks (CNN) and recurrent neural networks (RNN).
[0070] In some embodiments of the present disclosure, a state machine diagram, also known as a state diagram, is a commonly used Unified Modeling Language (UML) diagram used to describe the state changes of an object during its life cycle. A state machine diagram is generally used to represent the state transition logic of an entity or object, as well as the events and actions that trigger these transitions. A state machine diagram usually includes the following components: an initial state (indicating the starting state of the state machine, usually represented by a small circle), a final state (indicating the ending state of the state machine, usually represented by a small circle within a circle), a state (indicating the different states of an object, including simple states and compound states, usually represented by a rectangular box), a transition (indicating the transition between states, usually represented by an arrow), an event (a signal or action that triggers a state transition, usually marked on an arrow), etc.; a state machine diagram usually follows certain layout rules, such as from left to right (the state machine diagram starts from the initial state on the left, and the states and transitions expand to the right), from top to bottom (the state machine diagram starts from the initial state at the top, and the states and transitions expand downward), etc., and may also be flexibly laid out; that is, the layout rules may be from left to right, from top to bottom, or flexibly laid out; the first layout rule in step S223 and the second layout rule in step S224 may be the same layout rule or different layout rules.
[0071] In order to improve the accuracy of the current conversion feature group, such as Figure 5 As shown, step S223 may include: step S2231, performing layout analysis on the current state machine diagram according to the positions of contours in the current contour set, the positions of characters in the current character set and the first layout rule to obtain the current analysis group; step 2232, performing arrow detection on the current state machine diagram to obtain the current arrow direction; step S2233, optimizing the current analysis group according to the current arrow direction to obtain the current conversion element group.
[0072] In order to improve the accuracy of historical conversion feature groups, such as Figure 6As shown, step S224 may include: step S2241, performing layout analysis on the historical state machine diagram according to the positions of contours in the historical contour set, the positions of characters in the historical character set and the second layout rule to obtain a historical analysis group; step S2242, performing arrow detection on the historical state machine diagram to obtain the historical arrow direction; step S2243, optimizing the historical analysis group according to the historical arrow direction to obtain a historical conversion element group.
[0073] The arrow detection process in step S2242 and step S2232 may include: 1. Image preprocessing, including grayscale, binarization, noise reduction, etc.; 2. Edge detection, extracting image edge information; 3. Trunk extraction, straight lines are detected by Hough transform, and curves are obtained by curve fitting methods such as polynomial fitting to obtain the trunk of the arrow; 4. Arrow head detection, using Harris corner detection to find sharp points in the contour; 5. Feature extraction, using algorithms such as Scale-Invariant Feature Transform (SIFT) and Speeded-Up Robust Features (SURF) to extract the features of the arrow; 6. Direction determination, combining the above features to determine the direction of the arrow.
[0074] In some embodiments of the present disclosure, in order to facilitate the language model to analyze the current conversion element group and the historical conversion element group, the current conversion element group and the historical conversion element group may include the positions of the above-mentioned elements in addition to the source state, target state and event field; in particular, in order to improve the processing efficiency of the language model, the two groups of positions may be standardized positions.
[0075] In some embodiments of the present disclosure, in order to improve the generation effect of the language model to generate test cases, such as Figure 7 As shown, step S230 may include: step S231, comparing the current conversion element group with the historical conversion element group to obtain element change information; step S232, inputting the element change information into the language model. The element change information in step S231 may include one or more of element modification information, element deletion information, and element addition information; step S231 may adopt direct comparison, that is, for each conversion element in the current conversion element group, query whether the conversion element is included in the historical conversion element group; or hash comparison may be adopted, that is, for each conversion element in the current conversion element group and the historical conversion element group, generate the hash code of the conversion element, and then compare the hash codes in the two conversion element groups.
[0076] In some embodiments of the present disclosure, in daily development and testing activities, element comparison can be performed based on the historical conversion element group; in long-term stability testing or problem tracking, element comparison can be performed based on the current conversion element group.
[0077] In some embodiments of the present disclosure, in order to improve the generation effect of the language model to generate test cases, such as Figure 8 As shown, step S230 may also include: step S233, obtaining the project document corresponding to the object to be tested; step S234, inputting the current conversion element group, the historical conversion element group and the project document into the language model. The project document in step S233 refers to various files and records created during the entire project cycle, and may specifically be a document describing the technical details of a system or product, such as a requirement document, a software design document, and an interface specification document.
[0078] In particular, in order to prevent the entire project document from being input into the language model to mislead the language model, and to improve the generation effect of the language model to generate test cases, such as Fig. 9 As shown, step S234 may include: step S2341, obtaining the transition element information corresponding to the transition element of the state machine diagram from the project document; step S2342, inputting the current transition element group, the historical transition element group and the transition element information into the language model. The transition element information may be in the form of text description; for the convenience of processing, the form of the transition element information may be consistent with the form of the current transition element group and the historical transition element group.
[0079] In some embodiments of the present disclosure, in order to reduce the possibility of text leakage in optical character recognition and improve the generation effect of language model generation test cases, such as Fig.10 As shown, step S230 may also include: step S235, respectively performing content verification on the current conversion element group and the historical conversion element group to obtain verification results; step S236, updating the current conversion element group and the historical conversion element group according to the verification results; step S237, inputting the updated current conversion element group and the updated historical conversion element group into the language model. Among them, content verification may include: format verification (checking the content to ensure that it follows the predetermined format rules, such as type verification, integrity verification (null value verification), space verification (blank character verification), etc.), naming standard verification (checking the names of variable names, function names, class names, etc. to ensure that they follow certain naming conventions or specifications), preset value verification (checking the preset value to ensure that it meets the expected value) and uniqueness verification (ensuring that the content is unique to avoid duplicate content) one or more.
[0080] In some embodiments of the present disclosure, step 230 may include any of the steps of comparison, content verification, and adding project documents, such as Figure 8 , 9 or 10; Step S230 may also include multiple steps of comparison, content verification and adding project documents, and its implementation method is the same as Figures 8 to 10 Similar to that shown.
[0081] In some embodiments of the present disclosure, when the change is an element modification, it is necessary to ensure that the modification does not destroy the original function and that the new function works as expected. The test cases obtained through step S230 should include: test cases for verifying the working condition of the modified element itself (used to test whether the modified function can work as expected), test cases for verifying functions related to the modified element (used to test whether other functions related to the modified element still work normally), test cases for verifying the impact of the modified element on existing data (testing whether the modified element will affect the integrity of the existing data), and test cases for verifying the impact of the modified element on performance (testing whether the modified element will affect the performance of the system), etc.
[0082] When the change is element deletion, it is necessary to ensure that the deletion operation will not cause functional problems. The test cases obtained through step S230 should include: test cases to verify whether the deletion operation is successful (test whether the deletion operation is successfully executed as expected), test cases to verify the impact after the deletion operation (test whether the deletion operation has a negative impact on related functions), test cases to verify the impact of the deletion operation on data (test whether the deletion operation will affect the integrity of related data), and test cases to verify the impact of the deletion operation on performance (test whether the deletion operation will affect the performance of the system), etc.
[0083] When the change is the addition of an element, it is necessary to ensure that the new function works as expected and is compatible with other existing functions. The test cases obtained through step S230 should include: test cases for verifying the working condition of the new function (testing whether the new function works as expected), test cases for verifying the compatibility of the new function with other functions (testing whether the new function is compatible with other functions), test cases for verifying the impact of the new function on existing data (testing whether the new function will affect the integrity of the existing data), and test cases for verifying the impact of the new function on performance (testing whether the new function will affect the performance of the system).
[0084] In some embodiments of the present disclosure, the test case generated by step S230 is a set of conditions or variables with clearly defined inputs, operation steps and expected results, which are used to verify whether a specific function or behavior works as expected. The test case generated by step S230 may include input data, test steps and expected results; for ease of use, the test case may also include: test case ID (unique identifier, used to distinguish different test cases), title or description (a brief description of the test case), preconditions (conditions that need to be met to execute the test case, such as system status, database records, external system status, etc.), importance level (importance level of the test case, which can be used for priority sorting), execution frequency (specify the frequency at which the test case should be executed, such as daily, weekly, etc.), test environment (environmental details where the test needs to be executed, such as operating system version, browser type, etc.) and notes or comments (additional information or precautions to help testers better understand the purpose and background of the test case) and other contents. Taking the test of changing the order status as an example, the test case of the object to be tested obtained through step S230 may include: input data: order in the waiting receipt status, test steps: execute the receipt action, expected result: the order status changes to "received"; taking the test of realizing the shopping cart function as an example, the test case of the object to be tested obtained through step S230 may include: test case ID: T001, title / description: verify whether the user can add the product to the shopping cart, precondition: the user has logged in and there is at least one available product in the system, input data: product ID: PRODUCT123 45. Test steps: "1. Log in to the system; 2. Find product PRODUCT12345; 3. Click the "Add to Cart" button; 4. Check the shopping cart icon or notification to confirm that the product has been added to the shopping cart; 5. Enter the shopping cart page; 6. Verify that the product ID displayed in the shopping cart is PRODUCT12345", expected results: Product PRODUCT12345 is successfully added to the shopping cart and the shopping cart page correctly displays the product information, importance level: high, execution frequency: executed every iteration, test environment: operating system: XX, browser: XXX latest version.
[0085] Figure 11 to Figure 12 The test case generation system of the present invention can be implemented based on a hardware implementation method using a processor.
[0086] Embodiment 2: An embodiment of the present disclosure provides a test case generation system.
[0087] The system may include corresponding modules for executing each or several steps in the above flowchart. Therefore, each step or several steps in the above flowchart may be executed by the corresponding module, and the system may include one or more modules in these modules. The module may be one or more hardware modules specially configured to execute the corresponding steps, or implemented by a processor configured to execute the corresponding steps, or stored in a computer-readable medium for implementation by a processor, or implemented by some combination.
[0088] Fig.11 1 is a test case generation system 1000 that illustrates a hardware implementation of a processing system. The hardware can be implemented using a bus architecture. The bus architecture can include any number of interconnecting buses and bridges, depending on the specific application and overall design constraints of the hardware. The bus 1100 connects various circuits including one or more processors 1200, memory 1300, and / or hardware modules together. The bus 1100 can also connect various other circuits 1400 such as peripherals, voltage regulators, power management circuits, external antennas, etc., which are conventional techniques in the art and will not be described again.
[0089] like Fig.11 As shown, the test case generation system according to the present disclosure may include: The state diagram acquisition module 1010 is used to acquire the current state machine diagram corresponding to the current requirement document of the object to be tested and the historical state machine diagram corresponding to the historical requirement document.
[0090] The state diagram processing module 1020 is used to perform image processing on the current state machine diagram and the historical state machine diagram respectively to obtain a current transition element group and a historical transition element group.
[0091] The use case generation module 1030 is used to input the current conversion element group and the historical conversion element group into the language model to obtain the test case of the object to be tested.
[0092] In the test case generation system provided by the present disclosure, the state diagram processing module 1020 may include: The profile acquisition unit 1021 is used to search for profiles from the current state machine diagram and the historical state machine diagram respectively to obtain a current profile set and a historical profile set.
[0093] The character recognition unit 1022 is used to perform optical character recognition on the current state machine diagram and the historical state machine diagram respectively to obtain a current character set and a historical character set.
[0094] The first analysis unit 1023 is used to perform layout analysis on the current state machine diagram according to the positions of the contours in the current contour set, the positions of the characters in the current character set and the first layout rule to obtain a current conversion element group.
[0095] The second analysis unit 1024 is used to perform layout analysis on the historical state machine diagram according to the positions of the contours in the historical contour set, the positions of the characters in the historical character set, and the second layout rule to obtain a historical conversion element group.
[0096] In the test case generation system provided by the present disclosure, the case generation module 1030 may include: The comparison unit 1031 is used to compare the current conversion element group with the historical conversion element group to obtain element change information.
[0097] The first input unit 1032 is used to input element change information into the language model.
[0098] In the test case generation system provided by the present disclosure, the case generation module 1030 may also include: The document acquisition unit 1033 is used to acquire the project document corresponding to the object to be tested.
[0099] The second input unit 1034 is used to input the current conversion element group, the historical conversion element group and the project document into the language model.
[0100] In the test case generation system provided by the present disclosure, the case generation module 1030 may further include: The content verification unit 1035 is used to perform content verification on the current conversion element group and the historical conversion element group respectively to obtain verification results.
[0101] The element updating unit 1036 is used to update the current conversion element group and the historical conversion element group according to the verification result.
[0102] The third input unit 1037 is used to input the updated current conversion element group and the updated historical conversion element group into the language model.
[0103] The test case generation system provided by the present disclosure implements the test case generation process through the above modules, and the process of the above modules implementing their respective functions is similar to that provided in Embodiment 1 of the present disclosure. When the test case generation system includes all the above modules and units, the structure is as follows Fig.12 As shown; when the test case generation system only includes some of the above units, the structure is Fig.12 The test case generation system may be an electronic device, such as a server.
[0104] The present disclosure also provides a readable storage medium, in which a computer program is stored, and the computer program is used to implement the above method when executed by a processor. "Readable storage medium" can be any device that can contain, store, communicate, propagate or transmit a program for use in an instruction execution system, device or equipment or in combination with these instruction execution systems, devices or equipment. More specific examples of readable storage media include the following: an electrical connection portion (electronic device) with one or more wirings, a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable read-only memory (CDROM), etc.
[0105] The present disclosure also provides a computer program product. The method of the present disclosure can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instruction is loaded and executed, the process or function of the present disclosure is executed in whole or in part.
[0106] The computer program or instructions may be stored in a readable storage medium or transmitted from one readable storage medium to another readable storage medium, for example, the computer program or instructions may be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired or wireless means. The readable storage medium may be any available medium that can be accessed or a data storage device such as a server, data center, etc. that integrates one or more available media. The available medium may be a magnetic medium, such as a floppy disk, a hard disk, or a magnetic tape; it may also be an optical medium, such as a digital video disk; it may also be a semiconductor medium, such as a solid state drive. The computer readable storage medium may be a volatile or non-volatile storage medium, or may include both volatile and non-volatile types of storage media.
[0107] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing a computer-usable program requirement document.
[0108] The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0109] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0110] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0111] In the description of this specification, the description with reference to the terms "one embodiment / method", "some embodiments / methods", "example", "specific example", or "some examples" etc. means that the specific features, structures, or characteristics described in conjunction with the embodiment / method or example are included in at least one embodiment / method or example of the present disclosure. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment / method or example. Moreover, the specific features, structures, or characteristics described may be combined in any one or more embodiments / methods or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments / methods or examples described in this specification and features of different embodiments / methods or examples, unless they are contradictory.
[0112] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, "plurality" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0113] Those skilled in the art should understand that the above embodiments are only for the purpose of clearly illustrating the present disclosure, and are not intended to limit the scope of the present disclosure. For those skilled in the art, other changes or modifications may be made based on the above disclosure, and these changes or modifications are still within the scope of the present disclosure.
Claims
1. A test case generation method, characterized in that: include: Obtain the current state machine diagram corresponding to the current requirement document of the object to be tested and the historical state machine diagram corresponding to the historical requirement document; Performing image processing on the current state machine diagram and the historical state machine diagram respectively to obtain a current transition element group and a historical transition element group; and The current conversion element group and the historical conversion element group are input into a language model to obtain a test case for the object to be tested.
2. The test case generation method according to claim 1, wherein: The performing image processing on the current state machine diagram and the historical state machine diagram respectively to obtain a current conversion element group and a historical conversion element group includes: Searching for outlines from the current state machine diagram and the historical state machine diagram respectively to obtain a current outline set and a historical outline set; performing optical character recognition on the current state machine diagram and the historical state machine diagram respectively to obtain a current character set and a historical character set; and Perform layout analysis on the current state machine diagram according to the positions of the contours in the current contour set, the positions of the characters in the current character set and the first layout rule to obtain a current conversion element group: perform layout analysis on the historical state machine diagram according to the positions of the contours in the historical contour set, the positions of the characters in the historical character set and the second layout rule to obtain a historical conversion element group.
3. The test case generation method according to claim 2, characterized in that: The searching for the profile from the current state machine diagram and the historical state machine diagram respectively includes: Preprocessing the current state machine diagram and the historical state machine diagram respectively to obtain a current processing diagram and a historical processing diagram; and Contours are searched from the current processing graph and the historical processing graph respectively.
4. The test case generation method according to claim 2, wherein: The performing layout analysis on the current state machine diagram according to the positions of the contours in the current contour set, the positions of the characters in the current character set, and the first layout rule to obtain the current conversion element group includes: performing layout analysis on the current state machine diagram according to the positions of the contours in the current contour set, the positions of the characters in the current character set, and the first layout rule to obtain the current analysis group; performing arrow detection on the current state machine diagram to obtain the current arrow direction; optimizing the current analysis group according to the current arrow direction to obtain the current conversion element group; and / or Performing layout analysis on the historical state machine diagram according to the positions of the contours in the historical contour set, the positions of the characters in the historical character set, and the second layout rule to obtain a historical conversion element group, including: performing layout analysis on the historical state machine diagram according to the positions of the contours in the historical contour set, the positions of the characters in the historical character set, and the second layout rule to obtain a historical analysis group; performing arrow detection on the historical state machine diagram to obtain a historical arrow direction; and optimizing the historical analysis group according to the historical arrow direction to obtain a historical conversion element group.
5. The test case generation method according to any one of claims 1 to 4, characterized in that: The step of inputting the current conversion element group and the historical conversion element group into a language model includes: Obtaining the project document corresponding to the object to be tested; and The current conversion element group, the historical conversion element group, and the project document are input into a language model.
6. The test case generation method according to claim 5, characterized in that: The step of inputting the current conversion element group, the historical conversion element group, and the project document into a language model includes: Acquire transition element information corresponding to the transition element of the state machine diagram from the project document; and The current conversion element group, the historical conversion element group, and the conversion element information are input into a language model.
7. The test case generation method according to any one of claims 1 to 4, characterized in that: The step of inputting the current conversion element group and the historical conversion element group into a language model includes: Performing content verification on the current conversion element group and the historical conversion element group respectively to obtain verification results; Update the current conversion element group and the historical conversion element group according to the verification result; and The updated current conversion feature group and the updated historical conversion feature group are input into the language model.
8. A test case generation system, characterized in that: include: a memory storing execution instructions; as well as A processor, wherein the processor executes the execution instruction stored in the memory, so that the processor executes the test case generation method according to any one of claims 1 to 7.
9. A readable storage medium, characterized in that The readable storage medium stores execution instructions, which, when executed by a processor, are used to implement the test case generation method according to any one of claims 1 to 7.
10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the test case generating method according to any one of claims 1 to 7 is implemented.
