Method for obtaining process reward model corpus of test case and computing equipment
By automatically scoring the quality of test cases using computational devices and combining runtime and static testing to generate process reward model corpus, the problem of high cost of manual annotation is solved, and efficient automated test case generation is achieved.
Patent Information
- Application Number
- CN202511431314.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-30
- Publication Date
- 2026-01-02
AI Technical Summary
The process of manually annotating test cases is costly and inefficient, making it difficult to meet the needs of automated test case generation.
By using preset detection rules, computing devices can automatically score the quality of test cases. By combining runtime detection and static detection, fine-grained scoring of each test case can be achieved, generating a process reward model corpus.
It improves the efficiency of generating process reward model corpora, reduces manual costs, and enhances the automation of test case generation.
Smart Images

Figure CN121255643A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of software testing and artificial intelligence, and more specifically, to a method and computing device for obtaining a corpus of process reward models for test cases. Background Technology
[0002] Software testing is a crucial means of ensuring software program quality, and test cases are typically used to verify the correctness of software programs. Currently, software products are widely used, and the effectiveness of test cases has long been a major concern. Because manually writing test cases requires significant effort and cost, and necessitates expert knowledge, the demand for automated test case generation technologies is increasing. In recent years, with the continuous development of deep learning methods, more and more research has begun to focus on using large language models for unit test case generation tasks.
[0003] Research has begun on reinforcement learning methods based on process-oriented human feedback to train artificial intelligence (AI) models, enabling these models to automatically generate test cases. However, current PRM (Procedure-Based Reinforcement) corpora for code-related tasks are obtained through manual annotation. For example, for a test case, experts annotate the test case's score (i.e., reward), thus generating the PRM corpus. However, manual PRM corpus annotation requires a significant investment of expertise in the relevant task, resulting in high costs and low annotation efficiency.
[0004] Therefore, a method is needed to obtain process reward model corpus for test cases, which can improve the efficiency of obtaining PRM corpus and reduce manual costs. Summary of the Invention
[0005] This application provides a method for obtaining process reward model corpus of test cases. By pre-setting detection rules, the computing device can automatically score the quality of each test case, thereby improving the generation efficiency of PRM corpus and reducing manual costs.
[0006] In a first aspect, this application provides a method for obtaining a process reward model corpus of test cases, which can be executed by a computing device, or by a component of the computing device (e.g., a chip or circuit). For example, the computing device can be a computer.
[0007] The method includes: acquiring first information, the first information including multiple test cases; sending second information, the second information including target test cases, the multiple test cases including the target test cases, the target test cases being obtained based on the scoring results corresponding to each target test case, the scoring results corresponding to each test case being obtained by scoring the detection results of each test case according to preset detection rules, the preset detection rules including detection rules for the code structure of test cases and / or detection rules for the execution results of test cases.
[0008] For example, the code structure detection rules for test cases include at least one of the following: detection rules for each code component in the test case, detection rules for business components in the test case, where each business component in the test case is obtained based on at least one code component in the test case.
[0009] For example, the first information also includes prompts corresponding to multiple test cases, each prompt indicating the user's needs. The multiple test cases are test cases that meet the user's needs. In this case, the detection rules for the business components in the test cases include detection rules for the test cases and the prompts corresponding to the test cases.
[0010] For example, the rules for detecting the execution results of test cases include rules for detecting metrics, and the metrics include at least one of the following: test case compilation rate, test case coverage, and test case assertion pass rate.
[0011] Based on the above technical solution, this application embodiment combines two analysis techniques, runtime detection and static detection, to perform step-by-step detection on each component of each test case, thereby making the quality score of each test case more comprehensive and accurate.
[0012] In conjunction with the first aspect, in one possible implementation, each test case includes multiple lines of code, and the corresponding score for each test case is obtained based on the score corresponding to at least one line of code.
[0013] Furthermore, the solution provided in this application embodiment can be so precise as to detect and score each line of code, that is, this solution can obtain a more granular score.
[0014] In conjunction with the first aspect, in one possible implementation, obtaining the first information includes: obtaining the first information according to a first model, wherein the first model is used to generate test cases based on prompt words input by the user, the input of the first model is the prompt words, and the output of the first model is the test cases corresponding to the prompt words.
[0015] In conjunction with the first aspect, in one possible implementation, the second information also includes prompt words corresponding to the target test cases. This second information is used to train a second model, which generates test cases based on the prompt words input by the user. The input of the second model is the prompt words, and the output of the second model is the test cases corresponding to the prompt words. The second model is trained using a reinforcement learning method based on human feedback with process rewards.
[0016] In conjunction with the first aspect, in one possible implementation, the method further includes: receiving feedback information from a user, the feedback information indicating whether the user approves the target test case; obtaining third information based on the feedback information, the third information including test cases approved by the user and prompt words corresponding to the user-approved test users, and / or, test cases not approved by the user and prompt words corresponding to the user-not-approved test users, the third information being used to train a second model, the second model being used to generate test cases based on prompt words input by the user, the input of the second model being the prompt words, the output of the second model being the test cases corresponding to the prompt words, the second model being trained using a reinforcement learning method based on human feedback with process rewards.
[0017] For example, the second model can be a different model from the first model; or, for example, the second model can be the first model.
[0018] Based on the above technical solution, in this embodiment, a test case generation model can be trained based on the obtained second information, namely the PRM corpus. Since the scoring of test cases can be precise down to the point of detecting and scoring each line of code, when receiving test cases indicated by user feedback, it can provide more granular and comprehensive data support for the data flywheel. This allows for better guidance of model training and improved model quality when using reinforcement learning methods based on process-reward-based human feedback.
[0019] In conjunction with the first aspect, in one possible implementation, the method is applied to a cloud service system that includes a cloud management platform for managing infrastructure that provides cloud services. The infrastructure includes at least one cloud data center, which includes at least one server for any of the above possible implementations.
[0020] Secondly, this application proposes a computing device for performing the method described in the first aspect. Specifically, the device may include units and / or modules for performing the method proposed in this application, such as an acquisition module and a transceiver module.
[0021] For example, the computing device can be a computer or a computing device in a cloud service scenario. The cloud management platform is used to manage the infrastructure providing cloud services, and the infrastructure includes at least one cloud data center, each of which includes at least one server.
[0022] In one possible implementation, the first model and / or the second model are deployed on the at least one server.
[0023] Thirdly, this application provides a computing device comprising: at least one processor for executing a computer program or instructions stored in a memory to perform the method described in the first aspect. Optionally, the device further comprises a memory for storing the computer program or instructions. Optionally, the device further comprises a communication interface through which the processor reads the computer program or instructions stored in the memory.
[0024] In one implementation, the computing device is a device for implementing the functions of the above-described method in a chip.
[0025] In another implementation, the computing device is a chip, chip system, or circuit used to implement the functions described above in a chip.
[0026] Fourthly, this application provides a processor, including: an input circuit, an output circuit, and a processing circuit. The processing circuit is used to receive signals through the input circuit and to transmit signals through the output circuit, causing the processor to execute the method described in the first aspect.
[0027] In specific implementation, the processor can be one or more chips, the input circuit can be input pins, the output circuit can be output pins, and the processing circuit can be transistors, gate circuits, flip-flops, and various logic circuits. The input signal received by the input circuit can be received and input by, for example, but not limited to, a transceiver, and the signal output by the output circuit can be, for example, but not limited to, output to and transmitted by a transmitter. Furthermore, the input circuit and the output circuit can be the same circuit, which is used as both the input circuit and the output circuit at different times. This application does not limit the specific implementation of the processor and various circuits.
[0028] Unless otherwise specified, or if it does not contradict its actual function or internal logic in the relevant description, the transmission and acquisition / reception operations involved in the processor can be understood as processor output and reception, input and other operations, or as transmission and reception operations performed by radio frequency circuits and antennas. This application does not limit them in this regard.
[0029] Fifthly, a processing apparatus is provided, including a processor and a memory. The processor is used to read instructions stored in the memory and to receive signals via a transceiver and transmit signals via a transmitter to execute the method described in the first aspect.
[0030] Optionally, the processor may be one or more, and the memory may be one or more.
[0031] Optionally, the memory may be integrated with the processor, or the memory may be separated from the processor.
[0032] In the specific implementation process, the memory can be a non-transitory memory, such as read-only memory (ROM), which can be integrated with the processor on the same chip or set on different chips. The embodiments of this application do not limit the type of memory or the way the memory and processor are set.
[0033] It should be understood that the relevant data interaction process, such as sending the first information, can be the process of the processor outputting the first information, and the receiving capability information can be the process of the processor receiving input capability information. Specifically, the data output by the processor can be sent to the transmitter, and the input data received by the processor can come from the transceiver. Here, the transmitter and the transceiver can be collectively referred to as the transceiver.
[0034] The processing device mentioned in the fifth aspect above can be one or more chips. The processor in the processing device can be implemented in hardware or software. When implemented in hardware, the processor can be a logic circuit, integrated circuit, etc.; when implemented in software, the processor can be a general-purpose processor that reads software code stored in memory. This memory can be integrated into the processor or located outside the processor and exist independently.
[0035] In a sixth aspect, a computing cluster is provided, including at least one computing device, each computing device including a processor and a memory; the processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, such that the computing device cluster performs the method described in any possible implementation of the first aspect.
[0036] Optionally, the processor can be a general-purpose processor, which can be implemented in hardware or software. When implemented in hardware, the processor can be a logic circuit, integrated circuit, etc.; when implemented in software, the processor can be a general-purpose processor that reads software code stored in memory. This memory can be integrated into the processor or located outside the processor and exist independently.
[0037] In a seventh aspect, a computer-readable storage medium is provided that stores program code for execution by a device, the program code including the method described in the first aspect.
[0038] Eighthly, a computer program product containing instructions is provided, which, when run on a computer, causes the computer to perform the method described in the first aspect.
[0039] Ninth aspect, a chip system is provided, including a processor for calling and running a computer program from a memory, causing a device equipped with the chip system to perform the method of the first aspect described above. Attached Figure Description
[0040] Figure 1 This is a flowchart of an embodiment of the RLHF framework provided in this application.
[0041] Figure 2 This is a schematic block diagram of a method 200 for obtaining a process reward model corpus of test cases, provided in an embodiment of this application.
[0042] Figure 3 This application illustrates a schematic diagram of testing test cases according to the detection rules of the code structure.
[0043] Figure 4 This is a schematic diagram illustrating the detection effect of a test case in an embodiment of this application.
[0044] Figure 5 This is a schematic flowchart illustrating a test case executor executing a test case, as shown in an embodiment of this application.
[0045] Figure 6 This is a schematic flowchart illustrating how to obtain target test cases, as provided in an embodiment of this application.
[0046] Figure 7 This application embodiment illustrates a schematic flowchart of a model training method based on user feedback and training data collection.
[0047] Figure 8 This is a schematic diagram of a cloud service scenario used in this application.
[0048] Figure 9 This is a schematic block diagram of the device 900 provided in the embodiments of this application.
[0049] Figure 10 This is a schematic block diagram of the device 1000 provided in the embodiments of this application.
[0050] Figure 11This is a schematic diagram of the architecture of a computing device cluster provided in an embodiment of this application.
[0051] Figure 12 This is a schematic diagram showing the connection between computing devices 1100A and 1100B via a network according to an embodiment of this application. Detailed Implementation
[0052] The technical solutions in this application will now be described with reference to the accompanying drawings.
[0053] To facilitate understanding of the technical solutions provided in the embodiments of this application, the technical terms involved in this application are briefly introduced below. It should be noted that the introduction of technical terms in this application is only for the purpose of helping to understand the technical solutions and should not be construed as limiting the application.
[0054] 1. Software Testing Software testing is a crucial part of the software development process. Its purpose is to evaluate the quality of the software and identify defects (bugs). It's not simply about "running the program to see if it crashes," but a systematic process involving a series of activities designed to ensure the software meets customer needs and expectations and conforms to predetermined quality standards. Software testing can be categorized according to different criteria: by testing phase (unit testing, integration testing, system testing, acceptance testing); by testing method (black-box testing, white-box testing, gray-box testing); and by testing purpose (functional testing, performance testing, security testing, usability testing, compatibility testing, etc.).
[0055] For example, "unit testing (UT)" can be understood as a type of software testing that verifies the smallest unit of software design, i.e., whether the "unit" works properly during the software development process. For example, this "unit" can refer to a single function, class, module, or component, depending on the programming language and software architecture used. Typically, the purpose of unit testing is to: (1) verify the functionality of a single unit, ensuring that each unit can work independently as expected and meet its design specifications; (2) unit testing is usually performed in the early stages of development, which can significantly reduce the cost and time of fixing errors by finding and fixing them as early as possible; (3) by writing unit tests, developers need to think more clearly about the design and functionality of the code, thereby improving code quality and reducing the code defect rate.
[0056] 2. Test Cases Typically, a test case describes how to test a specific aspect of software, including input data, execution steps, and expected results. It's a general concept applicable to various types of software testing, including unit testing, integration testing, system testing, and acceptance testing. The scope of a test case can be broad, ranging from testing a single function to testing the entire system, and can be used to verify whether the software meets the requirements in its requirements specification. For example, a test case could be validating a user login function: entering the correct username and password should result in successful login; entering an incorrect username or password should result in login failure. This example could be part of a unit test case, or it could be part of an integration test or system test case, depending on the scope of the test.
[0057] For example, a "unit test case" is a special case of test cases specifically designed to test the smallest unit of software. A unit is typically a function, a class, or a module. Unit test cases have a very narrow scope, focusing solely on the functionality of a single unit. They are used to verify whether the functionality of a single unit is correct and meets its design specifications. For instance, a unit test case could test the function `calculateSum(a, b)`: input a = 5, b = 10, expected result 15; input a = -2, b = 3, expected result 1. This example focuses only on the `calculateSum` function itself, without considering other functions or external systems.
[0058] 3. Prompt The prompt acts as a bridge between humans and the large language model (LLM), playing a crucial role in guiding the LLM to complete tasks. For example, a prompt is the text input provided to the LLM to guide it in generating the desired output. It's like a task description, a question, an instruction, or the beginning of a context given to the LLM by the user. The LLM, based on the user-provided prompt and its own knowledge and understanding, generates the corresponding text output. Different prompts produce different outputs, allowing users to construct appropriate prompts to obtain the desired answers and results.
[0059] For example, a prompt can contain different components: (1) Instructions: tell the LLM what you want it to do, such as “summarize the following article”, “translate this text into English”, “write a poem about autumn”; (2) Questions: ask the LLM questions, such as “What is the capital of China?”, “How do you make a chocolate cake?”; (3) Context: provide some background information or examples to help the LLM better understand your intentions, such as providing an article for the LLM to summarize, or providing a conversation history for the LLM to continue the conversation; (4) Input data: data that the model needs to process, such as translating a sentence if you want the model to translate a sentence; (5) Output indicators: used to indicate the output format of the model, or the beginning of the output, etc.
[0060] 4. Data Flywheel A "data flywheel" can be understood as a feedback loop mechanism that continuously optimizes AI models by collecting data from interactions or processes, thereby generating better results and more valuable data. For example, the working principle of an AI data flywheel is to create a loop mechanism that helps AI models integrate institutional knowledge and user feedback, thus achieving continuous improvement. When the model generates output results, the data flywheel collects feedback and new data for optimization and enhancement. This process involves data governance and improved data quality to ensure that the accuracy and performance of the AI model are continuously improved.
[0061] 5. Reinforcement learning from human feedback (RLHF) RLHF is a method that combines reinforcement learning with human feedback to optimize the behavior and output of a model in a way that better aligns with human expectations. By introducing human feedback as a reward signal, it guides the model to better understand and satisfy human preferences, generating more natural outputs that are more in line with human intent. Typically, the RLHF framework contains several key elements that work together to ensure the model can optimize based on human feedback, which are briefly introduced below: (1) Reinforcement Learning Algorithm (RL Algorithm): The reinforcement learning algorithm is responsible for training the model to optimize its behavior. In RLHF, the commonly used reinforcement learning algorithm is proximal policy optimization (PPO). PPO is an "on-policy" algorithm in which the model learns and updates directly from the current policy without relying on past experience. Through the PPO algorithm, the model can adjust its policy based on the reward signal and ultimately generate the desired output.
[0062] (2) Action: In the RLHF framework, an action is the output text generated by the model based on a given prompt. Each output can be viewed as a choice made by the model when performing a task. The action space includes all possible tokens in the vocabulary and their permutations and combinations.
[0063] (3) Environment: The environment is the scenario in which the model interacts with the outside world, providing the state, actions, and corresponding rewards that the model needs to perform tasks. In RLHF, the environment is the external world in which the model generates output based on prompts and adjusts its behavior based on feedback.
[0064] (4) State space: All possible states presented to the model by the environment, usually the hints or context information input to the model.
[0065] (5) Action space: All possible actions that the model can perform, i.e. all output text generated based on the prompts.
[0066] (6) Reward function: Based on the model's output, the reward function assigns either a reward or a penalty. Typically, these rewards are predicted by a trained reward model that evaluates the output quality based on human feedback.
[0067] (7) Observation: Observations are the input prompts received by the model when generating output. These prompts serve as the basis for the model's decision-making and task execution. The observation space refers to the possible sequences of input tokens, i.e., the prompt text processed by the model.
[0068] (8) Reward Mechanism: The reward mechanism is a core component of the RLHF framework, responsible for allocating rewards or penalties based on the predictions of the reward model. The reward model is typically trained using a large amount of human feedback data to ensure accurate prediction of human preferences for different outputs. Feedback data is usually obtained by ranking and scoring the model outputs.
[0069] Typically, training a model based on the RLHF framework requires three stages: (1) First, sampling is performed from the prompt dataset. Annotators write answers for the sampled prompts according to requirements, forming descriptive data. This data is used to fine-tune the model, training a supervised learning model (SFT). Supervised fine-tuning of the model using descriptive data enables the model to generate answers that meet basic requirements. (2) Next, sampling is performed from the prompt database to generate multiple model outputs. Annotators score or rank these outputs to form comparative data, which is then used to train a reward model (RM). The reward model predicts the preference scores for different outputs, thereby helping the model generate higher quality outputs. (3) Finally, the PPO algorithm is used to optimize the reward model. By sampling from the dataset, the model outputs based on the initial data obtained in the supervised learning stage. The reward model scores each output, and finally, the PPO algorithm is used to adjust the model strategy to generate outputs that better meet human expectations. Through the RLHF method, the model can gradually improve its performance using human feedback, ultimately training a model that can generate high-quality outputs.
[0070] Figure 1 This is a flowchart illustrating an embodiment of the RLHF framework in this application. The preference dataset can be understood as the starting point of the entire process. This dataset contains human preference annotations for different LLM outputs. For example, for the same prompt word, experts can annotate which generated text is better. This annotated data provides the supervision information needed to train the reward model. The reward model can be understood as a model trained on the preference dataset through supervised learning. This model learns how to predict the degree of human preference for the quality of the input text; for example, it can output a numerical reward score. A higher score indicates that the generated text is better and more in line with human expectations. This step can also be understood as supervised learning, using human-provided preference data for training. The reinforcement learning training loop can be understood as an iterative process. For example, the base large language model can be understood as a pre-trained language model that needs improvement. The reward model evaluates the text generated by the base large language model and gives a reward score. Then, the reinforcement learning algorithm can update the parameters of the large language model based on these reward scores, making it generate text that better matches human preferences. This loop continues to iterate until the model performance reaches a satisfactory level. 6. Reinforcement learning based on process-oriented human feedback Process-based reinforcement learning with human feedback transforms human feedback from evaluating only the final output to evaluating and guiding each intermediate step in the model's reasoning process. This typically involves the following steps: Step 1: Constructing a process reward model (PRM) corpus. For example, given a cue word, the model generates a response. Instead of simply scoring the final result, at each step of generation (e.g., after generating a word or a reasoning step), an expert evaluates multiple possible "next word" (candidate actions). For example, the expert scores or ranks these candidate actions, indicating which is the best next step. This results in a large set of triples: [current state (generated text), candidate action (next word), human reward]. Step 2: Training the PRM. For example, using the PRM corpus collected in Step 1, a dedicated process reward model is trained. This PRM learns a function: f(current state, candidate action) -> predicted reward. It can judge, like a human expert, what is the best next step at any point in the generation process. Step 3: Reinforcement learning optimization. For example, a policy model (or a model to be optimized) can be generated that receives prompt words and begins generating content. For instance, at each generation step, it consults the Policy Manager (PRM): "If I generate word A next, how many points can I expect? What about word B?" The AI model will tend to choose actions (words) that yield higher rewards according to the PRM's prediction. After the entire generation process is complete, the sum of the rewards from all steps constitutes the total reward for this generation. Reinforcement learning algorithms (such as PPO) use this dense total reward signal to update the parameters of the policy model, making it more likely to generate high-reward actions in the future.
[0071] Software testing is a crucial means of ensuring software program quality, and test cases are typically used to verify the correctness of software programs. Currently, software products are widely used, and the effectiveness of test cases has long been a major concern. Because manually writing test cases requires significant effort and cost, and necessitates expert knowledge, the demand for automated test case generation technologies is increasing. In recent years, with the continuous development of deep learning methods, more and more research has begun to focus on using large language models for unit test case generation tasks.
[0072] Research has begun on reinforcement learning methods based on process-oriented human feedback to train AI models that can automatically generate test cases. However, current PRM corpora for code-related tasks are obtained through manual annotation. For example, for a test case, experts annotate the test case's score (i.e., reward), thus creating the PRM corpus. However, manual PRM corpus annotation requires a significant investment of expertise in the relevant task, resulting in high costs and low annotation efficiency.
[0073] In view of this, this application provides a method for obtaining process reward model corpus of test cases. By pre-setting detection rules, the computing device can automatically score the quality of each test case, thereby improving the generation efficiency of PRM corpus and reducing manual costs.
[0074] Figure 2 This is a schematic block diagram of a method 200 for obtaining a process reward model corpus of test cases, as provided in this application. For example, this method can be executed by a computing device; or, for example, this method can be executed by a module of the computing device, such as... Figure 2 As shown, the method includes: 210. Obtain the first information, which includes multiple test cases.
[0075] For example, the first information may also include prompts corresponding to multiple test cases, each prompt indicating the user's needs, and the multiple test cases being test cases that satisfy the user's needs. For example, multiple test cases may have the same prompt, which can be understood as different test cases being obtained based on the same prompt input by the user; or, for another example, multiple test cases may have different prompts.
[0076] In one possible implementation, initial information can be obtained from open-source networks. This can also be understood as using publicly available datasets.
[0077] In another possible implementation, the first information can be collected manually. For example, the first information can be obtained from a pre-trained first model used to generate test cases based on the prompts input by the user. The input of the first model is the prompt, and the output of the first model is the test case corresponding to the prompt. For instance, the user can input a prompt (e.g., "Please generate a test case for an addition function"), and the pre-trained first model can generate one or more test cases based on the user's request. For example, N (where N is an integer greater than 1) test cases can be collected using this method.
[0078] For example, the "test case" mentioned in the embodiments of this application can be understood as a "unit test case", or an "integration test case" or a "system test case", etc. The embodiments of this application do not limit the specific type of test case.
[0079] 220, Send the second message, which includes the target test case.
[0080] In this embodiment, multiple test cases include target test cases. The target test cases are obtained based on the scoring results corresponding to each target test case. The scoring results for each test case are obtained by scoring the detection results of each test case according to preset detection rules. These preset detection rules include detection rules for the code structure of the test cases and / or detection rules for the execution results of the test cases. The preset detection rules are described in detail below.
[0081] "Code structure detection rules for test cases" can be understood as static detection of test cases. For example, "static detection" can be understood as test rules written using abstract syntax tree (AST) technology. These rules depend on different test frameworks. For example, the quality of test cases can be reflected through syntax checking, testing framework-related application programming interface (API) usage specification checks, etc.
[0082] For example, the "rules for detecting the code structure of test cases" can also be called the "rules for detecting the code elements of test cases", the "rules for detecting the constituent elements of the code of test cases", or the "rules for detecting the components of the code of test cases", and so on.
[0083] In one possible implementation, the code structure detection rules for test cases include at least one of the following: detection rules for each code component in the test case, and detection rules for the business components in the test case (which can also be understood as detection rules for the legality of the business components in the test case). For example, for a unit test case, AST parsing can be used to decompose a complete test case into various code components, then each business component can be obtained based on each code component, and each code component and each business component can be scored according to the corresponding rules.
[0084] Figure 3 This application illustrates a schematic diagram of testing test cases according to code structure detection rules, such as... Figure 3 As shown, the code components within the obtained test cases can be analyzed using software analysis techniques, and each component can be analyzed. For example, individual code components can be analyzed, and business components can also be analyzed. Then, a score can be assigned based on the detection results to obtain the static detection score for the entire test case. For example, the scores for each part of the test case can be summed to obtain the static detection score for the entire test case. For instance, each test case includes multiple lines of code, and the corresponding score for each test case is obtained based on the score corresponding to at least one line of code.
[0085] The following mainly introduces the "each code component in the test case" and "each business component in the test case" mentioned in the embodiments of this application, as well as their respective detection rules.
[0086] In this embodiment, "each code component in a test case" can be understood as the detection of the various parts that constitute the source code of a test case. These parts work together to verify the specific function or behavior of the code under test. In other words, it can also be understood as the smallest unit in the code of a test case that can be identified by static or dynamic analysis tools and used to understand the logic, structure, and behavior of the test case. For example, "detection rules for each code component in a test case" can be understood as the detection and analysis of one or more of the following code components: "dependency imports," "annotations," "class declarations," "method declarations," "local variable declarations," "domain variable access," "method call information," etc. For example, corresponding scoring rules can be determined for each of the above code components. The following is a brief introduction to these components and their corresponding detection rules.
[0087] For example, "dependency import" can be understood as external libraries, frameworks, or modules imported into test cases, such as JUnit, Mockito, Selenium, etc. These dependencies provide the tools and functions required for testing, reflecting the context and dependencies of the test cases. For example, "dependency import detection rules" can include at least one of the following: (1) Clearly declare all dependencies to avoid implicit dependencies. Use dependency management tools to manage dependencies, ensure version consistency, and prevent conflicts. (2) Import only the dependencies necessary for testing, avoid importing unnecessary libraries, and reduce the complexity and runtime of test cases. (3) Isolate test cases from external environments as much as possible, such as databases, file systems, etc. External dependencies can be simulated using mock objects or stub methods to improve the stability and repeatability of tests.
[0088] For example, "annotation" can be understood as annotations used in test case code, such as @Test, @Before, @After, @Autowired, etc. These annotations provide metadata about test methods, such as the execution order of test methods, dependency injection, etc. For example, annotations can determine the execution method of test cases. For example, "annotation information detection rules" can include at least one of the following: (1) Follow the annotation specifications of the test framework (such as JUnit, TestNG), such as @Test, @Before, @After, @BeforeEach, @AfterEach, etc., to ensure the correct execution order of test methods and resource management. (2) Do not over-rely on annotations; a clear code structure is easier to understand and maintain than too many annotations.
[0089] For example, a "class declaration" can be understood as the declaration of a test case class, including the class name, access modifiers (public, private, etc.), inheritance relationship, and implemented interfaces. This defines the structure and type of the test case. For example, the "rules for detecting class declaration information" could be: use clear and concise naming to describe the function and purpose of the test case. For example, `testCalculateSum_positiveNumbers()` is easier to understand than `test1()`.
[0090] For example, a "method declaration" can be understood as a declaration of a test method, including the method name, access modifiers, parameter list, return type, etc., which defines the specific test logic. For example, the "method declaration information detection rules" can include at least one of the following: (1) The test method name should clearly describe the functional points it tests and should use test_ or Test as a prefix; (2) Maintain consistent naming conventions in the project, such as using all lowercase letters with underscores, or camelCase naming, to avoid style confusion.
[0091] For example, "local variable declaration" can be understood as a variable declared inside the test method, used to store temporary data used during the test. These variables reflect the calculations and logic inside the test method. For example, "domain variable access information" can be understood as the access to member variables (instance variables) defined in the test case class, including read and write operations. These variables may be used to store test data or state information. The detection rules for these two components may include at least one of the following: (1) Choose meaningful names for local variables and domain variables, and avoid using single-letter or meaningless names. (2) Narrow the scope of local variables to improve the readability and maintainability of the code. (3) Avoid using global variables, because global variables increase the coupling and complexity of the code.
[0092] For example, "method call information" can be understood as the situation of calling other methods in the test case, including calls to the code under test and calls to auxiliary methods. This is the core part of the test case, reflecting the flow of the test logic and the interaction with the code under test. For example, "method call information detection rules" may include at least one of the following: (1) Avoid excessively long call chains and maintain the conciseness and readability of the code.
[0093] (2) If multiple test methods need to call the same code, these codes can be extracted into independent helper methods to improve code reusability and maintainability.
[0094] In this embodiment of the application, "business components in test cases" can be understood as business components extracted from various code components, or as business components that can be obtained based on one or more code components. For example, in the business scenario of unit test cases, the various business components determined. For example, business components may include one or more of the following: "initialization content", "Mock syntax", "variable declaration", "domain variable usage", and "return type". Generally, code components can be understood from the perspective of technical implementation, focusing on code structure, syntax, structure, and algorithms; while business components can be understood from the perspective of business logic, focusing on business functions, processes, and data.
[0095] For example, initialization content in business components can be obtained based on dependency imports, class declarations, domain variable declarations, and annotations in code components; mock syntax can be obtained based on method call information in code components; variable declarations in business components can be obtained based on local variable declarations and / or individual variables in code components; and domain variable usage in business components can be obtained based on domain variable access in code components. Optionally, the preset detection rules also include rules for extracting business components. For example, it can detect whether the extracted code components that make up the business components are correct and score them.
[0096] For example, "initialization content" can be understood as data or conditions that set the initial state of the test scenario, such as database initialization, file preparation, and system parameter settings. These initializations directly affect the execution results of the business logic. Similarly, "Mock code" can be understood as code that simulates external dependencies (such as databases, network services, and third-party libraries), ensuring that test cases can run independently and focus on verifying the business logic of the system under test, rather than the stability of external dependencies. Typically, mocks themselves are not business logic, but the simulated data and behavior directly affect the execution of the business logic, and therefore can be considered part of the business logic. For example, "variable declarations" and "domain variable usage" can be understood as variables and domain variables that participate in the calculation, judgment, or flow control of the business logic. For example, variables that store user input, intermediate calculation results, or final output. For example, "return type" can be understood as the return type and return value of the method or function under test, which reflects the output results of the business logic and is therefore an important business component.
[0097] In this embodiment, corresponding scoring rules can be determined for each of the aforementioned business components. For example, business component analysis can be performed on the code components used in the function under test, extracting the unit test initialization part, mock code part, variable declaration part, domain variable usage part, and return type part, and scoring them according to the corresponding rules. For example, the "detection rules for the business components of test cases" may include detection analysis of one or more of the following: initialization detection rules, mock code detection rules, variable declaration detection rules, domain variable usage detection rules, and return type detection rules. For example, corresponding inspection rules can be formulated for several parts of the unit test, such as initialization content, mock code, variable declaration, domain variable usage, and return type, and each part can be scored separately.
[0098] Table 1 below shows the detection rules for the business components of a test case. As shown in Table 1, the detection rules for the business components include rules for checking the syntax of the business components, the usage specifications of the test framework related interfaces, etc., as well as context alignment checks. The context alignment check mainly checks the generated test cases and the prompt words corresponding to the test cases. Figure 4 This is a schematic diagram illustrating the detection effect of a test case in an embodiment of this application, as shown below. Figure 4 As shown, some lines of code do not conform to the business inspection rules in Table 1 at all, while some lines of code conform to the business inspection rules in Table 1.
[0099] Table 1
[0100] Specifically, those skilled in the art can reasonably determine the detection rules for each business component in the test case according to the actual business scenario, and no further examples will be given.
[0101] In this embodiment of the application, the "test case execution result detection rule" can be understood as the detection during test case execution. It can also be understood as the test case execution result detection rule including metric detection rules, which include at least one of the following: test case compilation rate, test case coverage, and test case assertion pass rate. For example, Figure 5 This is a schematic flowchart illustrating how a test case executor executes test cases, as shown in an embodiment of this application. Figure 5As shown, a test case executor can be used to load and execute pre-written test cases. For example, the test case executor can break down a test case into multiple test case fragments, extract these fragments, analyze them, and automatically build the necessary execution environment. Based on the analysis results, complete test cases are constructed, and then executed. This allows for the acquisition of information such as compilation rate and coverage, and a summary report of the test results is generated.
[0102] Based on the above technical solution, this application embodiment combines two analysis techniques, runtime detection and static detection, to perform step-by-step detection on each component of each test case. For example, it can be accurate to detect and score each line of code. In other words, this solution can obtain a more granular score.
[0103] For example, the compilation rate, coverage, and assertion pass rate of the entire test case can be converted into scores, and then combined with the scores obtained from static detection to obtain the overall score of the entire test case after executing the preset detection rules. For instance, a normalization algorithm can be used to normalize both the static detection score and the execution-time detection score, and then a weighted algorithm can be used to calculate the overall score of the test case. Figure 6 This is a schematic flowchart illustrating the process of obtaining target test cases provided in an embodiment of this application, such as... Figure 6 As shown, after performing static and runtime testing on the test cases, the scores of each test case can be sorted to obtain the target test cases.
[0104] For example, the target test cases include two test cases: the test case with the highest score and the test case with the lowest score. In this case, the target test cases can also be understood as a pair of test cases. For example, the target test cases include multiple pairs of test cases, such as the test case with the highest score and the test case with the lowest score, the test case with the second-highest score and the test case with the second-lowest score, and so on. For example, the second information can also include the score corresponding to the target test cases. In the embodiments of this application, the second information can also be understood as PRM corpus.
[0105] In one possible scenario, the second information also includes the prompt words corresponding to the target test cases. The second information is used to train the second model, which is used to generate test cases based on the prompt words input by the user. The input of the second model is the prompt words, and the output of the second model is the test cases corresponding to the prompt words. The second model is trained using a reinforcement learning method based on human feedback with process rewards.
[0106] At this point, it can also be understood that the PRM corpus can be obtained based on the second information output. For example, a second model can be trained based on the second information. For instance, a reward model can be trained first based on the second model, and then a policy model can be trained based on the reward model; this policy model can be understood as the second model. Specifically, this application does not limit how the second model is trained.
[0107] In another possible implementation, the method further includes: receiving feedback information from a user, the feedback information indicating whether the user approves the target test case; obtaining third information based on the feedback information, the third information including test cases approved by the user and prompt words corresponding to the user-approved test users, and / or, test cases not approved by the user and prompt words corresponding to the user-not-approved test users; the third information is used to train a second model, the second model being used to generate test cases based on prompt words input by the user, the input of the second model being the prompt words, the output of the second model being the test cases corresponding to the prompt words, and the second model being trained using a reinforcement learning method based on human feedback with process rewards.
[0108] At this point, it can also be understood that this application can output the target test case with the highest score (or several target test cases with the highest scores) to the user. Based on the user's feedback, it can be determined whether the target test case really meets the user's requirements. Therefore, based on the user's feedback, a more accurate PRM corpus can be obtained.
[0109] In this embodiment of the application, the second model can be another model different from the first model; for example, the second model can be the first model, which can also be understood as updating, fine-tuning or retraining the first model.
[0110] For example, Figure 7 This application embodiment illustrates a schematic flowchart of a model training method based on user feedback and training data collection, such as... Figure 7As shown, the user can input a request message into the target model. This request message can also be understood as a prompt, used to instruct the user to generate test cases that meet a certain requirement. For example, the target model can generate multiple candidate test cases. The target model can be an AI model deployed in the cloud or on a local client. For example, when the target model is deployed in the cloud, an AI-assisted development tool (e.g., a plugin) can be used to send the user's inference request message to the large model in the cloud. Then, according to the method provided in embodiment 200 of this application, each candidate test case is automatically scored according to a preset detection rule, and finally, the test cases with higher scores are displayed to the user interface. For example, one or more test cases with higher scores can be displayed to the user. Subsequently, assuming the user provides feedback on the test case, for example, the user approves of a test case (e.g., likes a test case), or the user disapproves of a test case, etc., training data can be obtained based on the feedback information provided by the user, thereby training the model. For example, the target model can be further fine-tuned (which can also be understood as post-training). For example, other models can be trained based on the collected training data. For example, data flywheel technology can be used to collect training data.
[0111] It should be noted that the specific steps for training a model using reinforcement learning methods based on process-based rewards and human feedback can be found in the preceding section on related terminology (e.g., Figure 1 We will use existing model training methods to understand this further, without going into details.
[0112] Based on the above technical solution, in this embodiment of the application, since the scoring of test cases can be accurate down to the detection and scoring of each line of code, when the test cases indicated by the user's feedback information are received, more granular and comprehensive data support can be provided for the data flywheel. This allows the model training to be better guided and the quality of the model to be improved when the reinforcement learning method based on process reward human feedback is used to train the model.
[0113] The solution provided in this application can be used in ordinary scenarios and can also be applied to cloud service scenarios. Figure 8 This is a schematic diagram of a cloud service system architecture used in this application, such as... Figure 8 As shown, this cloud scenario may include: a cloud management platform 810, the Internet 820, and a client 830. For example... Figure 8 As shown, the cloud management platform 810 is used to manage the infrastructure that provides multiple cloud services. The infrastructure includes multiple cloud data centers, each containing multiple servers, and each server containing cloud service resources to provide corresponding cloud services to tenants. In this embodiment, the cloud service resources may be cloud databases.
[0114] The cloud management platform 810 can be located in a cloud data center and provides access interfaces (such as user interfaces or application program interfaces, APIs). Tenants can use client 830 to remotely access the access interface to register a cloud account and password on the cloud management platform 810 and log in. After successful authentication of the cloud account and password on the cloud management platform 810, the tenant can further select and purchase virtual machines with specific specifications (processor, memory, disk) on the cloud management platform 810. After successful purchase, the cloud management platform 810 provides the remote login account and password for the purchased virtual machine, and client 830 can remotely log in to the virtual machine to install and run the tenant's applications. Therefore, tenants can create, manage, log in to, and operate virtual machines in the cloud data center through the cloud management platform 810.
[0115] The cloud management platform 810 includes, but is not limited to, a tenant console, compute management services, network management services, storage management services, authentication services, and image management services. The tenant console provides an interface or API for interaction with tenants. The compute management services manage servers running virtual machines and containers, as well as bare metal servers. The network management services manage network services (such as gateways and firewalls). The storage management services manage storage services (such as data bucket services). The authentication services manage tenant account passwords. The image management services manage virtual machine images. Tenants use client 830 and can log in to the cloud management platform 810 via the internet 820 to manage their rented cloud services.
[0116] For example, the methods provided in the embodiments of this application can be executed by a server.
[0117] For example, the at least one cloud data center is deployed with a first model and / or a second model.
[0118] It is understood that the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.
[0119] It should also be understood that the ordinal numbers such as "first" and "second" mentioned in the embodiments of this application are used to distinguish multiple objects, and are not used to limit the size, content, order, timing, priority or importance of multiple objects.
[0120] It should also be understood that, in this application, "at least one" means one or more, and "more than one" means two or more. "At least one item" or similar expressions mean one or more items, that is, any combination of these items, including any combination of single items or multiple items. For example, at least one of a, b, or c means: a, b, c, a and b, a and c, b and c, or a and b and c.
[0121] It should also be understood that, in the various embodiments of this application, determining B based on A does not mean that B is determined solely based on A; B can also be determined based on A and / or other information.
[0122] Those skilled in the art will recognize that, based on the units and algorithm steps described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is implemented in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0123] This application embodiment can divide the computing device into functional modules according to the above method example. For example, each function can be divided into its own functional modules, or two or more functions can be integrated into one processing module. The integrated modules can be implemented in hardware or as software functional modules. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods. The following description uses the division of functional modules according to each function as an example.
[0124] Figure 9 This is a schematic block diagram of a computing device 900 provided in an embodiment of this application. As shown in the figure, the computing device 900 may include: an acquisition module 910 and a transceiver module 920.
[0125] In one possible approach, computing device 900 can be understood as the computing device in the embodiments of this application, which can be used to execute the steps corresponding to method 200.
[0126] For example, the acquisition module is used to acquire first information; the send / receive module is used to send second information. As another example, the send / receive module is used to receive feedback information from the user, and the acquisition module is used to obtain third information based on the feedback information.
[0127] It should also be understood that the computing device 900 here is embodied in the form of a functional unit. The term "unit" here may refer to application-specific integrated circuits (ASICs), electronic circuits, processors (e.g., shared processors, proprietary processors, or group processors) and memory for executing one or more software or firmware programs, integrated logic circuits, and / or other suitable components that support the described functions.
[0128] The computing device 900 in each of the above schemes has the function of implementing the corresponding steps of the method 200. The function can be implemented in hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions; for example, the acquisition module can be replaced by a processor to execute the send / receive operations and related processing operations in each method embodiment. Furthermore, the acquisition module can also be a processing circuit.
[0129] It should be pointed out that, Figure 9 The computing device mentioned can be the computing device in the aforementioned method embodiments, or it can be a chip or chip system corresponding to the computing device, such as a system on a chip (SoC). Each module can also be a processor, microprocessor, or integrated circuit integrated on the chip. No limitation is made here.
[0130] Figure 10 This is a schematic block diagram of another computing device 1000 provided in an embodiment of this application. As shown, the computing device 1000 includes at least one processor 1020. The processor 1020 is coupled to a memory and is used to execute instructions stored in the memory to send and / or receive signals. Optionally, the device 1000 also includes a memory 1030 for storing instructions. Optionally, the computing device 1000 also includes a transceiver 1010, and the processor 1020 controls the transceiver 1010 to send and / or receive signals.
[0131] It should be understood that the processor 1020 and memory 1030 described above can be combined into a single processing device, with the processor 1020 executing the program code stored in the memory 1030 to achieve the aforementioned functions. In specific implementations, the memory 1030 can be integrated into the processor 1020 or independent of the processor 1020.
[0132] It should also be understood that transceiver 1010 may include a transceiver (or receiver) and a transmitter (or transmitter). The transceiver may further include an antenna, and the number of antennas may be one or more. Transceiver 1010 may have a communication interface or interface circuitry.
[0133] The 1040 bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, Figure 10 The bus 1040 may be represented by a single line, but this does not mean that there is only one bus or one type of bus. The bus 1040 may include a path for transmitting information between various components of the device 1000 (e.g., memory 1030, processor 1020, transceiver 1010).
[0134] The memory 1030 stores executable program code, and the processor 1020 executes the executable program code to implement the functions of the aforementioned modules, thereby implementing the methods in the embodiments of this application. That is, the memory 1030 stores instructions for executing the above methods. For example, the processor 1020 is used to execute the computer program or instructions stored in the memory 1030 to implement the steps corresponding to method 200 in the various embodiments above.
[0135] Figure 11 This is a schematic diagram of the architecture of a computing device cluster provided in an embodiment of this application. The computing device cluster includes at least one computing device. This computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smartphone. Figure 11 As shown, the computing device cluster includes at least one computing device 1100. The memory 1130 of one or more computing devices 1100 in the computing device cluster may store the same instructions for performing the actions described in embodiment 200 above.
[0136] In some possible implementations, the memory 1130 of one or more computing devices 1100 in the computing device cluster may also store partial instructions for performing the actions executed in the method 200 described in the above embodiments. In other words, a combination of one or more computing devices 1100 can jointly execute instructions for performing the actions executed by the method 200 described in the above embodiments.
[0137] For example, in one possible approach, one or more computing devices 1100 may be used to implement the steps corresponding to the foregoing embodiments.
[0138] It should be noted that the memory 1130 in different computing devices 1100 within the computing device cluster can store different instructions, which are used to execute parts of the functions of computing devices 900 and 1000, respectively. That is, the instructions stored in the memory 1130 of different computing devices 1100 can implement the functions of one or more of the aforementioned modules.
[0139] Alternatively, the memory 1130 in different computing devices 1100 within the computing device cluster can store different instructions, each used to execute a portion of the functions corresponding to the aforementioned devices 900-1000. That is, the instructions stored in the memory 1130 of different computing devices 1100 can implement the functions of one or more of the aforementioned modules.
[0140] In some possible implementations, one or more computing devices in a computing device cluster can be connected via a network. This network can be a wide area network (WAN) or a local area network (LAN), etc. Figure 12 One possible implementation is shown, such as Figure 12 As shown, the two computing devices 1100A and 1100B are connected via a network. Specifically, they are connected to the network through the communication interfaces in each computing device.
[0141] It should be understood that Figure 12 The functions of the computing device 1100A shown can also be performed by multiple computing devices 1100. Similarly, the functions of the computing device 900B can also be performed by multiple computing devices 1100.
[0142] Figure 12 The connection method between the computing device clusters shown can be such that, considering the need to obtain test cases for the method provided in this application, the function implemented by the acquisition module is delegated to the computing device 1100B.
[0143] In this embodiment, a computer program product containing instructions is also provided. The computer program product may be a software or program product containing instructions capable of running on a computing device cluster or stored on any available medium. When run by the computing device cluster, it causes the computing device cluster to perform the methods provided above, or causes the computing device cluster to implement the functions of the apparatus provided above.
[0144] In this embodiment, a computer-readable storage medium is also provided. This computer-readable storage medium can be any available medium that a computing device can store, or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., digital video disc (DVD)), or a semiconductor medium (e.g., a solid-state drive). The computer-readable storage medium includes instructions that, when executed on a computing device, cause the computing device to perform the method described above.
[0145] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0146] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0147] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0148] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0149] In addition, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0150] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0151] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for obtaining process reward model corpus for test cases, characterized in that, The method includes: Obtain first information, which includes multiple test cases; Send a second message, the second message including target test cases, the plurality of test cases including the target test cases, the target test cases being obtained based on the scoring results corresponding to each target test case, the scoring results corresponding to each test case being obtained by scoring the detection results of each test case according to preset detection rules, the preset detection rules including detection rules for the code structure of test cases and / or detection rules for the execution results of test cases.
2. The method according to claim 1, characterized in that, The code structure detection rules for the test cases include at least one of the following: detection rules for each code component in the test cases, and detection rules for each business component in the test cases, wherein each business component in the test cases is obtained based on at least one code component in the test cases.
3. The method according to claim 2, characterized in that, The first information also includes prompt words corresponding to each of the plurality of test cases. Each prompt word is used to indicate the user's needs. The plurality of test cases are test cases that meet the user's needs. The detection rules for the business components in the test cases include detection rules for the test cases and the prompt words corresponding to the test cases.
4. The method according to any one of claims 1 to 3, characterized in that, Each test case includes multiple lines of code, and the corresponding score for each test case is obtained based on the score corresponding to at least one line of code.
5. The method according to any one of claims 1 to 4, characterized in that, The detection rules for the execution results of the test cases include the detection rules for metrics, and the metrics include at least one of the following: test case compilation rate, test case coverage, and test case assertion pass rate.
6. The method according to any one of claims 1 to 5, characterized in that, The acquisition of the first information includes: The first information is obtained according to the first model, which is used to generate test cases based on the prompt words input by the user. The input of the first model is the prompt words, and the output of the first model is the test cases corresponding to the prompt words.
7. The method according to any one of claims 1 to 6, characterized in that, The second information also includes the prompt words corresponding to the target test case. The second information is used to train the second model. The second model is used to generate test cases based on the prompt words input by the user. The input of the second model is the prompt words, and the output of the second model is the test cases corresponding to the prompt words. The second model is trained using a reinforcement learning method based on human feedback with process rewards.
8. The method according to any one of claims 1 to 6, characterized in that, The method further includes: Receive feedback information from the user, the feedback information being used to indicate whether the user approves the target test case; A third piece of information is obtained based on the feedback information. The third piece of information includes test cases approved by the user and prompt words corresponding to the test users approved by the user, and / or test cases not approved by the user and prompt words corresponding to the test users not approved by the user. The third piece of information is used to train a second model. The second model is used to generate test cases based on the prompt words input by the user. The input of the second model is the prompt words, and the output of the second model is the test cases corresponding to the prompt words. The second model is trained using a reinforcement learning method based on human feedback with process rewards.
9. The method according to any one of claims 1 to 8, characterized in that, The method is applied to a cloud service system, the cloud service system including a cloud management platform for managing infrastructure that provides cloud services, the infrastructure including at least one cloud data center, the at least one cloud data center including at least one server, the at least one server being used to perform the method as described in any one of claims 1 to 8.
10. A computing device, characterized in that, The computing device includes an acquisition module and a transceiver module, wherein... The acquisition module is used to acquire first information, which includes multiple test cases; The transceiver module is used to send second information, the second information including target test cases, the plurality of test cases including the target test cases, the target test cases being obtained based on the scoring results corresponding to each target test case, the scoring results corresponding to each test case being obtained by scoring the detection results of each test case according to preset detection rules, the preset detection rules including detection rules for the code structure of test cases and / or detection rules for the execution results of test cases.
11. The computing device according to claim 10, characterized in that, The code structure detection rules for the test cases include at least one of the following: detection rules for each code component in the test cases, and detection rules for business components in the test cases, wherein each business component in the test cases is obtained based on at least one code component in the test cases.
12. The computing device according to claim 11, characterized in that, The first information also includes prompt words corresponding to each of the plurality of test cases. Each prompt word is used to indicate the user's needs. The plurality of test cases are test cases that meet the user's needs. The detection rules for the test cases include detection rules for the test cases and the prompt words corresponding to the test cases.
13. The computing device according to any one of claims 10 to 12, characterized in that, Each test case includes multiple lines of code, and the corresponding score for each test case is obtained based on the score corresponding to at least one line of code.
14. The computing device according to any one of claims 10 to 13, characterized in that, The detection rules for the execution results of the test cases include the detection rules for metrics, and the metrics include at least one of the following: test case compilation rate, test case coverage, and test case assertion pass rate.
15. The computing device according to any one of claims 10 to 14, characterized in that, The acquisition of the first information includes: The first information is obtained according to the first model, which is used to generate test cases based on the prompt words input by the user. The input of the first model is the prompt words, and the output of the first model is the test cases corresponding to the prompt words.
16. The computing device according to any one of claims 10 to 15, characterized in that, The second information also includes the prompt words corresponding to the target test case. The second information is used to train the second model. The second model is used to generate test cases based on the prompt words input by the user. The input of the second model is the prompt words, and the output of the second model is the test cases corresponding to the prompt words. The second model is trained using a reinforcement learning method based on human feedback with process rewards.
17. The computing device according to any one of claims 10 to 15, characterized in that, The transceiver module is also used to receive feedback information from the user, the feedback information being used to indicate whether the user approves the target test case; The acquisition module is used to obtain third information based on the feedback information. The third information includes test cases approved by the user and prompt words corresponding to the test users approved by the user, and / or test cases not approved by the user and prompt words corresponding to the test users not approved by the user. The third information is used to train a second model. The second model is used to generate test cases based on the prompt words input by the user. The input of the second model is the prompt words, and the output of the second model is the test cases corresponding to the prompt words. The second model is trained using a reinforcement learning method based on human feedback with process rewards.
18. The computing device according to any one of claims 10 to 17, characterized in that, The computing device is applied to a cloud service system, the cloud service system including a cloud management platform for managing the infrastructure providing cloud services, the infrastructure including at least one cloud data center, the at least one cloud data center including at least one computing device, the at least one computing device for performing the method as described in any one of claims 1 to 8.
19. A computing device cluster, characterized in that, It includes at least one computing device, each computing device including a processor and memory; The processor of the at least one computing device is configured to execute a computer program or instructions stored in the memory of the at least one computing device, so that the cluster of computing devices performs the method as described in any one of claims 1 to 9.
20. A computer program product containing instructions, characterized in that, When the instruction is executed by the computing device cluster, the computing device cluster performs the method as described in any one of claims 1 to 9.
21. A computer-readable storage medium, characterized in that, Includes a computer program or instructions, which, when executed by a cluster of computing devices, perform the method as described in any one of claims 1 to 9.