Test case generation method and device and electronic equipment

By obtaining object information of test objects, using network models to generate and update prompt words, and combining historical test cases to generate target test cases, the problem of poor quality test cases in the existing technology is solved, and higher quality test case generation is achieved.

CN120448263APending Publication Date: 2025-08-08SHENZHEN HEYTAP TECHNOLOGY CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510528274.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-24
Publication Date
2025-08-08

AI Technical Summary

Technical Problem

In the existing test case generation methods, the generated test cases are of poor quality and cannot meet high-quality testing needs.

Method used

By obtaining object information of the test object, a first prompt word is generated using the first network model, a second prompt word is generated in combination with the historical test cases corresponding to the first test point, and a target test case is generated through the second network model, updating the first prompt word is achieved to improve accuracy.

Benefits of technology

Improve the quality of test cases, making the generated test cases more accurate and adapt to the specific needs of the test objects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120448263A_ABST
    Figure CN120448263A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a test case generation method and device and electronic equipment. In the method, under the condition that object information of a test object is obtained, a first cue word can be obtained through the object information and a first network model, then after a first test point is determined according to the first cue word, a second cue word is obtained through a historical test case corresponding to the first test point and the first cue word, and then the second cue word is sent to the test object. And obtaining the target test case through the second prompt word and the second network model. Therefore, under the condition that the first cue word is obtained through the object information, the first test point can be further determined through the first cue word, so that the first cue word can be updated based on the historical test case corresponding to the first test point to obtain a more accurate second cue word, and the user experience is improved. The target test case obtained through the second cue word and the second network model is more accurate, so that the quality of the test case is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of terminal technology, and more specifically, to a test case generation method, device, and electronic device. Background Art

[0002] Test cases are the core of software testing. By defining input data, execution steps, and expected outputs, they provide a test basis for verifying software functionality, performance, and reliability. However, existing methods for generating test cases often suffer from poor quality. Summary of the Invention

[0003] In view of the above problems, the present application proposes a test case generation method, device and electronic device.

[0004] In a first aspect, the present application provides a test case generation method, the method comprising: obtaining object information of the test object when a test object is determined; obtaining a first prompt word through the object information and a first network model, the first network model being used to generate a prompt word; obtaining a second prompt word through a historical test case corresponding to a first test point and the first prompt word, the first test point being determined by the first prompt word; obtaining a target test case through the second prompt word and the second network model, the second network model being used to generate a test case.

[0005] In the second aspect, the present application provides a test case generation device, which includes: an information determination unit, which is used to obtain object information of the test object when the test object is determined; a first prompt word generation unit, which is used to obtain a first prompt word through the object information and a first network model, and the first network model is used to generate a prompt word; a second prompt word generation unit, which is used to obtain a second prompt word through a historical test case corresponding to a first test point and the first prompt word, and the first test point is determined by the first prompt word; a case generation unit, which is used to obtain a target test case through the second prompt word and the second network model, and the second network model is used to generate a test case.

[0006] In a third aspect, the present application provides an electronic device comprising one or more processors and a memory; one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the above-mentioned method.

[0007] In a fourth aspect, the present application provides a computer program product, comprising a computer program or instructions, which implement the above-mentioned method when executed by a processor.

[0008] In a fifth aspect, the present application provides a computer-readable storage medium storing a program code executable by a processor, wherein the computer-readable storage medium includes stored program code, wherein the above method is executed when the program code is run.

[0009] The present application provides a test case generation method, device, and electronic device. In this method, when obtaining object information of the test object, a first prompt word can be obtained through the object information and a first network model. After determining a first test point based on the first prompt word, a second prompt word is obtained through the historical test cases corresponding to the first test point and the first prompt word. Then, a target test case is obtained through the second prompt word and a second network model. Thus, through the above method, when the first prompt word is obtained through the object information, the first test point can be further determined through the first prompt word, so that the first prompt word can be updated based on the historical test cases corresponding to the first test point to obtain a more accurate second prompt word, so that the target test case obtained through the second prompt word and the second network model is more accurate, thereby improving the quality of the test case. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0011] Figure 1 A schematic diagram showing an application scenario of the test case generation method proposed in an embodiment of the present application;

[0012] Figure 2 A schematic diagram showing another application scenario of the test case generation method proposed in an embodiment of the present application is shown;

[0013] Figure 3 A flow chart of a test case generation method proposed in an embodiment of the present application is shown;

[0014] Figure 4 A flow chart of a test case generation method proposed in another embodiment of the present application is shown;

[0015] Figure 5 A flow chart of a test case generation method proposed in another embodiment of the present application is shown;

[0016] Figure 6 A flow chart of a test case generation method proposed in another embodiment of the present application is shown;

[0017] Figure 7 A schematic diagram of a system for executing a test case generation method proposed in an embodiment of the present application is shown;

[0018] Figure 8 A system architecture diagram for executing a test case generation method proposed in an embodiment of the present application is shown;

[0019] Figure 9 A flow chart of a test case generation method proposed in another embodiment of the present application is shown;

[0020] Figure 10 A structural block diagram of a test case generation device proposed in an embodiment of the present application is shown;

[0021] Figure 11 A structural block diagram of an electronic device for executing a test case generation method according to an embodiment of the present application is shown;

[0022] Figure 12 It is a storage unit for storing or carrying program codes for implementing the test case generation method according to an embodiment of the present application. DETAILED DESCRIPTION

[0023] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0024] Test cases are the core vehicle for software testing. By defining input data, execution steps, and expected outputs, they provide a test basis for verifying software functionality, performance, and reliability. However, the inventors of this application discovered that related test case generation methods still suffer from poor quality.

[0025] Therefore, the inventors have proposed a test case generation method, device, and electronic device in the present application. In this method, when obtaining the object information of the test object, a first prompt word can be obtained through the object information and a first network model. Then, after determining the first test point based on the first prompt word, a second prompt word is obtained through the historical test cases corresponding to the first test point and the first prompt word. Then, a target test case is obtained through the second prompt word and the second network model. Thus, through the above method, when the first prompt word is obtained through the object information, the first test point can be further determined through the first prompt word, so that the first prompt word can be updated based on the historical test cases corresponding to the first test point to obtain a more accurate second prompt word, so that the target test case obtained through the second prompt word and the second network model is more accurate, thereby improving the quality of the test case.

[0026] The following first introduces the application scenarios involved in the embodiments of this application.

[0027] In the embodiment of the present application, the test case generation method provided can be executed by an electronic device. In this way, all steps in the test case generation method provided by the embodiment of the present application can be executed by the electronic device. For example, Figure 1 As shown, all steps in the test case generation method provided in the embodiment of the present application can be executed by an application in the electronic device 100. The application can be a test case generation program.

[0028] Alternatively, the test case generation method provided in the embodiment of the present application may also be executed by a server. Accordingly, in this server-side execution mode, the server may begin executing the steps of the test case generation method provided in the embodiment of the present application in response to a trigger instruction. The trigger instruction may be sent by an electronic device used by the user, or may be triggered locally by the server in response to some automated event.

[0029] In addition, the test case generation method provided in the embodiment of the present application can also be executed by the electronic device and the server in collaboration. In this way of collaborative execution by the electronic device and the server, some steps in the test case generation method provided in the embodiment of the present application are executed by the electronic device, while other steps are executed by the server. For example, Figure 2 As shown, electronic device 100 may perform a test case generation method including: determining a test object. Subsequently, electronic device 100 transmits the test object to server 200. Upon receiving the test object, server 200 may perform subsequent steps to obtain a target test case. After obtaining the target test case, server 200 may store the target test case for use in testing the test object.

[0030] It should be noted that in this method of collaborative execution by the electronic device and the server, the steps respectively executed by the electronic device and the server are not limited to the methods introduced in the above examples. In actual applications, the steps respectively executed by the electronic device and the server can be dynamically adjusted according to actual conditions.

[0031] It should be noted that the electronic device 100 is Figure 1 and Figure 2 In addition to the smartphone shown in , it can also be a tablet computer or other device. Server 200 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, as well as a cloud server for basic cloud computing services such as an artificial intelligence platform. In particular, when the test case generation method provided in the embodiment of the present application is executed by a server cluster or distributed system composed of multiple physical servers, different steps in the test case generation method can be executed by different physical servers respectively, or can be executed in a distributed manner by a server built based on a distributed system.

[0032] The embodiments of the present application will be described in detail below with reference to the accompanying drawings.

[0033] See also Figure 3 , this application provides a test case generation method, the method comprising:

[0034] S110: When the test object is determined, obtain object information of the test object.

[0035] In an embodiment of the present application, the test object can be understood as an object to be tested. Wherein, the test object can be a complete program or a partial module in a complete program. Exemplarily, the test object can be an application for running in an electronic device (for example, a camera program, a payment program, etc.), or a functional module in the application (for example, an image optimization module in a camera program, etc.). Alternatively, the test object can be an embedded program. Wherein, an embedded program can be understood as a program running on an embedded system (such as a microcontroller, a single-chip microcomputer, etc.).

[0036] In an embodiment of the present application, the test object can be determined by the user. As a method, a selection interface can be displayed so that the user can determine the test object through the selection interface.

[0037] The object information of the test object can be understood as information that introduces the relevant information of the test object. Optionally, the relevant information can include the functions included in the test object, the services it can provide, the update status, the interface definition, etc.

[0038] As a way, for the test object, there can be corresponding documents (for example, technical documents or requirement documents). In this case, the corresponding object information can be obtained through the test object's documents. Among them, technical documents are detailed materials written for technical personnel such as development, testing, and operation and maintenance, covering professional technical content such as system architecture, interface specifications, database design, and code implementation, which are used to guide the technical implementation process; requirement documents are business description documents for product managers, business parties, and development teams, which include functional requirements, user scenarios, non-functional constraints (such as performance requirements), etc., to clarify the business goals and user value that the software needs to achieve. The two together constitute the complete basis for software development.

[0039] Alternatively, the object information of the test object may be manually input by the user.

[0040] S120: Obtain a first prompt word through the object information and a first network model, where the first network model is used to generate a prompt word.

[0041] In the embodiment of the present application, the first network model can be understood as a model for generating prompt words. Therefore, the first network model can also be a prompt word generation model.

[0042] It should be noted that prompt words are a medium for interacting with the network model. Prompt words can convey the user's operating intention to the network model through structured language, guiding the network model to generate expected output. Among them, the essence of prompt words is to convert the user's needs into machine-understandable instructions and serve as input signals to trigger the operation of the model. In an embodiment of the present application, prompt words (for example, a first prompt word or a subsequent second prompt word) can be understood as keywords, phrases or sentences used to guide the network model to generate specific output information (for example, test cases) during the processing of the network model.

[0043] The first prompt word is obtained through the object information and the first network model, which can be understood as inputting the object information into the first network model to obtain the first prompt word output by the first network model. It should be noted that the currently generated first prompt word will be further optimized in subsequent content, so the currently generated first prompt word can be understood as a preliminary prompt word.

[0044] As a method, the first network model can be trained with a large amount of data so as to accurately understand the object information of the test object and generate targeted prompt words. During the training process, the training data used can include historically determined test objects and the object information corresponding to the historically determined test objects.

[0045] In an embodiment of the present application, the first network model may be a large language model (LLM). It should be noted that a large language model is a language model constructed by a deep neural network containing more parameters, which can be trained using a large amount of unlabeled text using a self-supervised learning method, and can predict and generate text and other content through training with large-scale data sets. Among them, the generation capability of the large language model is one of its core functions, and this capability enables the large language model to automatically generate content based on the input content. In an embodiment of the present application, after obtaining the first conversation data, the first conversation data can be input into the large language model to generate recommendation questions through the large language model. Moreover, the large language model can quickly understand and generate natural language text through deep learning and a large amount of text data training, so that the large language model can complete the generation of prompt words in a shorter time.

[0046] S130: Obtain a second prompt word through a historical test case corresponding to a first test point and the first prompt word, wherein the first test point is determined by the first prompt word.

[0047] It should be noted that, in the embodiment of the present application, the first prompt word is generated by the first network model according to the object information of the test object. Therefore, the first prompt word may carry some content that can characterize the test point of the test object.

[0048] In the embodiments of the present application, test points refer to specific functions, features or business logic points that can be focused on and verified during the test process. As a way, test points can include functional points, business logic points, exception handling points and user experience points in the test object. Among them, functional points include specific functions that the test object needs to implement, such as login, registration, search, etc. Business logic points include logic related to business rules in the test object, such as permission control, etc. Exception handling points can include the performance of the test object under abnormal circumstances, such as input errors, network interruptions, etc. User experience points can include details related to user interaction, such as interface layout, response speed, etc.

[0049] Therefore, if the first prompt word carries some content that can represent the test point, the corresponding historical test case can be obtained through the first prompt word. The historical test case can be understood as the test case used in the previous test process to test the test point represented by the first prompt word.

[0050] When historical test cases are obtained, the first prompt word can be further enriched and expanded through the historical test cases to obtain the second prompt word.

[0051] Historical test cases contain a wealth of testing experience and information. They detail how to test each test point involved in the first prompt (e.g., functional points, business logic points, exception handling points, user experience points, etc.). Using these historical test cases, the first prompt can be further enriched and expanded to obtain the second prompt.

[0052] Specifically, on the one hand, the information such as the test steps and expected results in the historical test case can supplement more details for the first prompt word, making its description more accurate and complete. For example, for the login function point, the historical test case may record in detail the test steps and expected results under various situations such as normal login, password error login, account lock login, etc. Integrating this information into the first prompt word can allow the second prompt word to more comprehensively cover the various test scenarios of the login function. On the other hand, historical test cases can also introduce new test ideas for the first prompt word. In the past testing process, the tester may have discovered some problems or potential test points that were not considered in the initial first prompt word. By adding these new contents into the first prompt word, the second prompt word can be made more targeted and comprehensive, better guiding subsequent testing work.

[0053] For example, assume that the first prompt word is: "For an online shopping platform, generate prompt words for testing the login function." According to the previous description, the first prompt word generated by the first network model based on the object information may be: "Test the login function of the online shopping platform, including normal login and incorrect password login scenarios." By searching historical test cases, the following relevant information can be found: Normal login scenario: In addition to the conventional username and password login, historical test cases also record the test steps and expected results for logging in using a third-party account. Incorrect password login scenario: Historical test cases describe in detail how to handle the account being locked after entering the wrong password multiple times in a row, as well as the process of unlocking the account. Other related scenarios: also include the handling of network interruptions during the login process, and test points on user experience such as whether the interface jumps correctly after login.

[0054] Based on these historical test cases, the first prompt word can be enriched and expanded to obtain the second prompt word: "Test the login function of the online shopping platform, including: 1. Normal login scenario, covering username and password login and login using a third-party account, verifying whether the correct jump to the homepage is made after a successful login; 2. Incorrect password login scenario, testing whether the account is locked after multiple consecutive incorrect password entries, and whether the account unlocking process is correct; 3. Network interruption scenario, verifying how login requests are handled in the event of a network interruption, and whether login operations can continue after the network is restored; 4. User experience after login, checking whether the interface layout after login is reasonable and whether the response speed meets the requirements." Through this expansion, the second prompt word covers all aspects of the online shopping platform login function in a more comprehensive and detailed manner, providing more accurate guidance for subsequent testing work.

[0055] S140: Obtain a target test case through the second prompt word and the second network model, where the second network model is used to generate a test case.

[0056] In the embodiments of the present application, the second network model is a model for generating test cases. In other words, the second network model can be understood as a test case generation model. When a second prompt word is obtained, the second prompt word can be input into the second network model so that the corresponding target test case can be output through the second network model. After obtaining the target test case, the target test case can be stored so that the test object can be tested using the target test case.

[0057] This embodiment provides a test case generation method, which enables, through the above-mentioned method, when a first prompt word is obtained through object information, the first test point determined by the first prompt word to update the first prompt word based on the historical test case corresponding to the first test point to obtain a more accurate second prompt word, so that the target test case obtained through the second prompt word and the second network model is more accurate, thereby improving the quality of the test case.

[0058] See also Figure 4 The present application provides a test case generation method, which is applied to electronic devices and includes:

[0059] S210: When the test object is determined, obtain object information of the test object.

[0060] S220: Obtain a first prompt word through the object information and a first network model, where the first network model is used to generate a prompt word.

[0061] S230: Obtain a first test point through the first prompt word, the second test point, and the second network model, wherein the second test point belongs to at least part of the historical test points of the test object.

[0062] In the embodiment of the present application, the second test point can be understood as a universal test point.

[0063] The second network model can be used to generate not only test cases but also test points. For example, the second test point and the first prompt word can be input into the second network model, and the test point output by the second network model can be used as the first test point.

[0064] As one approach, obtaining the first test point using the first prompt word, the second test point, and the use case generation model may include: obtaining a third test point using the first prompt word, the second test point, and the second network model; and obtaining the first test point selected by the user from the third test point. It should be noted that the third test point is a test point directly generated by the second network model. Therefore, the third test point may include test points that do not meet the user's current testing requirements. By having the user select some test points from the third test point as the first test point, the obtained first test point can be made more consistent with the user's current testing requirements.

[0065] For example, the third test point output by the second network model may include test point T1, test point T2, test point T3, test point T4, and test point T5. If the user selects test point T1, test point T2, and test point T3, then test point T1, test point T2, and test point T3 may be determined as the first test point.

[0066] S240: Obtain a second prompt word through a historical test case corresponding to a first test point and the first prompt word, wherein the first test point is determined by the first prompt word.

[0067] S250: Obtain a target test case through the second prompt word and the second network model, where the second network model is used to generate a test case.

[0068] This embodiment provides a test case generation method that can improve the quality of test cases. Furthermore, in this embodiment, after obtaining a first prompt word, the first test point can be obtained using the first prompt word, the second test point, and the second network model. This allows for more accurate determination of the first test point, thereby facilitating a better fit between the ultimately determined target test case and the test object.

[0069] See also Figure 5The present application provides a test case generation method, which is applied to electronic devices and includes:

[0070] S310: When the test object is determined, object information of the test object is obtained, where the object information is obtained through a document corresponding to the test object, and the document content of the document includes text and / or images.

[0071] It should be noted that the document of the test object may be written manually, or the document content in the document may come from multiple sources. Therefore, the document content in the document may not clearly and accurately represent the original intention, or its actual meaning may not be recognized. For example, the text in the document may not be semantically smooth or ambiguous. In this case, the purpose of preprocessing the document content is to make the document content more clearly express the original meaning. Among them, the documents corresponding to the test object can include technical documents and requirement documents.

[0072] Based on the foregoing, as a way to obtain object information, when a document of the test object is obtained, the document content of the document can be preprocessed to obtain preprocessed document content, and the object information can be obtained through the preprocessed document content. In an embodiment of the present application, the corresponding preprocessing method may be different for different document contents. For example, when the document content includes images, the preprocessing may include improving the clarity of the image; when the document content includes text, the preprocessing may include improving the readability of the text. In addition, the preprocessing may also include filtering images in the document that do not meet the first condition; and filtering text in the document that does not meet the second condition. Among them, the first condition may include: images with clarity lower than a preset level and whose clarity cannot be improved. The second condition may include: text that is not related to the test object.

[0073] Among them, in the preprocessing of documents, the optimization of images and texts is an important part of improving the quality of documents. As shown in the above content, one of the functions of preprocessing is to make up for the limitations of manual writing through technical means, so that the document content can convey the original information more accurately. Among them, the images in the document may include pictures and / or videos. In one way, for documents that include pictures, preprocessing can be used to improve the quality of pictures, such as super-resolution reconstruction or denoising of blurred screenshots, which can improve the details of the pictures; if the pictures included in the text are low-pixel photos, the edges and contrast can be enhanced by algorithms, or converted into vector graphics to avoid scaling distortion. For example, for screenshots of software interfaces in documents, super-resolution reconstruction can be performed to ensure that buttons and menu items are clearly visible.

[0074] For text content, preprocessing can further improve readability, such as logically splitting lengthy paragraphs, adding subheadings or bullet points, explaining specialized terms (such as "interface call" and "database transaction"), and correcting grammatical errors. For example, after preprocessing, a blurry screenshot of a registration page in a software user manual has clearly visible input boxes and verification prompts. The operation steps are also broken down into numbered processes, and key terms are given concise explanations, making it easier to quickly and accurately understand the implementation logic. This, in turn, helps generate clearer, more complete, and more accurate object information.

[0075] S320: Obtain a first prompt word through the object information and a first network model, where the first network model is used to generate a prompt word.

[0076] S330: Obtain a second prompt word through a historical test case corresponding to a first test point and the first prompt word, wherein the first test point is determined by the first prompt word.

[0077] S340: Obtain a target test case through the second prompt word and the second network model, where the second network model is used to generate a test case.

[0078] This embodiment provides a test case generation method to improve the quality of test cases. Furthermore, in this embodiment, after obtaining the technical documentation of the test object, the document content of the test document is preprocessed to obtain preprocessed document content. Object information is obtained from the preprocessed document content, so that the preprocessed document content can more accurately express the original meaning, thereby facilitating a more accurate determination of the target test case.

[0079] See also Figure 6 The present application provides a test case generation method, which is applied to electronic devices and includes:

[0080] S410: When the test object is determined, obtain object information of the test object.

[0081] S420: Obtain a first prompt word through the object information, the first network model and the template prompt word, wherein the first network model is used to generate the prompt word, wherein the template prompt word is obtained by training the first network model and training data.

[0082] It should be noted that, in the embodiment of the present application, the prompt word itself can be understood as a framework template. And the template prompt word therein can be understood as a more general prompt word. Moreover, the template prompt word has already performed a templated definition of some content. After obtaining the object information, the template prompt word can be further targeted updated according to the object information to obtain the first prompt word, so that in the process of generating the first prompt word, the first network model can update the template prompt word according to the object information, and the first prompt word for the test object can be obtained, so that not only the first prompt word can be generated more quickly, but also the content of the generated first prompt word is more in line with predetermined rules (i.e., the rules defined in the template prompt word), so as to generate higher quality test cases.

[0083] In an embodiment of the present application, multiple trainings can be performed using the training data and the first network model to obtain template prompt words. As one method, the process of obtaining the template prompt words includes: in each training process, scoring the multiple candidate prompt words output by the first network model using the scoring model, and determining the target prompt word based on the scores of the multiple candidate words using the evaluation model. If the score of the target prompt word obtained in the current training process meets the scoring conditions, the template prompt word is obtained using the target prompt word obtained in the current training process; otherwise, the next training process is entered; wherein, in the first training process, the multiple candidate prompt words are obtained by the first network model based on the training data, and in the second training process, the multiple candidate prompt words are obtained by the first network model based on the target prompt word determined in the previous training process. The training data can be object information obtained historically.

[0084] Exemplarily, during the first training process, the first network model outputs multiple candidate prompt words based on training data, including prompt word T11, prompt word T12, prompt word T13, and prompt word T14. These multiple prompt words can then be scored using a scoring model to obtain scores for prompt word T11, prompt word T12, prompt word T13, and prompt word T14. The evaluation model can then determine a target prompt word based on the scores of these multiple prompt words. For example, if prompt word T11 is determined to be the target prompt word, prompt word T11 can be input into the first network model, allowing the first network model to generate multiple prompt words similar to prompt word T11 based on prompt word T11. Approximate prompt words can be understood as words with similar semantics but different expressions. Exemplarily, the multiple prompt words similar to prompt word T11 can include prompt word T21, prompt word T22, and prompt word T23. In this case, during the second training process, the multiple candidate prompt words included include prompt word T11, prompt word T21, prompt word T22 and prompt word T23, thereby repeating the above process. If a target prompt word that meets the scoring conditions is generated, the training is terminated.

[0085] S430: Obtain a second prompt word through a historical test case corresponding to a first test point and the first prompt word, wherein the first test point is determined by the first prompt word.

[0086] S440: Obtain a target test case through the second prompt word and the second network model, where the second network model is used to generate a test case.

[0087] This embodiment provides a test case generation method to improve the quality of test cases. Furthermore, in this embodiment, a first prompt word can be obtained using object information, a first network model, and a template prompt word. The template prompt word is obtained by training the first network model and training data multiple times, thereby enabling the first network model to more accurately generate corresponding prompt words (e.g., the first prompt word) based on the input.

[0088] In one embodiment, the test case generation method provided in the present application can be applied to a test case generation system. Figure 7 As shown, the test case generation system may include the data layer, prompt engineering, and model reasoning.

[0089] Among them, for the data layer, the corpus (for example, PDF corpus) can be hierarchically parsed and identified and text extracted, and the key information of the requirements can be selected and added to the vector (vectorized embedding) database; the image is extracted by the network model (for example, GPT-4o model), and the extraction results are added to the vector database. Among them, when performing prompt engineering training, in addition to using the data in the vector database, existing test cases can also be added. In addition, when generating test cases, test checkpoints can be added to the vector database to facilitate the generation of target test cases based on test checkpoints.

[0090] Prompt Engineering: This layer uses the aforementioned vector database built based on historical requirement documents and test cases as training data, and uses the Automatic Prompt Engineering (APE) method to construct the prompt engineering. In the process of constructing the prompt engineering, the inference model can generate multiple candidate prompt words, which are passed into the target model for scoring, and the score of each candidate word is passed into the evaluation model for evaluation, so that the evaluation model can select the prompt word with the highest score as the target prompt word. The target prompt word can be re-introduced into the inference model to generate a variant of the target prompt word (which can be understood as a prompt word that is similar to the target prompt word). Then, the previous process can be repeated based on the variant of the target prompt word and the target prompt word (i.e., Figure 7 The cycle between the three models involved in the prompt project) until the best prompt word is selected. Among them, the best prompt word can be understood as the target prompt word generated to meet the scoring conditions. Figure 7 The reasoning model, target model, and evaluation model shown in can all be generated based on the GPT-4 model, or can also be other types of large prediction models.

[0091] As a method, the test case generation method provided in the embodiment of the present application can be applied to a test case generation system. The test case generation system may include: an image processing unit, an information analysis unit, a test case generation unit, an automatic prompt optimization unit, and a user interaction unit.

[0092] The image processing unit may include an image restoration subunit, an image extraction subunit, and an image filtering subunit.

[0093] Among them, the image restoration subunit can use deep learning algorithms (such as convolutional neural networks) to process images in documents (for example, requirement documents and technical documents) to improve the clarity and readability of the images. The image restoration subunit can use denoising technology and detail enhancement technology to ensure the accuracy of image information. The image extraction subunit can use optical character recognition technology (OCR) to extract text and graphic elements from the clarified image as structured text information. The image extraction subunit can recognize a variety of fonts and formats to ensure accurate extraction of information from various documents. Image filtering subunit: Use optical character recognition technology to filter images containing keywords, thereby reducing the cost of subsequent analysis; use image classification algorithms to mark and model invalid images accumulated over a long period of time, reducing analysis time while further improving the efficiency of image analysis.

[0094] As a method, the image processing unit may be a unit for performing pre-processing on the image in the document in the embodiment of the present application.

[0095] The information analysis unit is responsible for semantic analysis and requirement resolution of the text in the document. It uses Natural Language Processing (NLP) technology to identify key elements in the document (including functional points, boundary conditions, and business rules). Furthermore, the information analysis unit can map historical test case content into vectors (e.g., 384 dimensions) using a network model (e.g., all-minilm-l6-v2) and store them in a database (e.g., a Chroma database). It can also associate historical requirements with historical test cases to improve the business compatibility of the use case generation model.

[0096] As one approach, the information analysis unit can be used to construct the aforementioned training data. The content stored in the database can serve as the training data. Alternatively, the information analysis unit can be used to analyze the test subject's document after obtaining it to obtain subject information. For example, the information analysis unit can be used to analyze preprocessed text to obtain subject information.

[0097] The test case generation unit can utilize the information provided by the analysis unit (e.g., object information in the embodiment of the present application) to automatically generate corresponding test cases (e.g., target test cases). The test case generation unit can dynamically adjust the number and details of test cases based on the complexity and changes of requirements to ensure that all key test points are covered.

[0098] The automatic prompt optimization unit is used to generate optimized prompt words in real time based on the generated test cases and extracted information. It uses machine learning algorithms to analyze the context and provide recommendations related to the test cases, helping testers quickly identify key test points and potential risks. For example, prompt words can be further optimized using an APE model. As a method, the automatic prompt optimization unit can be used to execute the aforementioned process of obtaining template prompt words.

[0099] The user interaction unit provides a user interface for testers to view, edit, and manage generated test cases. The user interaction unit supports version control and tracking of test cases and provides feedback functions for testers to evaluate and adjust generated test cases.

[0100] As a way, the architecture of the system to which the test case generation method provided in the embodiment of the present application is applied can be as follows: Figure 8 As shown, Figure 8 The system shown includes an interface layer, an integration layer, an atomic layer, and an external layer.

[0101] The interface layer implements functions such as test checkpoint generation, test case generation, and acquisition of test case modification suggestions. Test checkpoint generation involves generating test checkpoints for corresponding requirements using the test case generation model. Acquiring test case modification suggestions involves acquiring and saving user modifications to generated test cases.

[0102] Among them, the functions to be implemented by the integration layer include: information reading and writing services, configuration management services, use case generation services, information learning services, association search services, and model training services. Among them, information reading and writing services include data collection services, text extraction services, image recognition services, and policy services, which are used to implement information reading and writing functions such as document reading and prompt word generation. The configuration management service is used to combine the configuration service and the policy service to achieve the management of all configurations. The use case generation service is used to combine the use case generation model and the prompt service to design and generate test cases for the prompts generated by the prompt service. The association search service is used to call historical use cases in the R&D cloud through the data collection service, etc., to achieve association with historical use cases and improve the accuracy of use case generation. The model training service is used to train the model by combining historical use cases and modified use cases.

[0103] Among them, the functions to be implemented by the atomic layer include: prompt service, configuration service, text extraction service, image recognition service, data collection service and policy service. Among them, the prompt service is used to call the interface of the prompt generation model through appropriate descriptions to generate text (for example, the first prompt word or the second prompt word) that can be input into the use case generation model. The configuration service is used to record the configuration required for all services. The text extraction service is used to extract the text part of the content and integrate it into appropriate information based on the content returned by the interface. The image recognition service is used to extract the image part of the content and integrate it into appropriate information based on the content returned by the interface. The data collection service is used to call the interface of the R&D cloud to obtain historical use cases and requirements for fine-tuning the model, and call the interface to obtain specified requirements during the application process. The policy service is used to combine with other services to generate an integration layer service with appropriate policies.

[0104] The external layer implements functions such as a prompt generation model, a use case generation model, an R&D cloud, and documentation. The prompt generation model is used to generate prompts in the prompt project. The use case generation model takes appropriate prompts as input and outputs a large language model of the expected test cases. The R&D cloud is a work platform for storing historical test cases and historical requirements information.

[0105] Next, pass Figure 9 The process of a test case generation method involved in an embodiment of the present application is described.

[0106] like Figure 9 The process shown involves three parts: the big model, the use case generation tool, and the data source.

[0107] First, the user can enter the requirement ID through the use case generation tool, create a use case generation task based on the user-entered requirement ID, and associate the use case generation task with the corresponding requirement. During the creation of the use case generation task, the user can request documents and common test points corresponding to the test object (determined by the requirement ID) from the R&D cloud. Relevant information corresponding to the product being developed can be stored on the document platform. In these cases, the documents corresponding to the test object can be obtained through the document platform.

[0108] After obtaining the document of the test object, the document preprocessing step can be triggered. In the document preprocessing step, a model for document preprocessing (for example, a GPT-4o model) can be used to identify key text information in the document through the model, and to identify and refine the information of the image in the document to obtain image information, and then generate prompt requirement information through the key text information, image information and prompt service. Among them, the prompt service can be understood as the service provided by the aforementioned first network model. Therefore, the prompt requirement information generated by the prompt service can be understood as the aforementioned first prompt word.

[0109] After obtaining the prompt requirement information, the aggregated test points can be obtained using the prompt requirement information, the universal test points, and the network model used to generate the test points. The universal test points here can be understood as the aforementioned second test points, and the aggregated test points can be understood as the third test points. The network model used to generate the test points can be understood as the aforementioned second network model. Exemplarily, the second network model can be a model established based on GPT-4.

[0110] After the third test point is obtained, the third test point may be displayed through an interface so that the user can select a desired test point from the third test points as the first test point.

[0111] After obtaining the first test point, the corresponding historical test case can be obtained through the first test point. The corresponding historical test case can be obtained based on the first test point using a model for obtaining historical test cases. The model for obtaining historical test cases can be the aforementioned second network model. Exemplarily, the model for obtaining historical test cases can be established based on GPT-4.

[0112] In the process of obtaining historical test cases, the first test point can be classified, and then according to the classification results, the historical test cases corresponding to each classification can be obtained from the vector database to obtain the historical test cases corresponding to the first test point.

[0113] After obtaining the historical test case corresponding to the first test point, a second prompt word can be derived based on this historical test case and the first prompt word. This second prompt word is then passed into the test case generation model to obtain the target test case. The test case generation model can be understood as the aforementioned second network model. The target test case can also be converted to Xmind format for interface display.

[0114] It should be noted that in the embodiments of the present application, there is no specific limitation on the first network model and the specific model category of the first network model. In addition to GPT-4 as an example, it can also be implemented through other large oracle models.

[0115] See also Figure 10 The present application provides a test case generation device, the device 500 comprising:

[0116] The information determining unit 510 is configured to obtain object information of the test object when the test object is determined.

[0117] The first prompt word generating unit 520 is configured to obtain a first prompt word through the object information and a first network model, where the first network model is used to generate a prompt word.

[0118] The second prompt word generating unit 530 is configured to obtain a second prompt word through the historical test case corresponding to the first test point and the first prompt word, wherein the first test point is determined by the first prompt word.

[0119] The use case generating unit 540 is configured to obtain a target test case using the second prompt word and the second network model, where the second network model is used to generate a test case.

[0120] As a method, the second prompt word generation unit 530 is further used to obtain a first test point through the first prompt word, the second test point and the second network model; wherein the second test point belongs to at least part of the historical test points of the test object.

[0121] Optionally, the second prompt word generating unit 530 is further specifically configured to obtain a third test point through the first prompt word, the second test point, and the second network model; and obtain a first test point selected by the user from the third test point.

[0122] As a method, the information determining unit 510 is specifically configured to obtain the object information through the technical document of the test object, wherein the document content includes text and / or images.

[0123] Optionally, the information determination unit 510 is specifically used to preprocess the document content of the test document to obtain preprocessed document content when obtaining the technical document of the test object; obtain object information through the preprocessed document content; wherein the preprocessing includes one or more of the following multiple operations, and the multiple operations include: improving the clarity of the image; improving the readability of the text; filtering images in the document that do not meet the first condition; and filtering text in the document that does not meet the second condition.

[0124] As a method, the first prompt word generation unit 520 is specifically used to obtain the first prompt word through the object information, the first network model and the template prompt word; wherein, the template prompt word is obtained by multiple trainings using the first network model and training data.

[0125] Optionally, the process of obtaining the template prompt word includes: in each training process, scoring the multiple candidate prompt words output by the first network model through the scoring model, and determining the target prompt word based on the scores of the multiple candidate words through the evaluation model; if the score of the target prompt word obtained in the current training process meets the scoring condition, the template prompt word is obtained through the target prompt word obtained in the current training process, otherwise, entering the next training process; wherein, in the first training process, the multiple candidate prompt words are obtained by the first network model based on the training data, and in the second training process, the multiple candidate prompt words are obtained by the first network model based on the target prompt word determined in the previous training process.

[0126] This embodiment provides a test case generation device, so that when the first prompt word is obtained through the object information of the currently determined test object, the first test point can be further determined by the first prompt word, so that the first prompt word can be updated based on the historical test case corresponding to the first test point to obtain a more accurate second prompt word, so that the target test case obtained by the second prompt word and the second network model is more accurate, thereby improving the quality of the test case.

[0127] It should be noted that the device embodiment in this application corresponds to the aforementioned method embodiment, and the specific implementation principles of each unit in the device embodiment are similar to the principles in the aforementioned method embodiment. The specific contents in the device embodiment can be found in the method embodiment, and will not be repeated in the device embodiment.

[0128] The following will be combined Figure 11 An electronic device provided by this application is described.

[0129] See also Figure 11 Based on the above-mentioned test case generation method and apparatus, the embodiments of the present application further provide an electronic device 1000 that can execute the above-mentioned test case generation method. The electronic device 1000 includes one or more (only one is shown in the figure) processors 105, a memory 104, an audio playback module 106, and an audio acquisition device 108 that are coupled to each other. The memory 104 stores a program that can execute the content of the above-mentioned embodiments, and the processor 105 can execute the program stored in the memory 104.

[0130] The processor 105 may include one or more processing cores. The processor 105 utilizes various interfaces and circuits to connect various components within the electronic device 1000. It executes instructions, programs, code sets, or instruction sets stored in the memory 104, and accesses data stored in the memory 104 to perform various functions and process data within the electronic device 1000. Optionally, the processor 105 may be implemented using at least one of the following hardware forms: a digital signal processing (DSP), a field-programmable gate array (FPGA), or a programmable logic array (PLA). The processor 105 may integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. The CPU primarily processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem handles wireless communications. It is understood that the modem may not be integrated into the processor 105 and may be implemented separately via a communication chip.

[0131] The memory 104 may include a random access memory (RAM) or a read-only memory (ROM). The memory 104 may be used to store instructions, programs, codes, code sets, or instruction sets. The memory 104 may include a program storage area and a data storage area. The program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc.

[0132] Furthermore, in addition to the aforementioned components, the electronic device 1000 may further include a network module 110 and a sensor module 112 .

[0133] The network module 110 is used to realize information interaction between the electronic device 1000 and other devices. For example, a connection can be established with other audio playback devices or other electronic devices, and information interaction is performed based on the established connection. As a way, the network module 110 of the electronic device 1000 is a radio frequency module, which is used to receive and send electromagnetic waves, realize the mutual conversion of electromagnetic waves and electrical signals, and thus communicate with a communication network or other devices. The radio frequency module may include various existing circuit elements for performing these functions, such as antennas, radio frequency transceivers, digital signal processors, encryption / decryption chips, user identity modules (SIM) cards, memories, etc. For example, the radio frequency module can interact with external devices by sending or receiving electromagnetic waves.

[0134] The sensor module 112 may include at least one sensor. Specifically, the sensor module 112 may include, but is not limited to: a pressure sensor, a motion sensor, an acceleration sensor, and other sensors.

[0135] Among them, the pressure sensor can be a sensor that detects pressure generated by pressing on the electronic device 1000. That is, the pressure sensor detects pressure generated by contact or pressing between the user and the electronic device 1000, for example, pressure generated by contact or pressing between the user's ear and the electronic device 1000. Therefore, the pressure sensor can be used to determine whether contact or pressing occurs between the user and the electronic device 1000, and the magnitude of the pressure.

[0136] The accelerometer can detect the magnitude of acceleration in all directions (generally three axes) and the magnitude and direction of gravity when stationary. This can be used for applications that recognize the posture of the electronic device 1000 (such as switching between landscape and portrait modes, related games, and magnetometer posture calibration), vibration recognition-related functions (such as pedometers and tapping), etc. In addition, the electronic device 1000 may also be equipped with other sensors such as a gyroscope, barometer, hygrometer, and thermometer, which will not be detailed here.

[0137] The audio collection device 110 is used to collect audio signals. Optionally, the audio collection device 110 includes multiple audio collection devices, which may be microphones.

[0138] Please refer to Figure 12 , which shows a block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 1100 stores program code, which can be called by a processor to execute the method described in the above method embodiment.

[0139] Computer-readable storage medium 1100 may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, hard disk, or ROM. Alternatively, computer-readable storage medium 1100 may include a non-transitory computer-readable storage medium. Computer-readable storage medium 1100 may have storage space for program code 1110 for executing any of the method steps described above. These program codes may be read from or written to one or more computer program products. Program code 1110 may be compressed, for example, in a suitable form.

[0140] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine different embodiments or examples described in this specification and features of different embodiments or examples without contradiction.

[0141] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of the technical features being referred to. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of such features. Throughout the description of this application, "plurality" means at least two, for example, two, three, etc., unless otherwise specifically defined.

[0142] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code comprising one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may be performed out of the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present application belong.

[0143] The logic and / or steps represented in the flowchart or otherwise described herein may be considered, for example, as an ordered list of executable instructions for implementing logical functions, and may be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other system that can fetch and execute instructions from an instruction execution system, apparatus, or device).

[0144] In summary, the present application provides a test case generation method, device, and electronic device. In this method, when obtaining the object information of the test object, a first prompt word can be obtained through the object information and the first network model. After determining the first test point based on the first prompt word, a second prompt word is obtained through the historical test case corresponding to the first test point and the first prompt word. Then, a target test case is obtained through the second prompt word and the second network model. Therefore, through the above method, when the first prompt word is obtained through the object information, the first test point can be further determined through the first prompt word, so that the first prompt word can be updated based on the historical test case corresponding to the first test point to obtain a more accurate second prompt word, so that the target test case obtained through the second prompt word and the second network model is more accurate, thereby improving the quality of the test case.

[0145] In one embodiment, an embodiment of the present application relates to an intelligent system for adaptively generating test cases based on requirement documents and technical documents. The intelligent system combines an image restoration algorithm, an image extraction algorithm, and an automatic prompt word optimization algorithm to improve the quality and efficiency of test case generation.

[0146] Among them, some innovative points in the embodiments of this application also include:

[0147] 1. Application of image restoration algorithms. This embodiment of the application utilizes advanced image restoration algorithms to process images in requirements and technical documents to enhance their clarity and readability. This process removes image noise and enhances image detail, making the key information extracted from the documents more accurate and ensuring that the generated test cases fully reflect the actual requirements and functionality of the software.

[0148] 2. Application of an image extraction algorithm. This embodiment of the application introduces an efficient image extraction algorithm to convert image information into structured text data. This algorithm can identify text and graphic elements in images and convert them into text information that can be used for subsequent analysis. This ensures that all relevant requirements and functional points are extracted from the image, providing a comprehensive foundation for test case generation.

[0149] 3. Application of an Automatic Prompt Optimization Algorithm. This embodiment of the present application also includes an automatic prompt optimization algorithm designed to perform real-time optimization based on extracted text information and generated test cases. This algorithm analyzes context and automatically generates prompts and suggestions related to the test case, helping testers quickly locate key test points and improving test case design efficiency.

[0150] 4. Adaptive test case generation. By combining the above technologies, the embodiments of the present application realize the ability of adaptive test case generation, which can dynamically adjust test cases according to changes in requirements and technical documents to ensure the comprehensiveness and effectiveness of test coverage.

[0151] In summary, the embodiments of the present application provide an efficient and intelligent test case generation solution by combining image restoration, image extraction and automatic prompt word optimization technologies, which significantly improves the quality and efficiency of software testing and has important application value and market potential.

[0152] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical feature diagrams therein. These modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A test case generation method, characterized in that: The method comprises: When the test object is determined, obtaining object information of the test object; Obtaining a first prompt word through the object information and a first network model, wherein the first network model is used to generate the prompt word; Obtaining a second prompt word through a historical test case corresponding to a first test point and the first prompt word, wherein the first test point is determined by the first prompt word; A target test case is obtained through the second prompt word and the second network model, and the second network model is used to generate a test case.

2. The method according to claim 1, characterized in that The method further comprises: Obtaining a first test point through the first prompt word, the second test point, and the second network model; The second test points belong to at least part of the historical test points of the test object.

3. The method according to claim 2, characterized in that The step of obtaining the first test point by using the first prompt word, the second test point, and the use case generation model includes: Obtaining a third test point through the first prompt word, the second test point, and the second network model; A first test point selected by a user from the third test points is obtained.

4. The method according to claim 1, wherein The object information is obtained through a document corresponding to the test object, and the document content includes text and / or images.

5. The method according to claim 4, characterized in that The acquiring of the object information of the test object includes: when a document of the test object is obtained, preprocessing the document content of the document to obtain preprocessed document content; Object information is obtained through preprocessed document content, wherein the preprocessing includes one or more of the following operations, the multiple operations including: improving image clarity; improving text readability; filtering images in the document that do not meet a first condition; and filtering text in the document that does not meet a second condition.

6. The method according to claim 1, characterized in that The obtaining of the first prompt word through the object information and the first network model includes: Obtaining a first prompt word through the object information, the first network model, and the template prompt word; The template prompt words are obtained by training through a first network model and training data.

7. The method according to claim 6, characterized in that The process of obtaining the template prompt word includes: In each training process, the scoring model is used to score the multiple candidate prompt words output by the first network model, and the evaluation model is used to determine the target prompt word based on the scores of the multiple candidate words. If the score of the target prompt word obtained in the current training process meets the scoring conditions, the template prompt word is obtained based on the target prompt word obtained in the current training process. Otherwise, the next training process is entered; In the first training process, multiple candidate prompt words are obtained by the first network model based on training data, and in the second training process, multiple candidate prompt words are obtained by the first network model based on target prompt words determined in the previous training process.

8. A test case generating device, characterized in that: The device comprises: an information determining unit, configured to obtain object information of the test object when a test object is determined; a first prompt word generating unit, configured to obtain a first prompt word through the object information and a first network model, wherein the first network model is used to generate the prompt word; a second prompt word generating unit, configured to obtain a second prompt word by using a historical test case corresponding to a first test point and the first prompt word, wherein the first test point is determined by the first prompt word; The use case generating unit is used to obtain a target test case through the second prompt word and the second network model, and the second network model is used to generate a test case.

9. An electronic device, characterized in that: including one or more processors and memory; One or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method according to any one of claims 1 to 7.

10. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Method, device and equipment for generating test case based on large language model

    CN120803950A

  • Methods, apparatus, and devices for generating test cases based on large language models

    CN120803950B