Code testing method and device, computer equipment and storage medium
By building a target knowledge graph and using task prompt words and analysis models for intelligent testing, the existing code testing methods are solved, and an automated and efficient code testing process is realized.
Patent Information
- Application Number
- CN202510219309.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-26
- Publication Date
- 2025-07-11
AI Technical Summary
Existing code testing methods are inefficient and have poor analysis accuracy, and cannot adapt to the development and operation and maintenance requirements of fast iteration and frequent delivery. Auxiliary analysis tools rely on manual interaction and experience to lead to unstable results.
By obtaining target test requests, determining the test input information and types, building a target knowledge graph, finding matching test design tasks, using task prompt words, analysis models and output templates for intelligent full-process testing, and generating and executing test cases.
It realizes the automation and intelligence of the test process, reduces manual operations, improves testing efficiency and accuracy, and can fully cover complex testing scenarios.
Smart Images

Figure CN120295903A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software development, and in particular, to a code testing method, apparatus, computer device, and storage medium. Background Art
[0002] In the process of software development, code testing is a key link to ensure the stability and security of software systems. Traditional code testing methods require manual design of test plans and test cases. The test work scenario is complex, time-consuming and laborious, and it is easy to have omissions and deviations in test plans and test cases. The professional level differences among different testers will also affect the quality of test cases. Therefore, many auxiliary analysis tools for code testing have emerged in the software industry.
[0003] In the prior art, although the auxiliary analysis tools can assist testers in improving work efficiency throughout the test development cycle, these auxiliary analysis tools are generally static analysis tools and are restricted by the inherent rule set, and cannot meet the requirements of rapid iteration and frequent delivery in development and operation and maintenance. For example: the tool needs to interact with the user frequently to ask and answer questions during operation, with slow response speed and complex interaction steps; the tool depends on the questioning method and personal experience when interacting with the user, resulting in unstable and inaccurate output results; the tool has deviations in understanding business knowledge during interactive analysis, the answers to difficult problems are not ideal, and the comprehensiveness and depth of analysis are insufficient, etc. Therefore, the existing auxiliary analysis tools will reduce the test efficiency and affect the accuracy of test analysis. Summary of the Invention
[0004] Based on this, it is necessary to provide a code testing method, apparatus, computer device, and storage medium for the above technical problems to solve the problems of low test efficiency and poor test analysis accuracy in the existing code testing methods.
[0005] A code testing method includes: Obtain a target test request, and determine test input information and a target test type according to the target test request; Determine the code to be tested and a test plan file according to the test input information, and preprocess the code to be tested and the test plan file to obtain a target knowledge graph corresponding to the target test request; Find a target test design task matching the target test type from a preset test task list; Determine a task prompt word, a task analysis model, and a task output template according to the target test design task, perform a retrieval and recall process on the target knowledge graph according to the task prompt word to obtain a retrieval and recall result corresponding to the task prompt word, perform an analysis process on the retrieval and recall result through the task analysis model to obtain a model analysis result corresponding to the task analysis model, and perform a process on the model analysis result according to the task output template to obtain a task output result; When confirming that the task output result is the target test case of the code to be tested, perform a test process on the code to be tested according to the target test case to obtain a target test result.
[0006] A code testing device, comprising: A test request acquisition module, configured to acquire a target test request, and determine test input information and a target test type according to the target test request; An input information preprocessing module, configured to determine the code to be tested and a test scheme file according to the test input information, and perform preprocessing on the code to be tested and the test scheme file to obtain a target knowledge graph corresponding to the target test request; A test task determination module, configured to find a target test design task that matches the target test type from a preset test task list; A test case generation module, configured to determine a task prompt word, a task analysis model, and a task output template according to the target test design task, perform a retrieval and recall process on the target knowledge graph according to the task prompt word to obtain a retrieval and recall result corresponding to the task prompt word, perform an analysis process on the retrieval and recall result through the task analysis model to obtain a model analysis result corresponding to the task analysis model, and perform a process on the model analysis result according to the task output template to obtain a task output result; A test result acquisition module, configured to perform a test process on the code to be tested according to the target test case to obtain a target test result when confirming that the task output result is the target test case of the code to be tested.
[0007] A computer device, comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein when the processor executes the computer-readable instructions, the above-mentioned code testing method is implemented.
[0008] A computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the one or more processors are caused to execute the code testing method as described above.
[0009] In the above code testing method, apparatus, computer device, and storage medium, the code testing method obtains a target test request, determines test input information and a target test type according to the target test request; determines the code to be tested and a test scenario file according to the test input information, and preprocesses the code to be tested and the test scenario file to obtain a target knowledge graph corresponding to the target test request; searches for a target test design task matching the target test type from a preset test task list, and determines a task prompt word, a task analysis model, and a task output template according to the target test design task; performs a retrieval and recall process on the target knowledge graph according to the task prompt word to obtain a retrieval and recall result corresponding to the task prompt word, analyzes and processes the retrieval and recall result through the task analysis model to obtain a model analysis result corresponding to the task analysis model, and processes the model analysis result according to the task output template to obtain a task output result; when it is confirmed that the task output result is a target test case for the code to be tested, performs a test process on the code to be tested according to the target test case to obtain a target test result. Based on determining the test input information and the target test type, the present invention functionalizes the test workflow, and uses the target knowledge graph and the target test design task to implement intelligent full-process testing, reduces manual operations, reduces interaction complexity, and improves test efficiency and quality. At the same time, the present invention can comprehensively cover various complex test scenarios such as test analysis, test design, and test execution, and improves the comprehensiveness and accuracy of testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments of the present invention. Obviously, the following drawings are only some embodiments of the present invention, and those of ordinary skill in the art can also obtain other drawings without creative efforts.
[0011] Figure 1 is a flowchart of a code testing method according to an embodiment of the present invention; Figure 2 is a flowchart of step S10 in the code testing method according to an embodiment of the present invention; Figure 3 is a flowchart of step S20 in the code testing method according to an embodiment of the present invention; Figure 4 is a flowchart of step S30 in the code testing method according to an embodiment of the present invention; Figure 5 is a flowchart of step S40 in the code testing method according to an embodiment of the present invention; Figure 6It is another schematic flowchart of step S40 in the code testing method according to an embodiment of the present invention; Figure 7 It is a schematic flowchart of step S50 in the code testing method according to an embodiment of the present invention; Figure 8 It is a schematic structural diagram of a code testing device according to an embodiment of the present invention; Figure 9 It is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed implementation manners
[0012] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0013] The code testing method provided in this embodiment can be applied to an application environment where the user selects a target test type through the client and submits the code to be tested to the server, and the server completes the test process based on the automated test system. Among them, the client and the server establish a communication connection. The client includes, but is not limited to, various personal computers, laptop computers, smart phones, tablet computers, etc. The server can be implemented by an independent server or a server cluster composed of multiple servers.
[0014] In one embodiment, as Figure 1 shown, a code testing method is provided, including the following steps S10 - S50. S10. Obtain a target test request, and determine test input information and a target test type according to the target test request.
[0015] Understandably, after the server obtains the target test request, it parses the target test request to obtain the test input information and the target test type. The target test request is request information including the test input information and the target test type, and is used to trigger the code testing method process. Among them, the test input information refers to the code to be tested provided by the user and the information on specific test requirements, such as code snippets and test requirement files. The target test type refers to the type of different functional tests for the code specified by the user according to needs, such as the abnormal use case test type.
[0016] In one embodiment, as Figure 2 shown, in step S10, that is, before obtaining the target test request, it includes: S101. Receive the test input information entered by the client, and send a type selection request to the client; S102. When receiving the target test type corresponding to the type selection request sent by the client, generate a target test request according to the test input information and the target test type.
[0017] Understandably, users can perform data interaction with the server through the interaction interface of the client. Before the server obtains the target test request, it is necessary to generate the target test request according to the information provided by the user. When the server receives the test input information entered by the client, it sends a type selection request to the client. The type selection request refers to the request information used to display multiple test type options (such as functional option buttons) through the interaction interface of the client, enabling the user to select one of the multiple test type options as the target test type. When the server receives the target test type corresponding to the type selection request sent by the client, it generates a target test request according to the test input information and the target test type.
[0018] In one embodiment, the user is a developer. The developer inputs code and documents as test input information through the interaction interface of the client, and then selects the target test type from the functional test type options. The server triggers the operation process of the code test method based on the test input information and the target test type. The functional test type options include an exception case test type for implementing exception test case design, an interface case test type for implementing interface test case design, a general solution test type for implementing general test solution design, etc. These functional test type options can be integrated using an if-elif-else structure. For example, the exception case test type corresponds to "if", the interface case test type corresponds to "elif", and the general solution test type corresponds to "else". The if-elif-else statement can handle multiple branches, enabling the server to trigger the corresponding processing process under multiple conditions. Among them, elif represents "else if" and is used to add multiple functional test type options.
[0019] In this embodiment, the user can trigger the automated process of the code test method by submitting the test input information and selecting the target test type through the interaction interface of the client, reducing the interaction complexity and improving the test efficiency.
[0020] S20. Determine the code to be tested and the test solution file according to the test input information, and preprocess the code to be tested and the test solution file to obtain a target knowledge graph corresponding to the target test request.
[0021] Understandably, the test input information includes the code to be tested and the test scenario file. The code to be tested refers to the code snippet that needs to be tested, and the test scenario file is the test requirement file corresponding to the code to be tested. For example, the test scenario file includes the requirement document (or requirement specification), design document (such as system or software design document), and test plan document. The requirement document is the basis and guidance for testing. The requirement document details the functional requirements, performance requirements, user interface requirements, and other non-functional requirements of the software product. The server needs to formulate a test plan based on these requirements to ensure that the software product meets the expectations and requirements of users. The design document provides detailed design information of the product, including system architecture, module division, database design, etc. The server can understand the internal structure of the software product through these documents to conduct more detailed and accurate tests. The test plan document describes the scope, method, resources, schedule, etc. of the test. The test plan document guides the entire test process to ensure the orderly progress of the test work. In addition, the test scenario file may also involve other auxiliary documents, such as the interface document (describing the interface information between the product and other systems). The interface document plays an auxiliary role in the test process to help the server understand the software product more comprehensively and conduct tests.
[0022] Preprocessing refers to operations such as code parsing and document extraction on the code to be tested and the test scenario file, so as to construct a target knowledge graph corresponding to the target test request. The target knowledge graph is structured data that integrates the relationships between the structure, function, and dependencies of the code to be tested, as well as the requirement background, test focus, requirement scope, etc. information in the test scenario file. The target knowledge graph is generated in real time based on the data in the target test request. There is a one-to-one correspondence between the target test request and the target knowledge graph, and different target test requests correspond to different target knowledge graphs.
[0023] In one embodiment, as Figure 3 shown, in step S20, that is, preprocessing the code to be tested and the test scenario file to obtain a target knowledge graph corresponding to the target test request, includes: S201. Perform code cleaning and slicing on the code to be tested to obtain code knowledge data corresponding to the code to be tested; S202. Perform document cleaning and segmentation on the test scenario file to obtain document knowledge data corresponding to the test scenario file; S203. Determine the target knowledge graph according to the code knowledge data and the document knowledge data.
[0024] Understandably, code cleaning is to remove comments, blank lines, unnecessary formatting characters, etc. from the code to be tested, making the code more concise and easier to understand for subsequent analysis. Slicing is to split the code into smaller, more understandable and analyzable parts, such as based on structures like functions, classes, modules, etc. After code cleaning and slicing, code knowledge data corresponding to the code to be tested is obtained, and the code knowledge data includes code structure, function signatures, variable definitions and usage, etc. Document cleaning is to remove redundant information in the test plan file, such as headers, footers, tables of contents, unnecessary formatting, etc. Segmentation is to split the test plan file into multiple logically relatively independent paragraphs or chapters. Specifically, the document is split into multiple parts according to markers such as titles and paragraph separators, and the theme and content type of each part are identified (such as requirement background, test focus, requirement scope, etc.).
[0025] Through reasonable processing and analysis in this embodiment, all key information and their interrelationships in the code to be tested and the test plan file can be extracted and a target knowledge graph can be generated, providing strong support for subsequent test analysis and execution, not only improving test efficiency, but also enhancing the accuracy and reliability of testing.
[0026] S30. Search for a target test design task that matches the target test type from a preset test task list.
[0027] Understandably, a target test design task that matches the target test type can be searched from a preset test task list. The preset test task list is a pre-generated data list recording the association relationships between different test type options and test design tasks. The target test type is the test type option selected by the user. The target test design task refers to the test design workflow task corresponding to the target test type, including multiple workflow nodes such as determining the test scope, formulating a test strategy, and designing test cases.
[0028] In one embodiment, as Figure 4 shown, before step S30, that is, before searching for a target test design task that matches the target test type from the preset test task list, it includes: S301. Receive test type configuration information, test node configuration information, and template configuration information; S302. Determine the target test type according to the test type configuration information, determine at least one test node task according to the node prompt words and node analysis model in the test node configuration information, and determine the output node task according to the template configuration information; S303. Generate a target test design task associated with the target test type according to all the test node tasks and the output node task.
[0029] Understandably, before finding the target test design task that matches the target test type from the preset test task list, it is necessary to first configure the preset test task list that contains the association relationship between the target test type and the target test design task to avoid the situation of search failure. The user creates a test design task through the interactive interface of the client, configures the corresponding test type option and test node, and adds it to the preset test task list after configuration, so as to directly repeat the call of the associated test design task according to the selected test type option to complete the code test process later.
[0030] In one embodiment, on the one hand, the server receives the test type configuration information and determines the target test type according to the test type configuration information. The test type configuration information refers to the information used to specify or describe the test type corresponding to the test design task to be configured. On the other hand, the server receives the test node configuration information and determines at least one test node task according to the node prompt word and node analysis model in the test node configuration information. The test design task can include only one test node task or multiple test node tasks. Each test node task corresponds to a workflow step in the test design task, and the output node task is the last workflow step in the test design task. The test node configuration information refers to the specific configuration and guidance information required for each test node task in the test design task, including the node prompt word and the node analysis model. The node prompt word refers to the prompt word used to retrieve and recall specific information in a test node task of the test design task. The node analysis model refers to the deep learning model used to analyze the retrieved and recalled information in a test node task of the test design task. Each test node task corresponds to a group of mutually associated node prompt words and node analysis models. After the test node task is configured, the server also needs to determine the task output template according to the template configuration information and generate the output node task. Finally, the target test design task associated with the target test type is generated according to all the test node tasks and the output node task.
[0031] This embodiment generates the target test design task associated with the target test type based on the configuration information of the test type and the test node, thereby ensuring the availability of the preset test task list, being able to cover various test types more comprehensively, providing a call basis for the automatic execution of subsequent test design tasks, and ensuring the accuracy and pertinence of the test design tasks.
[0032] S40. Determine a task prompt word, a task analysis model, and a task output template according to the target test design task, perform a retrieval and recall process on the target knowledge graph according to the task prompt word to obtain a retrieval and recall result corresponding to the task prompt word, perform an analysis process on the retrieval and recall result through the task analysis model to obtain a model analysis result corresponding to the task analysis model, and perform a process on the model analysis result according to the task output template to obtain a task output result.
[0033] Understandably, based on the found target test design task, the server can determine a task prompt word for guiding the test design task, a task analysis model for executing the test design task, and a task output template for integrating the analysis results of the task analysis model. The task prompt word refers to the collective term for all node prompt words in the target test design task, and the task prompt word can include node prompt words of one or more node tasks. The task analysis model refers to the collective term for all node analysis models in the target test design task, and the task analysis model can include node analysis models of one or more node tasks. The execution of the target test design task applies the Retrieval-Augmented Generation (RAG) technology, which combines the content retrieval of the knowledge base and the generation ability of the large model to ensure the accuracy and credibility of the answers generated by the Large Language Model (LLM). The Retrieval-Augmented Generation technology includes two stages: retrieval and generation. In the retrieval stage, the server uses an efficient retrieval algorithm (such as Dense Passage Retrieval) to retrieve the most relevant information from the target knowledge graph according to the task prompt word. The information recalled by the task prompt word can tell the task analysis model what to do, how to do it, and what to output. In the generation stage, the task analysis model (such as large language models like GPT and BERT) is used to generate answers or execute tasks in combination with the retrieved and recalled information.
[0034] In one embodiment, as Figure 5 shown, in step S40, that is, determining a task prompt word, a task analysis model, and a task output template according to the target test design task, performing a retrieval and recall process on the target knowledge graph according to the task prompt word to obtain a retrieval and recall result corresponding to the task prompt word, performing an analysis process on the retrieval and recall result through the task analysis model to obtain a model analysis result corresponding to the task analysis model, and performing a process on the model analysis result according to the task output template to obtain a task output result, includes: S401. Determine the node prompt words, node analysis models for at least one test node task, and the task output template for the output node task according to the target test design task. S402. Perform retrieval and recall processing on the target knowledge graph according to the node prompt words corresponding to each test node task to obtain the node input data corresponding to each test node task. S403. Perform data processing on the node input data through the node analysis models corresponding to each test node task, and obtain the node model analysis results of the target test cases of the to-be-tested code after all the test node tasks are completed. S404. Process the node model analysis results of all the test node tasks according to the task output template to obtain the task output result of the output node task.
[0035] Understandably, a test node task refers to a workflow step before the output node task in the target test design task. The target test design task may include only one test node task or multiple sequentially executed test node tasks. Each test node task corresponds to a set of pre-configured node prompt words and node analysis models. When the server executes the target test design task, first, it uses the node prompt words of one of the test node tasks in the target knowledge graph in the execution order to perform retrieval, recall the information related to the test node task, and determine the retrieved result as the node input data. The node input data refers to the data used to input into the node analysis model in the test node task. Then, it uses the node analysis model of the current test node task to analyze and process the node input data to obtain the execution result of the test node task. Next, it determines whether there are unfinished test node tasks. If there are unfinished test node tasks, it continues to execute the unfinished test node tasks in order. Finally, after all the test node tasks are completed, it processes the node model analysis results of all the test node tasks according to the task output template to obtain the task output result of the output node task.
[0036] Different target test types match different target test design tasks. Different target test design tasks are configured with different task output templates, and different task output templates correspond to different task output results. For example, when the target test type is an exception test case test type, the target test design task is an exception test case design task, and the corresponding task output template is a test case template. Another example is that when the target test type is a general solution design type, the target test design task is a test solution design task, and the corresponding task output template is a test solution generation template.
[0037] In this embodiment, the task prompt words and task analysis model are determined according to the target test design task, and further combined with the retrieval ability of the knowledge graph and the processing ability of the data analysis model, which improves the efficiency and accuracy of test design. This embodiment is based on a large language model, which helps to automatically generate test cases, execute tests, and analyze test results, covering various test scenarios more comprehensively, and improving the stability and reliability of tests.
[0038] In one embodiment, the target test design task includes an abnormal test case design task; as Figure 6 shown, in step S40, that is, determining the task prompt words, task analysis model, and task output template according to the target test design task, performing a retrieval and recall process on the target knowledge graph according to the task prompt words to obtain a retrieval and recall result corresponding to the task prompt words, analyzing and processing the retrieval and recall result through the task analysis model to obtain a model analysis result corresponding to the task analysis model, and processing the model analysis result according to the task output template to obtain a task output result, including: S405. Determine the requirement node prompt words and requirement node analysis model of the requirement analysis node task, the solution node prompt words and solution node analysis model of the solution analysis node task, and the test case template of the output node task according to the abnormal test case design task; S406. Perform a requirement retrieval and recall process on the target knowledge graph according to the requirement node prompt words to obtain a requirement retrieval and recall result, and perform data processing on the requirement retrieval and recall result through the requirement node analysis model to obtain test requirement parameters; S407. Perform a solution retrieval and recall process on the target knowledge graph according to the solution node prompt words to obtain a solution retrieval and recall result, and perform data processing on the solution retrieval and recall result through the solution node analysis model to obtain technical solution parameters; S408. Perform data processing on the test requirement parameters and technical solution parameters according to the test case template to obtain the target test case of the code to be tested.
[0039] Understandably, the target test design task includes an abnormal test case design task. When the user selects the functional option of the abnormal use case test type, the target test type is the abnormal use case test type, which is a test type used to verify whether the function of the code to be tested meets the expected performance under abnormal conditions or edge conditions. At this time, the server searches the preset test task list for the abnormal test case design task that matches the abnormal use case test type, and determines the abnormal test case design task as the target test design task. The abnormal test case design task includes two test node tasks, namely, the requirement analysis node task and the solution analysis node task, and an output node task. Each test node task corresponds to a set of node prompt words and a node analysis model. The requirement analysis node task corresponds to the requirement node prompt words and the requirement node analysis model, and is used to understand and refine the test requirements. The solution analysis node task corresponds to the solution node prompt words and the solution node analysis model, and is used to explore and implement potential technical solutions that meet the test requirements. The abnormal test case design task is also configured with a test case template for the output node task, which is used to generate specific test cases based on the test requirements and technical solutions. The target test case refers to a series of specific test scenarios and parameters used to verify the function and behavior of the code to be tested.
[0040] In one embodiment, first, the server performs a requirement retrieval and recall process on the target knowledge graph according to the requirement node prompt words, and processes the requirement retrieval and recall results through the requirement node analysis model to obtain test requirement parameters. The requirement node prompt words include the requirement background, requirement purpose, and requirement scope. The test requirement parameters refer to the assignment data extracted from the test solution file corresponding to the requirement node prompt words. Then, the server performs a solution retrieval and recall process on the target knowledge graph according to the solution node prompt words, and processes the solution retrieval and recall results through the solution node analysis model to obtain technical solution parameters. The solution node prompt words include the changes, test focus, test difficulty, developers, testers, product personnel, and test methods. The technical solution parameters refer to the assignment data extracted from the test solution file corresponding to the solution node prompt words. Finally, the server determines the test case template according to the abnormal test case design task, and processes the test requirement parameters and technical solution parameters through the test case template to obtain the target test case of the code to be tested. When the target test design task is the abnormal test case design task, the corresponding test case template is the template for generating abnormal test cases.
[0041] This embodiment makes full use of the information retrieval ability of the target knowledge graph and the data processing ability of each node analysis model, so as to be able to efficiently and accurately generate abnormal test cases for the code to be tested. This embodiment not only improves the design efficiency of abnormal test cases, but also enhances the pertinence and effectiveness of test cases.
[0042] S50. When it is confirmed that the task output result is the target test case of the code to be tested, perform a test process on the code to be tested according to the target test case to obtain a target test result.
[0043] Understandably, the server automatically completes the test process of the code to be tested according to the generated target test case to obtain a target test result. The target test result refers to the test result generated after running the target test case in the code to be tested. In addition, when configuring the target test design task, the user can also specify the output method of the test result according to needs, such as docking systems, direct answers, and sending emails. After obtaining the target test result, the server will output the target test result to the client according to the pre-specified output method.
[0044] In this embodiment, by obtaining a target test request, determining test input information and a target test type according to the target test request; determining the code to be tested and a test scenario file according to the test input information, and preprocessing the code to be tested and the test scenario file to obtain a target knowledge graph corresponding to the target test request; searching for a target test design task matching the target test type from a preset test task list, and determining a task prompt word, a task analysis model, and a task output template according to the target test design task; performing a retrieval and recall process on the target knowledge graph according to the task prompt word to obtain a retrieval and recall result corresponding to the task prompt word, and analyzing the retrieval and recall result through the task analysis model to obtain a model analysis result corresponding to the task analysis model, and processing the model analysis result according to the task output template to obtain a task output result; when it is confirmed that the task output result is the target test case of the code to be tested, perform a test process on the code to be tested according to the target test case to obtain a target test result. Based on determining the test input information and the target test type, this embodiment functionalizes the test workflow, uses the target knowledge graph and the target test design task to implement intelligent full-process testing, reduces manual operations, reduces interaction complexity, and improves test efficiency and quality. At the same time, this embodiment can comprehensively cover various complex test scenarios such as test analysis, test design, and test execution, improving the comprehensiveness and accuracy of testing.
[0045] In one embodiment, as Figure 7 shown, in step S50, that is, after it is confirmed that the task output result is the target test case of the code to be tested and the test process on the code to be tested is performed according to the target test case to obtain a target test result, it includes: S501. Receive test evaluation information corresponding to the target test result sent by the client, and send the test evaluation information to a preset operation and maintenance party.
[0046] Understandably, in the automated test process of the code, the server can automatically generate test cases, execute tests, and output test results based on the large language model. The end user can obtain the test results through the interactive interface of the client. On the one hand, if the user is not satisfied with the target test results output by the large language model because they are not detailed enough, the user can continue to manually input questions and have a question-and-answer session with the large model through the question-and-answer window of the interactive interface until the user is satisfied. On the other hand, if the user feels that the answer of the large language model is completely wrong, the user can send test evaluation information to the server through the feedback window of the interactive interface. The test evaluation information refers to the descriptive information fed back by the user regarding the errors and improvement suggestions in the target test results. After receiving the test evaluation information corresponding to the target test results, the server sends the test evaluation information to the preset operation and maintenance party to facilitate the preset operation and maintenance party to optimize the task workflow, such as updating the prompt words and analysis models in the currently configured test case design tasks. The sending methods may include email, text message, instant message notification, etc. The preset operation and maintenance party refers to the technical team or management personnel responsible for maintaining, optimizing, or improving the automated test system.
[0047] This embodiment establishes a closed-loop feedback mechanism, timely improves the process and adjusts the system based on the test evaluation information corresponding to the target test results, realizes the dynamic update of the automated test system, and ensures the effectiveness of the automated test.
[0048] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
[0049] In one embodiment, a code testing device is provided, and the code testing device corresponds one-to-one to the code testing method in the above embodiment. As Figure 8 shown, the code testing device includes a test request acquisition module 10, an input information preprocessing module 20, a test task determination module 30, a test case generation module 40, and a test result acquisition module 50. The detailed description of each functional module is as follows: The test request acquisition module 10 is used to acquire a target test request, and determine test input information and a target test type according to the target test request; The input information preprocessing module 20 is used to determine the code to be tested and a test plan file according to the test input information, and preprocess the code to be tested and the test plan file to obtain a target knowledge graph corresponding to the target test request; The test task determination module 30 is used to find a target test design task that matches the target test type from a preset test task list; A test case generation module 40 is configured to determine a task prompt word, a task analysis model, and a task output template according to the target test design task, retrieve and recall the target knowledge graph according to the task prompt word to obtain a retrieval and recall result corresponding to the task prompt word, analyze and process the retrieval and recall result through the task analysis model to obtain a model analysis result corresponding to the task analysis model, and process the model analysis result according to the task output template to obtain a task output result; A test result acquisition module 50 is configured to perform a test process on the code to be tested according to the target test case when it is confirmed that the task output result is the target test case of the code to be tested, and obtain a target test result.
[0050] In one embodiment, the test request acquisition module 10 includes: An input information receiving unit is configured to receive test input information entered by a client and send a type selection request to the client; A test request generation unit is configured to generate a target test request according to the test input information and the target test type when receiving the target test type corresponding to the type selection request sent by the client.
[0051] In one embodiment, the input information preprocessing module 20 includes: A code processing unit is configured to perform code cleaning and slicing on the code to be tested to obtain code knowledge data corresponding to the code to be tested; A file processing unit is configured to perform document cleaning and segmentation on the test scheme file to obtain document knowledge data corresponding to the test scheme file; A knowledge graph determination unit is configured to determine a target knowledge graph according to the code knowledge data and the document knowledge data.
[0052] In one embodiment, the test task determination module 30 includes: A configuration information receiving unit is configured to receive test type configuration information, test node configuration information, and template configuration information; A configuration information analysis unit is configured to determine a target test type according to the test type configuration information, determine at least one test node task according to a node prompt word and a node analysis model in the test node configuration information, and determine an output node task according to the template configuration information; A task generation unit is configured to generate a target test design task associated with the target test type according to all the test node tasks and the output node task.
[0053] In one embodiment, the test case generation module 40 includes: A test node task determination unit, configured to determine a node prompt word and a node analysis model of at least one test node task according to the target test design task, and output a task output template of the node task; A node input data acquisition unit, configured to perform a retrieval and recall process on the target knowledge graph according to the node prompt word corresponding to each test node task, and obtain node input data corresponding to each test node task; A node model analysis unit, configured to perform data processing on the node input data through the node analysis model corresponding to each test node task, and obtain a node model analysis result of each test node task; A template processing unit, configured to process the node model analysis results of all the test node tasks according to the task output template, and obtain a task output result of the output node task.
[0054] In one embodiment, the test case generation module 40 further includes: An abnormal test node task determination unit, configured to determine a requirement node prompt word and a requirement node analysis model of a requirement analysis node task, a solution node prompt word and a solution node analysis model of a solution analysis node task, and a test case template of an output node task according to the abnormal test case design task; A test requirement parameter determination unit, configured to perform a requirement retrieval and recall process on the target knowledge graph according to the requirement node prompt word, obtain a requirement retrieval and recall result, and perform data processing on the requirement retrieval and recall result through the requirement node analysis model to obtain test requirement parameters; A technical solution parameter determination unit, configured to perform a solution retrieval and recall process on the target knowledge graph according to the solution node prompt word, obtain a solution retrieval and recall result, and perform data processing on the solution retrieval and recall result through the solution node analysis model to obtain technical solution parameters; A target test case generation unit, configured to perform data processing on the test requirement parameters and the technical solution parameters according to the test case template, and obtain a target test case of the code to be tested.
[0055] In one embodiment, the test result acquisition module 50 includes: A test feedback unit, configured to receive test evaluation information corresponding to the target test result sent by a client, and send the test evaluation information to a preset operation and maintenance party.
[0056] For the specific limitations of the code testing device, reference can be made to the limitations of the code testing method in the foregoing text, which will not be elaborated here. Each module in the above code testing device can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor of the computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to the above modules.
[0057] In one embodiment, a computer device is provided. The computer device can be a server, and its internal structure diagram can be as Figure 9 shown. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a readable storage medium and an internal memory. The readable storage medium stores an operating system, computer-readable instructions, and a database. The internal memory provides an environment for the operation of the operating system and computer-readable instructions in the readable storage medium. The database of the computer device is used to store the data involved in the code testing method. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer-readable instructions are executed by the processor, a code testing method is implemented. The readable storage medium provided in this embodiment includes a non-volatile readable storage medium and a volatile readable storage medium.
[0058] In one embodiment, a computer device is provided, including a memory, a processor, and computer-readable instructions stored on the memory and executable on the processor. When the processor executes the computer-readable instructions, the following steps are implemented: Obtain a target test request, and determine test input information and a target test type according to the target test request; Determine the code to be tested and a test plan file according to the test input information, and preprocess the code to be tested and the test plan file to obtain a target knowledge graph corresponding to the target test request; Search for a target test design task matching the target test type from a preset test task list; Determine a task prompt word, a task analysis model, and a task output template according to the target test design task, and perform a retrieval and recall process on the target knowledge graph according to the task prompt word to obtain a retrieval and recall result corresponding to the task prompt word. Analyze and process the retrieval and recall result through the task analysis model to obtain a model analysis result corresponding to the task analysis model, and process the model analysis result according to the task output template to obtain a task output result; When it is confirmed that the task output result is the target test case of the code to be tested, perform a test process on the code to be tested according to the target test case to obtain a target test result.
[0059] In one embodiment, one or more computer-readable storage media storing computer-readable instructions are provided. The readable storage media provided in this embodiment include non-volatile readable storage media and volatile readable storage media. Computer-readable instructions are stored on the readable storage media. When the computer-readable instructions are executed by one or more processors, the following steps are implemented: Obtain a target test request, and determine test input information and a target test type according to the target test request; Determine the code to be tested and a test scenario file according to the test input information, and perform preprocessing on the code to be tested and the test scenario file to obtain a target knowledge graph corresponding to the target test request; Search for a target test design task matching the target test type from a preset test task list; Determine a task prompt word, a task analysis model, and a task output template according to the target test design task, perform a retrieval and recall process on the target knowledge graph according to the task prompt word to obtain a retrieval and recall result corresponding to the task prompt word, perform an analysis process on the retrieval and recall result through the task analysis model to obtain a model analysis result corresponding to the task analysis model, and process the model analysis result according to the task output template to obtain a task output result; When it is confirmed that the task output result is the target test case of the code to be tested, perform a test process on the code to be tested according to the target test case to obtain a target test result.
[0060] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through computer-readable instructions. The computer-readable instructions can be stored in a non-volatile readable storage medium or a volatile readable storage medium. When the computer-readable instructions are executed, they can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database, or other medium used in the embodiments provided by the present invention can include non-volatile and / or volatile memories. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or an external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and Rambus dynamic RAM (RDRAM), etc.
[0061] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of each functional unit and module is used as an example. In actual applications, the above functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0062] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A code testing method, characterized in that, Including: Obtain a target test request, and determine test input information and a target test type according to the target test request; Determine the code to be tested and a test scenario file according to the test input information, and preprocess the code to be tested and the test scenario file to obtain a target knowledge graph corresponding to the target test request; Search for a target test design task that matches the target test type from a preset test task list; Determine a task prompt word, a task analysis model, and a task output template according to the target test design task, perform a retrieval and recall process on the target knowledge graph according to the task prompt word to obtain a retrieval and recall result corresponding to the task prompt word, perform an analysis process on the retrieval and recall result through the task analysis model to obtain a model analysis result corresponding to the task analysis model, and process the model analysis result according to the task output template to obtain a task output result; When it is confirmed that the task output result is a target test case for the code to be tested, perform a test process on the code to be tested according to the target test case to obtain a target test result.
2. The code testing method according to claim 1, characterized in that Before obtaining the target test request, including: Receive test input information entered by the client, and send a type selection request to the client; When receiving the target test type corresponding to the type selection request sent by the client, generate a target test request according to the test input information and the target test type.
3. The code testing method according to claim 1, characterized in that The preprocessing the code to be tested and the test scenario file to obtain a target knowledge graph corresponding to the target test request includes: Perform code cleaning and slicing processing on the code to be tested to obtain code knowledge data corresponding to the code to be tested; Perform document cleaning and segmentation processing on the test scenario file to obtain document knowledge data corresponding to the test scenario file; Determine a target knowledge graph according to the code knowledge data and the document knowledge data.
4. The code testing method according to claim 1, characterized in that Before searching for a target test design task that matches the target test type from a preset test task list, including: Receive test type configuration information, test node configuration information, and template configuration information; Determine the target test type according to the test type configuration information, determine at least one test node task according to the node prompt word and the node analysis model in the test node configuration information, and determine an output node task according to the template configuration information; Generate a target test design task associated with the target test type according to all the test node tasks and the output node task.
5. The code testing method according to claim 1, wherein The determining a task prompt word, a task analysis model, and a task output template according to the target test design task, performing a retrieval and recall process on the target knowledge graph according to the task prompt word to obtain a retrieval and recall result corresponding to the task prompt word, performing an analysis process on the retrieval and recall result through the task analysis model to obtain a model analysis result corresponding to the task analysis model, and processing the model analysis result according to the task output template to obtain a task output result includes: Determine the node prompt words and node analysis models of at least one test node task according to the target test design task, and the task output template of the output node task; Perform retrieval and recall processing on the target knowledge graph according to the node prompt words corresponding to each test node task to obtain the node input data corresponding to each test node task; Perform data processing on the node input data through the node analysis models corresponding to each test node task to obtain the node model analysis results of each test node task; Process the node model analysis results of all test node tasks according to the task output template to obtain the task output result of the output node task.
6. The code testing method according to claim 1, characterized in that The target test design task includes an abnormal test case design task; Determine the task prompt words, task analysis models and task output templates according to the target test design task, perform retrieval and recall processing on the target knowledge graph according to the task prompt words to obtain the retrieval and recall results corresponding to the task prompt words, and perform analysis and processing on the retrieval and recall results through the task analysis models. Obtain the model analysis results corresponding to the task analysis model, and process the model analysis results according to the task output template to obtain the task output results, including: Determine the requirement node prompt words and requirement node analysis models of the requirement analysis node task, the solution node prompt words and solution node analysis models of the solution analysis node task, and the test case template of the output node task according to the abnormal test case design task; Perform requirement retrieval and recall processing on the target knowledge graph according to the requirement node prompt words to obtain the requirement retrieval and recall results, and perform data processing on the requirement retrieval and recall results through the requirement node analysis models to obtain the test requirement parameters; Perform solution retrieval and recall processing on the target knowledge graph according to the solution node prompt words to obtain the solution retrieval and recall results, and perform data processing on the solution retrieval and recall results through the solution node analysis models to obtain the technical solution parameters; Perform data processing on the test requirement parameters and technical solution parameters according to the test case template to obtain the target test cases of the code to be tested.
7. The code testing method according to claim 1, wherein After performing the test processing on the code to be tested according to the target test case and obtaining the target test results, including: Receive the test evaluation information corresponding to the target test results sent by the client and send the test evaluation information to the preset operation and maintenance party.
8. A code testing device, characterized in that Including: A test request acquisition module for acquiring a target test request and determining test input information and a target test type according to the target test request; An input information preprocessing module for determining the code to be tested and a test solution file according to the test input information, and preprocessing the code to be tested and the test solution file to obtain a target knowledge graph corresponding to the target test request; A task determination module for finding a target test design task that matches the target test type from a preset test task list; A task execution module, configured to determine a task prompt word, a task analysis model, and a task output template according to the target test design task, perform a retrieval and recall process on the target knowledge graph according to the task prompt word to obtain a retrieval and recall result corresponding to the task prompt word, perform an analysis process on the retrieval and recall result through the task analysis model to obtain a model analysis result corresponding to the task analysis model, and perform a process on the model analysis result according to the task output template to obtain a task output result; A test result acquisition module, configured to perform a test process on the code to be tested according to the target test case when it is confirmed that the task output result is the target test case of the code to be tested, to obtain a target test result.
9. A computer device, comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, characterized in that, When the processor executes the computer-readable instructions, the code testing method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing computer-readable instructions, characterized in that, When the computer-readable instructions are executed by one or more processors, the one or more processors are caused to execute the code testing method according to any one of claims 1 to 7.
Citation Information
Cited By
Data analysis method and device, electronic equipment and computer readable medium
CN121233730A