Test case processing method and electronic equipment
By obtaining the target distance between test cases and optimizing the test order, the problem of long switching time between test cases was solved, and a more efficient and continuous testing process was achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-26
- Publication Date
- 2026-04-07
AI Technical Summary
During the testing process, the switching between test cases takes a long time, resulting in low testing efficiency and poor continuity.
By obtaining the target distance between multiple test cases, a distance matrix is constructed. Then, using clustering algorithms and pre-trained neural network models, the test order is optimized to reduce transition and reset time.
It significantly improves the efficiency of the testing process, shortens the testing cycle, reduces reset and transition time, and enhances the accuracy and reliability of the tests.
Smart Images

Figure CN121807716A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of testing technology, and in particular to a method for processing test cases and an electronic device. Background Technology
[0002] In the testing field, such as testing vehicle systems, as testing complexity increases, the number of test cases gradually grows, and the switching between test cases becomes a significant factor restricting testing efficiency. Related test order adjustment methods, such as script priority-based adjustments or coverage-based sorting, mainly focus on parallel execution of tests and test case selection. However, the time-consuming issue of switching between test cases persists. In scenarios involving a large number of system state adjustments, the accumulated time required for resets and state transitions during these test case switches is considerable, severely slowing down the testing progress and resulting in high execution time and poor continuity of test cases in related technologies. Summary of the Invention
[0003] This application provides a test case processing method and electronic device, aiming to improve the technical problems of high execution time and poor continuity of test cases in related technologies.
[0004] According to one aspect of the embodiments of this application, a method for processing test cases is provided, comprising: acquiring a plurality of test cases; determining a target distance between any two test cases among the plurality of test cases, wherein the target distance is used to characterize the time required to switch between any two test cases; determining a target test order of the plurality of test cases based on the target distance between any two test cases; and performing tests based on the target test order and the plurality of test cases.
[0005] This application systematically acquires multiple test cases, providing rich data support for subsequent distance calculation and sorting adjustments. By determining the target distance between any two test cases, the conversion time between test cases is quantified as the target distance, facilitating algorithm understanding and processing, thus providing an accurate comparison benchmark for adjusting the test order. Distance calculation provides data processing basis for adjusting the test order. By minimizing the target distance, the time spent on conversion and reset operations between test cases can be reduced. The adjusted test order ensures a smoother testing process, reduces potential errors caused by complex conversion and reset operations, and improves the accuracy and reliability of the test. By testing based on the target test order and multiple test cases, the adjusted test order reduces the reset and conversion time between test cases, significantly improving the efficiency of the testing process, shortening the overall testing cycle, and thus solving the technical problems of high execution time and poor continuity of test cases in related technologies.
[0006] In this embodiment of the application, determining the target distance between any two test cases among multiple test cases includes: obtaining an initial condition set and an expected result set, wherein the initial condition set includes: the initial conditions required to start executing each test case, and the expected result set includes: the expected results achieved by ending the execution of each test case; and determining the target distance between any two test cases based on the initial condition set and the expected result set.
[0007] In the above process, by determining the initial set of conditions and the expected set of results, the transition time between any two test cases can be accurately quantified. By calculating and minimizing the target distance, the transition time between test cases can be minimized while maintaining test coverage, thereby significantly improving test efficiency.
[0008] In this embodiment of the application, determining the target distance between any two test cases based on the initial condition set and the expected result set includes: determining the target expected result corresponding to the first test case from the expected result set, and determining the target initial condition corresponding to the second test case from the initial condition set; determining the target distance between the first test case and the second test case based on the target expected result and the target initial condition, wherein the target distance is used to characterize the time required to switch from the first test case to the second test case.
[0009] In the above process, the state transition costs between test cases are converted into specific numerical values, which facilitates subsequent algorithm understanding and operation, and helps to accurately evaluate the efficiency of the test order. The distance matrix provides a basis for adjusting the test order, enabling the algorithm to determine a better test order by searching for paths with smaller target distances, reducing reset and transition time, and thus significantly improving test efficiency.
[0010] In this embodiment of the application, determining the target test order of multiple test cases based on the target distance between any two test cases includes: constructing a total distance objective function based on the target distance between any two test cases, wherein the total distance objective function is used to represent the objective function established with the total distance between the target distances of any two test cases as the improvement objective; and solving the total distance objective function to obtain the target test order.
[0011] In the above process, adjusting the test order is transformed into solving a problem of objective function. This gives the problem-solving a clear objective and method, enabling the identification of a test order that minimizes conversion costs, thereby improving the testing process. The adjusted test order can reduce the reset and conversion time between test cases, significantly improving the overall testing efficiency and shortening the testing cycle. The effect is even more pronounced when dealing with a large number of test cases.
[0012] In this embodiment of the application, determining the test order of multiple test cases based on the target distance between any two test cases includes: using a preset clustering algorithm to cluster multiple test cases to obtain multiple test case sets; and determining the target test order based on the target distance between any two test cases in the multiple test case sets.
[0013] In the above process, clustering algorithms are used to determine the test order. These algorithms group test cases with similar conversion costs, reducing the conversion time between test cases within the test case set. Furthermore, by adjusting the order within and between test case sets, the overall number of reset and conversion operations between test cases is reduced. This approach breaks down complex technical problems into multiple simpler sub-problems, and by improving the test case set to determine the overall optimal solution, the complexity of the problem is reduced, making the improvement process more efficient.
[0014] In this embodiment of the application, determining the target test order based on the target distance between any two test cases in multiple test case sets includes: determining the test order within a subset of at least one test case in any test case set based on the target distance between any two test cases in any test case set; and merging the test orders within the subset of at least one test case in multiple test case sets to obtain the target test order.
[0015] In the above process, adjusting the test order within the test case set can more precisely reduce reset time and state adjustments, maximizing local efficiency. The adjusted test case set order takes into account the conversion costs between test case sets during merging, ensuring a smooth overall testing process and improving global efficiency.
[0016] In this embodiment of the application, determining the test order within a subset of any test case in any set of test cases based on the target distance between any two test cases in any set of test cases includes: constructing a target function for distance within a subset based on the target distance between any two test cases in any set of test cases, wherein the target function for distance within a subset is used to represent a target function established with the total distance between the target distances between any two test cases in any set of test cases as the improvement objective; and solving the target function for distance within a subset to determine the test order within the subset.
[0017] In the above process, the construction and solution of the objective function within the test case set allows for significant improvements at the local level of the test cases, reducing conversion time and improving testing efficiency. The order within the test case set can serve as the basis for constructing a better overall test order. By improving the local aspects first and then integrating the global aspects, more accurate test process management can be achieved, improving overall testing efficiency.
[0018] In this embodiment of the application, solving the distance objective function within a subset and determining the test order within the subset includes: using a pre-trained neural network model to solve the distance objective function within the subset and obtain the test order within the subset.
[0019] In the above process, pre-trained neural network models can quickly process large amounts of data and find the optimal test order within the test case set more quickly, making them suitable for scenarios with large-scale test cases. Pre-trained neural network models possess good generalization ability, understanding the relationships between different test cases and effectively predicting the optimal execution order when faced with new test cases. Through multiple training iterations, pre-trained neural network models can gradually learn optimal strategies and continuously improve themselves based on data collected from actual testing, thereby enhancing computational accuracy.
[0020] In this embodiment of the application, the test order within a subset of at least one test case in multiple test example sets is merged to obtain a target test order, including: obtaining the test order between subsets of multiple test example sets; and merging the test order within a subset of at least one test case in multiple test example sets based on the test order between subsets to obtain a target test order.
[0021] In the above process, based on improvements within the test case set, the execution order between test case sets was further improved, ensuring maximum testing efficiency from a global perspective. The orderly transition between test case sets enhances the coherence and logic of the testing process, making the entire testing process smoother and reducing interruptions and delays caused by improper test order. By first adjusting the order within the test case set and then addressing the order between test case sets, the complex problem is decomposed, reducing the computational complexity and difficulty of the improved algorithm and improving the efficiency and feasibility of the test order improvement.
[0022] In this embodiment of the application, obtaining the test order among subsets of multiple test example sets includes: determining the inter-subset cluster center and multiple intra-subset cluster centers of any test example set; determining the subset distance between any two test example sets based on the inter-subset cluster center and multiple intra-subset cluster centers, wherein the subset distance is used to characterize the time required to switch between any two test example sets; and determining the test order among subsets based on the subset distance.
[0023] In the above process, the calculation of distances between test case sets provides an accurate assessment of conversion costs, helping to more accurately predict and control time consumption in the testing process and reduce unnecessary waiting and reset time. By determining the cluster centers and calculating the distances between test case sets, the originally complex distance calculation between multiple test cases is simplified, reducing the computational complexity of the algorithm and improving the efficiency of the tuning process.
[0024] According to another aspect of the embodiments of this application, a test case processing apparatus is also provided, comprising: an acquisition module for acquiring a plurality of test cases; a first determination module for determining a target distance between any two test cases among the plurality of test cases, wherein the target distance is used to characterize the time required to switch between any two test cases; a second determination module for determining a target test order of the plurality of test cases based on the target distance between any two test cases; and a testing module for performing tests based on the target test order and the plurality of test cases.
[0025] According to another aspect of the embodiments of this application, an electronic device is also provided, including: a memory storing an executable program; and a processor for running the program, wherein the program executes the methods in various embodiments of this application when it runs.
[0026] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, the computer-readable storage medium including a stored executable program, wherein, when the executable program is running, it controls the device where the computer-readable storage medium is located to perform the methods of various embodiments of this application. Attached Figure Description
[0027] Figure 1 This is a flowchart of a test case processing method according to an embodiment of this application;
[0028] Figure 2 This is a schematic diagram illustrating the processing procedure of an optional test case according to an embodiment of this application;
[0029] Figure 3 This is a schematic diagram of a test case processing device according to an embodiment of this application;
[0030] Figure 4This is a schematic diagram of an electronic device according to an embodiment of this application. Detailed Implementation
[0031] To make the technical problems, technical solutions, and beneficial effects solved by this application clearer, the following detailed description is provided in conjunction with embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0032] This application provides a method for processing test cases, comprising: acquiring multiple test cases; determining a target distance between any two test cases among the multiple test cases, wherein the target distance is used to characterize the time required to switch between any two test cases; determining a target test order for the multiple test cases based on the target distance between any two test cases; and performing tests based on the target test order and the multiple test cases.
[0033] The test case processing method provided in this application achieves the following technical effects: This application systematically acquires multiple test cases, providing rich data support for subsequent distance calculation and sorting adjustments. By determining the target distance between any two test cases, the conversion time between test cases is quantified into the target distance, facilitating algorithm understanding and processing, thereby providing an accurate comparison benchmark for adjusting the test order. Distance calculation provides a data processing basis for adjusting the test order. By minimizing the target distance, the conversion and reset operation time between test cases can be reduced. The adjusted test order ensures a smoother test process, reduces potential errors caused by complex conversion and reset operations, and improves the accuracy and reliability of the test. By testing based on the target test order and multiple test cases, the adjusted test order reduces the reset and conversion time between test cases, significantly improving the efficiency of the test process, shortening the overall test cycle, and thus solving the technical problems of high execution time and poor continuity of test cases in related technologies.
[0034] This application provides a method for processing test cases. Please refer to the embodiments provided. Figure 1 This includes the following steps:
[0035] S110: Obtain multiple test cases.
[0036] The aforementioned test cases refer to a series of test scenarios or cases designed to evaluate and verify the performance of various systems. Each test case can contain a specific set of initial conditions and expected results, covering various situations during vehicle use and detecting the vehicle system's response to different inputs. For example, in an intelligent driving assistance system, a test case could include a scenario where a pedestrian suddenly crosses the road while the vehicle is traveling at low speed. The initial conditions could be parameters such as vehicle speed and pedestrian position, and the expected result could be the vehicle decelerating in time and coming to a stop. Test cases can be used to test vehicles under test, which can be vehicles that need to undergo a series of tests. The hardware and software systems inside a vehicle are quite complex, including multiple layers such as communication systems, sensors, controllers, and actuators. These systems work together during vehicle operation to achieve the various functions of the vehicle.
[0037] In one optional embodiment, collecting and preparing multiple test cases to be executed can provide data support for subsequent adjustments to the test case order. Specifically, a detailed analysis of the test vehicle's functionality, performance, and safety aspects can be conducted to design a series of test cases. Each test case can correspond to one or more functional checkpoints of the vehicle, including vehicle startup, driver assistance, communication systems, and safety systems. For each test case, a feature vector can be extracted, which can contain the initial conditions and expected results of the test case. Initial conditions can include vehicle status, such as engine status, vehicle speed, and battery charge; environmental conditions, such as temperature and light; and the configuration of the test equipment. Expected results can reflect the state or functional performance that the vehicle system and test environment should achieve after the test. The extracted test case feature vectors can also be collected into a set to form a test case library for the vehicle under test. These test cases can include various test requirements from basic functions to advanced driver assistance systems.
[0038] In the above process, by systematically acquiring multiple test cases, rich data support was provided for subsequent test case classification, distance calculation and sorting adjustment, which reduced repetitive work in the test preparation stage and improved data processing efficiency.
[0039] S120: Determine the target distance between any two test cases in a plurality of test cases, wherein the target distance is used to characterize the time required to switch between any two test cases.
[0040] The aforementioned target distance can refer to the time required to measure the reset and preparation phases between executing any two test cases. Since each test case has specific initial conditions and expected results, when transitioning from one test case to another, the system state needs to be reset or adjusted to meet the initial conditions of the new test case.
[0041] In one optional embodiment, for each test case, a feature vector can be constructed based on the changes in the vehicle and environment before and after execution. The feature vector can include initial conditions and expected results. Then, the target distance between any two test cases can be determined by calculating the Euclidean or Manhattan distance between the feature vectors, reflecting the reset and adjustment time required to transition from one test case to another. This distance calculation method quantifies the complexity of state transitions and is directly related to the time consumed in switching test cases. For each test case, a distance matrix can also be constructed, where each element represents the target distance for transitioning from one test case to another, providing more comprehensive state transition cost information for subsequent test sequence adjustments.
[0042] In the above process, by determining the target distance between any two test cases from multiple test cases, the transformation complexity between test cases is quantified into the target distance, which facilitates algorithm understanding and processing, thus providing an accurate comparison benchmark for adjusting the test order. The mathematical method of distance calculation provides a data basis for adjusting the test order, avoiding the subjectivity and inaccuracy of manual sorting, and ensuring the objectivity and repeatability of the order adjustment process.
[0043] S130: Determine the target test order for multiple test cases based on the target distance between any two test cases.
[0044] The aforementioned target test order can refer to a determined sequence of test case executions that minimizes the total target distance between test cases. Adjusting the test case order can reduce unnecessary reset and transition time, making the entire testing process more efficient, effectively reducing the time spent on invalid waiting and state adjustments during testing, thereby accelerating the testing process and improving overall testing efficiency.
[0045] In one alternative embodiment, a distance matrix can be constructed based on the target distance between test cases, where each element represents the target distance from one test case to another. Next, an objective function can be defined to minimize the total distance between the test case sets, measuring the execution efficiency of the entire test sequence. Then, improved algorithms, such as genetic algorithms, simulated annealing, and deep neural networks, can be used to search and iterate through the sequence to find the order of test cases that minimizes the objective function. These improved algorithms can explore the sequence space and find paths with lower transformation costs.
[0046] As the algorithm iterates, the order of test cases can be continuously updated. After each update, actual tests can be performed to measure the actual conversion time, and this actual conversion time can be used as a reward or penalty factor to further adjust and improve the process until the determined test order tends to stabilize, thus obtaining the target test order.
[0047] In the above process, minimizing the target distance reduces the time spent on transitions and resets between test cases, significantly improving testing efficiency. The adjusted test sequence ensures a smoother testing process, reduces potential errors caused by frequent resets, and enhances the accuracy and reliability of the tests.
[0048] S140: Test based on the target test order and multiple test cases.
[0049] In one optional embodiment, the test environment, including vehicle status, test equipment, and software environment, can be initialized based on the first test case in the target test sequence to ensure that the initial conditions of the test case are met. Then, test cases can be executed one by one according to the target test sequence. After executing each test case, the initial conditions for the next test case can be transitioned based on the expected result, minimizing the reset and transition time between test cases. During the execution of test cases, vehicle status and test results can be monitored in real time, and data, including actual test time, changes in vehicle status, and execution results of test cases, can be recorded to provide feedback for subsequent model iterations. Any abnormal situations that occur during the testing process, such as malfunctions or failure to achieve expected results, can be handled promptly, and this information can be fed back to the improvement model for adjusting the test sequence and strategy.
[0050] In the above process, by conducting tests based on the target test order and multiple test cases, the adjusted test order reduces the reset and transition time between test cases, significantly improving the efficiency of the testing process and shortening the overall testing cycle. Testing according to the target test order avoids resource waste, and for test cases that require specific conditions to execute, it ensures that resources are used at the necessary times.
[0051] In this embodiment of the invention, a method for processing test cases is provided, comprising: acquiring multiple test cases; determining a target distance between any two test cases among the multiple test cases, wherein the target distance is used to characterize the time required to switch between any two test cases; determining a target test order for the multiple test cases based on the target distance between any two test cases; and performing tests based on the target test order and the multiple test cases. This application systematically acquires multiple test cases, providing rich data support for subsequent distance calculation and sorting adjustments. By determining the target distance between any two test cases among the multiple test cases, the conversion time between test cases is quantified into the target distance, facilitating algorithm understanding and processing, thereby providing an accurate comparison benchmark for adjusting the test order. Distance calculation provides a data processing basis for adjusting the test order. By minimizing the target distance, the time spent on conversion and reset operations between test cases can be reduced. The adjusted test order ensures a smoother testing process, reduces potential errors caused by complex conversion and reset operations, and improves the accuracy and reliability of the tests. By conducting tests based on the target test sequence and multiple test cases, the adjusted test sequence reduces the reset and transition time between test cases, significantly improving the efficiency of the test process and shortening the overall test cycle. This solves the technical problems of high execution time and poor continuity of test cases in related technologies.
[0052] In this embodiment of the application, determining the target distance between any two test cases among multiple test cases includes: obtaining an initial condition set and an expected result set, wherein the initial condition set includes: the initial conditions required to start executing each test case, and the expected result set includes: the expected results achieved by ending the execution of each test case; and determining the target distance between any two test cases based on the initial condition set and the expected result set.
[0053] The aforementioned set of initial conditions refers to a series of states that the vehicle system or test environment needs to be in before executing each test case. These initial conditions can be configuration parameters of the hardware and software systems, sensor states, actuator positions, communication protocol states, etc., and can be specifically determined according to the nature and purpose of the test cases. For testing intelligent connected vehicles, initial conditions may include, but are not limited to, vehicle speed, engine speed, door open / closed status, in-vehicle temperature setting, target location setting of the navigation system, and weather conditions of the external environment simulator.
[0054] The aforementioned set of expected results refers to the set of states or behaviors that the vehicle system or test environment should achieve after each test case is executed. These expected results can be the state of sensor data, the state of actuators, the activation or deactivation of vehicle system functions, etc.
[0055] In one optional embodiment, for each test case, a series of initial conditions that need to be met before execution can be determined. These conditions may include, but are not limited to, vehicle states such as engine on, neutral gear, dashboard display, and driver assistance system activation, as well as environmental conditions such as temperature and light intensity. These conditions constitute the initial condition set. A series of expected results that should be achieved after execution can be defined for each test case. This may include the vehicle's expected safety status, the expected behavior of the function, and the detection of error codes. These results constitute the expected result set. Based on the initial condition set and the expected result set, the target distance between any two test cases can be calculated. The distance metric can be Euclidean distance, Manhattan distance, etc. The determined target distance can represent the transition and reset time required to change from the expected result of one test case to the initial conditions of another test case.
[0056] In the above process, by determining the initial set of conditions and the expected set of results, the transition time between any two test cases can be accurately quantified. By calculating and minimizing the target distance, the transition time between test cases can be minimized while maintaining test coverage, thereby significantly improving test efficiency.
[0057] In this embodiment of the application, determining the target distance between any two test cases based on the initial condition set and the expected result set includes: determining the target expected result corresponding to the first test case from the expected result set, and determining the target initial condition corresponding to the second test case from the initial condition set; determining the target distance between the first test case and the second test case based on the target expected result and the target initial condition, wherein the target distance is used to characterize the time required to switch from the first test case to the second test case.
[0058] The aforementioned expected results can refer to a set of predetermined states or behaviors that the vehicle system or test environment should achieve after the first test case is completed. For example, when testing a test case involving the vehicle's automatic parking function, the results that should be achieved after successful execution may include the vehicle accurately parking in the designated parking space, the reversing radar turning off normally, and the turn signals resetting.
[0059] The aforementioned initial conditions can refer to a set of state conditions that the vehicle system or test environment needs to be in before the execution of the second test case. For example, when testing the adaptive cruise control function of a vehicle on a highway, the initial conditions may include the vehicle's engine starting, the transmission being in a forward gear, the vehicle speed being stable at a certain value, and the adaptive cruise control system being in standby mode.
[0060] In an optional embodiment, any two test cases can be selected. The target expected result of the first test case and the target initial conditions of the second test case can be determined, facilitating the evaluation of the adjustments required to transition from the expected state of the first test case to the initial conditions of the second test case. Next, based on the target expected result and the target initial conditions, the target distance between the first and second test cases can be determined. This target distance can be quantified using a mathematical formula, such as the Euclidean distance formula, and can reflect the complexity and time required for the state transition. For each test case, a distance matrix can be constructed, where each element represents the target distance from one test case to another. The distance matrix can serve as the data foundation for subsequent test order improvement algorithms.
[0061] In the above process, the state transition costs between test cases are converted into specific numerical values, which facilitates subsequent algorithm understanding and operation, and helps to accurately evaluate the efficiency of the test order. The distance matrix provides a basis for adjusting the test order, enabling the algorithm to determine a better test order by searching for paths with smaller target distances, reducing reset and transition time, and thus significantly improving test efficiency.
[0062] In this embodiment of the application, determining the target test order of multiple test cases based on the target distance between any two test cases includes: constructing a total distance objective function based on the target distance between any two test cases, wherein the total distance objective function is used to represent the objective function established with the total distance between the target distances of any two test cases as the improvement objective; and solving the total distance objective function to obtain the target test order.
[0063] The aforementioned total distance objective function can refer to an objective function used to comprehensively evaluate the overall conversion time of each test case in a specific order. The total distance objective function can be formed by summing the distances between test cases to form a global improvement target.
[0064] In one alternative embodiment, an objective function representing the total distance between any two test cases can be constructed based on the distance matrix between test cases. The objective function can be defined in relation to a test sequence, which represents the execution order of a series of test cases. A series of constraints can also be set to ensure that each test case is executed exactly in the sequence. Next, an improved algorithm, such as a genetic algorithm, simulated annealing, or deep neural network, can be used to solve the objective function. Iterative algorithms can iterate and try different test case orders to find the test order that minimizes the objective function. After the improved algorithm's solution process is complete, the obtained test order can be verified to ensure that all constraints are met. This may include comparing multiple solutions and selecting the test order that minimizes the total distance objective function as the target test order.
[0065] In the above process, adjusting the test order is transformed into solving a problem of objective function. This gives the problem-solving a clear objective and method, enabling the identification of a test order that minimizes conversion costs, thereby improving the testing process. The adjusted test order can reduce the reset and conversion time between test cases, significantly improving the overall testing efficiency and shortening the testing cycle. The effect is even more pronounced when dealing with a large number of test cases.
[0066] In this embodiment of the application, determining the test order of multiple test cases based on the target distance between any two test cases includes: using a preset clustering algorithm to cluster multiple test cases to obtain multiple test case sets; and determining the target test order based on the target distance between any two test cases in the multiple test case sets.
[0067] The aforementioned pre-defined clustering algorithm refers to a predetermined algorithm used for analyzing and organizing data. It can decompose large, complex datasets into several smaller subsets with similar characteristics. In test case tuning, the pre-defined clustering algorithm can construct feature vectors based on the initial conditions and expected results of the test cases. Then, through iterative calculation, it finds multiple cluster center locations that minimize the sum of squared average distances between data points within a cluster and the cluster center. Finally, it assigns test cases to corresponding clusters based on the proximity of data points to the cluster centers. When processing a large number of test cases, the pre-defined clustering algorithm can organize test cases into multiple subsets, i.e., test case sets. Test cases within each test case set have high similarity, such as sharing some initial conditions or having similar expected results. Such clustering helps to more efficiently process and adjust the execution order of test cases in subsequent steps. Resetting and transforming similar test cases is often simpler and faster than resetting test cases with large differences.
[0068] The aforementioned multiple test case sets can refer to subsets obtained by grouping test cases using a pre-defined clustering algorithm. Each test case set may contain a group of test cases with similar characteristics, which tend to require similar state reset or preparation processes. Creating multiple test case sets helps reduce the transition time between test cases. Due to the high similarity of test cases within a test case set, switching from one test case to another does not require significant changes to the state of the vehicle system or test environment, thus shortening reset and preparation time. This also helps simplify the problem scope, making it easier to adjust the test order of each independent test case set, thereby reducing the overall complexity of the improvement problem.
[0069] In one optional embodiment, overall testing efficiency can be improved by grouping test cases according to similarity and then adjusting their order within each group. Specifically, a preset clustering algorithm can be determined first, and each test case can be clustered based on its feature vector, including initial conditions and expected results. This grouping test cases with similar conversion costs into the same group reduces the conversion cost between different groups. After clustering, multiple test case sets can be formed, each containing a set of highly similar test cases. The number and composition of the test case sets can be determined based on the parameter settings of the clustering algorithm. For each test case set, the target distance between any two test cases within the group can be calculated. Then, an improved algorithm, such as a deep neural network, can be used to adjust the order of test cases within each test subset to minimize the total target distance between test cases within each test case set. The test order within each test case set can be adjusted to reduce conversion time. The distance between different test subsets can be calculated by comparing the cluster centers of each test case set, and then the test case sets are sorted according to these distances to ensure that the conversion cost between subsets is also minimized. Next, the test order within the test case set can be combined with the sorting among the test case sets to generate the overall target test order.
[0070] In the above process, clustering algorithms are used to determine the test order. These algorithms group test cases with similar conversion costs, reducing the conversion time between test cases within the test case set. Furthermore, by adjusting the order within and between test case sets, the overall number of reset and conversion operations between test cases is reduced. This approach breaks down complex technical problems into multiple simpler sub-problems, and by improving the test case set to determine the overall optimal solution, the complexity of the problem is reduced, making the improvement process more efficient.
[0071] In this embodiment of the application, determining the target test order based on the target distance between any two test cases in multiple test case sets includes: determining the test order within a subset of at least one test case in any test case set based on the target distance between any two test cases in any test case set; and merging the test orders within the subset of at least one test case in multiple test case sets to obtain the target test order.
[0072] The aforementioned test order within a subset refers to the execution order of test cases within a set of test cases formed using a pre-defined clustering algorithm, in order to minimize the time required for state transitions between test cases. The determination of the test order within a subset can be based on calculating the target distance between each pair of test cases, i.e., the time required to transition from executing one test case to another.
[0073] In one optional embodiment, for each set of test cases, a target distance between any two test cases within that set can be calculated. Then, based on the calculated target distances within the test case sets, an improved algorithm can be used to determine a better order of test cases within each set. The improvement objective can be to minimize the total distance between test cases within each set, thereby reducing unnecessary reset operations and waiting time. Next, the adjusted test orders from each set can be merged to form an overall target test order. This process can consider the conversion costs between test case sets, ensuring a smooth and low-cost transition from one set to another. After merging the test case set orders, the overall order can be verified and fine-tuned again to ensure that overall testing efficiency is maximized.
[0074] In the above process, adjusting the test order within the test case set can more precisely reduce reset time and state adjustments, maximizing local efficiency. The adjusted test case set order takes into account the conversion costs between test case sets during merging, ensuring a smooth overall testing process and improving global efficiency.
[0075] In this embodiment of the application, determining the test order within a subset of any test case in any set of test cases based on the target distance between any two test cases in any set of test cases includes: constructing a target function for distance within a subset based on the target distance between any two test cases in any set of test cases, wherein the target function for distance within a subset is used to represent a target function established with the total distance between the target distances between any two test cases in any set of test cases as the improvement objective; and solving the target function for distance within a subset to determine the test order within the subset.
[0076] The aforementioned target function for distance within a subset can refer to a target function designed for test cases within each set of test cases, constructed based on the sum of target distances between test cases within the set of test cases. Alternatively, it can be a quantitative target function formed by accumulating the target distances between any two test cases in the set of test cases.
[0077] In one alternative embodiment, within the test case set, a target distance between any two test cases can be calculated. Then, a subset distance objective function can be constructed based on the target distances between the test cases within the test case set. This subset distance objective function aims to minimize the total distance between the test cases within the subset. Next, an improved algorithm can be used to solve the subset distance objective function, finding a test case execution order that minimizes the subset distance objective function. This process may involve iteration and trying multiple strategies to ensure a globally optimal solution is found. The resulting test order within the test case set can be verified to ensure that all constraints are met, and the determined test order can be adjusted appropriately based on the verification results.
[0078] In the above process, the construction and solution of the objective function within the test case set allows for significant improvements at the local level of the test cases, reducing conversion time and improving testing efficiency. The order within the test case set can serve as the basis for constructing a better overall test order. By improving the local aspects first and then integrating the global aspects, more accurate test process management can be achieved, improving overall testing efficiency.
[0079] In this embodiment of the application, solving the distance objective function within a subset and determining the test order within the subset includes: using a pre-trained neural network model to solve the distance objective function within the subset and obtain the test order within the subset.
[0080] The aforementioned pre-trained neural network model refers to a neural network model that has been pre-trained and possesses a certain generalization ability. The specific pre-trained neural network model can be determined according to actual needs. It can be trained on a large-scale dataset and can learn general feature representations of the data. These feature representations can be transferred to other related but different tasks, providing a strong starting point for processing new tasks.
[0081] In one optional embodiment, the subset distance objective function can be used as input to the pre-trained neural network model to ensure that the model can comprehensively understand the transformation requirements between test cases. Before application, the pre-trained neural network model can be fine-tuned according to specific test cases to better adapt to real-world scenarios. This process can be completed in the early development stages of the model or through minimal training before each application to improve performance. A loss function for the pre-trained neural network model can be defined, and its objective can be to output a subset-based test order that minimizes the subset distance objective function given input conditions. The pre-trained neural network model can be used to adjust the execution order of test cases within the test case set. Iteratively generating and evaluating different orders, the model outputs a subset-based test order that minimizes the subset distance objective function. The determined subset-based test order can be applied to actual testing to verify its effectiveness.
[0082] In the above process, pre-trained neural network models can quickly process large amounts of data and find the optimal test order within the test case set more quickly, making them suitable for scenarios with large-scale test cases. Pre-trained neural network models possess good generalization ability, understanding the relationships between different test cases and effectively predicting the optimal execution order when faced with new test cases. Through multiple training iterations, pre-trained neural network models can gradually learn optimal strategies and continuously improve themselves based on data collected from actual testing, thereby enhancing computational accuracy.
[0083] In this embodiment of the application, the test order within a subset of at least one test case in multiple test example sets is merged to obtain a target test order, including: obtaining the test order between subsets of multiple test example sets; and merging the test order within a subset of at least one test case in multiple test example sets based on the test order between subsets to obtain a target test order.
[0084] The aforementioned inter-subset test order refers to the execution order of test case sets after dividing the test cases into multiple test case sets. Within each test case set, the optimal execution order of test cases has already been determined through the intra-subset test order. The inter-subset test order can optimally arrange the execution order of these test case sets, further reducing state reset and transition time in the entire test process.
[0085] In one alternative embodiment, the distance between various test case sets can be calculated, which can be approximated based on the cluster centers of the test case sets to reflect the time required for a test state transition from one test case set to the start of testing in another test case set. Next, a distance objective function between subsets can be constructed. Minimizing this objective function can be the goal of improving the order between test case sets to determine a better execution order among multiple test case sets. Then, the improved test order within each test case set can be combined with the better execution order between test case sets to form a global test case execution order. This step ensures that the transition between test case sets follows the improved order, thereby generating a test case execution sequence that considers transition costs from a global perspective—the target test order. The target test order can minimize reset and state transition time between test cases while ensuring test comprehensiveness.
[0086] In the above process, based on improvements within the test case set, the execution order between test case sets was further improved, ensuring maximum testing efficiency from a global perspective. The orderly transition between test case sets enhances the coherence and logic of the testing process, making the entire testing process smoother and reducing interruptions and delays caused by improper test order. By first adjusting the order within the test case set and then addressing the order between test case sets, the complex problem is decomposed, reducing the computational complexity and difficulty of the improved algorithm and improving the efficiency and feasibility of the test order improvement.
[0087] In this embodiment of the application, obtaining the test order among subsets of multiple test example sets includes: determining the inter-subset cluster center and multiple intra-subset cluster centers of any test example set; determining the subset distance between any two test example sets based on the inter-subset cluster center and multiple intra-subset cluster centers, wherein the subset distance is used to characterize the time required to switch between any two test example sets; and determining the test order among subsets based on the subset distance.
[0088] The cluster center of the aforementioned subsets can refer to the feature vector representing the center point of the test case set after clustering the test cases.
[0089] The cluster centers within the aforementioned subsets can refer to the feature vectors that represent the center points of a certain set of test cases, calculated based on the initial conditions and expected results of the test cases.
[0090] The subset distance mentioned above can be a parameter used to quantify the time required for state transitions between two test case sets, and can be calculated based on the distance between the cluster centers of any two test case sets. The subset distance can represent the time required for the state of the last test case in one test case set to transition to the state of the first test case in another test case set.
[0091] In one optional embodiment, for each set of test cases, a cluster center between subsets and multiple cluster centers within subsets can be determined. Next, the distance between the cluster centers of any two test case sets can be calculated to obtain the subset distance. The subset distance reflects the time required to transition from the state of one test case set to the state of another. The specific calculation method can be Euclidean distance or other distance metrics, taking into account the actual transition cost between test cases. Then, based on the subset distance, a corresponding objective function can be constructed, aiming to minimize the total distance of switching between test case sets. Solving this objective function using an improved algorithm can determine a better test order between subsets of the test case sets.
[0092] In the above process, the calculation of distances between test case sets provides an accurate assessment of conversion costs, helping to more accurately predict and control time consumption in the testing process and reduce unnecessary waiting and reset time. By determining the cluster centers and calculating the distances between test case sets, the originally complex distance calculation between multiple test cases is simplified, reducing the computational complexity of the algorithm and improving the efficiency of the tuning process.
[0093] The technical solution proposed in this application is described below with reference to an optional embodiment. This application proposes a method for improving the test case testing order based on K-means clustering and reinforcement learning. This application relates to the field of whole vehicle system testing, and particularly to the field of test efficiency improvement. The proposed method for improving the test case testing order based on K-means clustering and reinforcement learning defines the distance between test cases according to the initial conditions and expected results of the test cases. Then, it classifies the test cases using K-means clustering, and then uses a deep neural network to improve the test order sorting and iterates. The method includes the following steps: using the initial condition set and expected result set of test cases as feature groups for the test cases, and defining the distance between test cases i and j; classifying the total set of test cases using K-means clustering, determining the best clusters based on the clustering results, and sorting the test case sets according to the smaller total distance between them; using minimizing the total distance between test case sets as the objective function, training each test case set using a deep neural network model to improve the testing order of each set; inputting the actual testing time as the reward function into the neural network model for repeated training, repeating the above steps until the model converges, and outputting the final test case order scheme. This application can improve the testing order of test cases, reduce the time consumed between test cases, and improve testing efficiency.
[0094] This application is based on the initial conditions of the test cases (A) i1 A i2 A iM ) and expected outcome (B) i1 B i2 B iM Define the distance sij between use cases i and j as ∑(A im –B jm ) 2 Using minimizing the total distance between test case sets as the objective function, a deep neural network model is trained to improve the test case testing order. Simultaneously, to avoid the impact of low correlation between test cases on the stability of the neural network model, K-means clustering is used to classify the test case sets, and a separate deep neural network is built for each class to improve the testing order. Finally, a test case testing order scheme is obtained, improving testing efficiency.
[0095] The technical solution of this application may include the following steps: setting the initial condition set (A) of the test cases. i1 A i2 A iM ) and expected outcome set (B i1 B i2 B iMAs a feature group of use cases, the distance sij between use cases i and j is defined as ∑(A im –B jm ) 2 This represents the time required to execute test case j after executing test case i; the above process can use the following control conditions or parameters: initial condition set (A i1 A i2 A iM ) and expected outcome set (B i1 B i2 B iM ), containing the values of the designed bus signals; inter-use case distance sij=∑(A im –B jm ) 2 , represents the time required to execute test case j after test case i has been executed, and has a significant impact on the testing efficiency between test cases.
[0096] Based on the feature groups of the above test cases, K-means clustering is used to classify the total set of test cases. The best clusters are determined based on the clustering results. The distance between the cluster centers is used as the distance between the test case sets. The test case sets are then sorted according to the smaller total distance between the test case sets. The above process can use the following control conditions or parameters: the number of clusters K, which represents the number of categories in the clustering result and has a significant impact on the clustering result.
[0097] Following the order of the test case sets mentioned above, and with the objective function of minimizing the total distance between test case sets, deep neural network models are used to train each test case set to improve the testing order of each set, ultimately obtaining a testing order scheme for the total set of test cases. The above process can utilize the following control conditions or parameters: Reward function: r t =-r dis , where r dis= ∑∑s ij s ij The distance sij between use cases i and j is represented as ∑(A im –B jm ) 2 .
[0098] The test was conducted according to the above test sequence plan, and the actual test time T was [specified]. k The reward function is input into the neural network model for repeated training. This process is repeated until the model converges. The model result at this point is used as the final test order scheme for the total set of test cases. The above process can adopt the following control conditions or parameters: actual test time T k , representing the efficiency of the test case testing sequence, used to train patterns to improve testing efficiency; reward function: r t = 1rdis+ 2r T , where r T =∑T k / K; 1. 2 represents the weight of the reward function.
[0099] The working method of this application includes the following steps: initial condition set (A) for test cases. i1 A i2 A iM ) and expected outcome set (B i1 B i2 B iM ) as the feature group of the use case, namely (A i1 A i2 A iM B i1 B i2 B iM ); Define the distance sij between use cases i and j as ∑(A im –B jm ) 2 , used to represent the time required to execute test case j after executing test case i; based on the feature groups of the above test cases, K-means clustering is used to classify the total set of test cases, and the best cluster K is determined based on the clustering results; the distance between the cluster centers is used as the distance between the test case sets, and the test case sets are sorted according to the smaller total distance between the test case sets; according to the order of the test case sets mentioned above, with minimizing the total distance between the test case sets as the objective function, a deep neural network model is used to train the test case sets to improve the test order of the test case sets; the above is repeated until all test case sets are traversed, and the results of each model are merged; the test is carried out according to the above test order scheme, and the actual test time T is recorded. k The reward function is input into the neural network model for repeated training; the above steps are repeated until the model converges, and the model result at this point is used as the final test order scheme for the total set of test cases.
[0100] Figure 2 This is a schematic diagram illustrating the processing procedure of an optional test case according to an embodiment of this application, as shown below. Figure 2As shown, multiple test cases are obtained; the target distance between any two test cases in the multiple test cases is determined; the multiple test cases are clustered using a preset clustering algorithm to obtain multiple test case sets; based on the target distance between any two test cases in any test case set, a distance objective function within a subset is constructed; the distance objective function within the subset is solved using a pre-trained neural network model to obtain the test order within the subset; the test order between subsets of the multiple test case sets is obtained; based on the test order between subsets, the test order within the subset of at least one test case in the multiple test case sets is merged to obtain the target test order.
[0101] This application focuses on reducing the additional time spent on operations such as resetting and switching between test cases, and defines the distance between test cases as sij=∑(A im –B jm ) 2 This represents the time required to execute test case j after executing test case i. The objective function is to minimize the distance between test case sets. The test case testing order is improved to reduce the additional time spent on resetting and switching between test cases, thereby improving testing efficiency. The test case testing order improvement method proposed in this application can minimize the additional time spent on resetting and switching between test cases and continuously improve the testing order based on actual testing conditions, which is beneficial to improving testing efficiency.
[0102] This application also provides a test case processing device 30, please refer to... Figure 3 The device includes: an acquisition module 310 for acquiring multiple test cases; a first determination module 320 for determining a target distance between any two test cases among the multiple test cases, wherein the target distance is used to characterize the time required to switch between any two test cases; a second determination module 330 for determining a target test order of the multiple test cases based on the target distance between any two test cases; and a test module 340 for performing tests based on the target test order and the multiple test cases.
[0103] The first determining module is further used to obtain an initial condition set and an expected result set. The initial condition set includes the initial conditions required to start executing each test case, and the expected result set includes the expected results to be achieved when ending the execution of each test case. Based on the initial condition set and the expected result set, the target distance between any two test cases is determined.
[0104] The first determining module is further configured to determine the target expected result corresponding to the first test case among any two test cases from the expected result set, and to determine the target initial condition corresponding to the second test case among any two test cases from the initial condition set; and to determine the target distance between the first test case and the second test case based on the target expected result and the target initial condition, wherein the target distance is used to characterize the time required to switch from the first test case to the second test case.
[0105] The second determining module is further used to construct a total distance objective function based on the target distance between any two test cases. The total distance objective function is used to represent the objective function established with the total distance between the target distances of any two test cases as the improvement objective. The target test order is obtained by solving the total distance objective function.
[0106] The second determining module is further used to cluster multiple test cases using a preset clustering algorithm to obtain multiple test case sets; and to determine the target test order based on the target distance between any two test cases in the multiple test case sets.
[0107] The second determining module is further configured to determine the test order within a subset of at least one test case in any set of test cases based on the target distance between any two test cases in any set of test cases; and to merge the test orders within the subsets of at least one test case in multiple sets of test cases to obtain the target test order.
[0108] The second determining module is further configured to construct a distance objective function within a subset based on the target distance between any two test cases in any set of test cases. The distance objective function within the subset represents the objective function established with the total target distance between any two test cases in any set of test cases as the improvement objective. The distance objective function within the subset is solved to determine the test order within the subset.
[0109] The second determining module is also used to solve the distance objective function within the subset using a pre-trained neural network model to obtain the test order within the subset.
[0110] The second determining module is further used to obtain the test order among subsets of multiple test example sets; based on the test order among subsets, the test order within the subset of at least one test case in the multiple test example sets is merged to obtain the target test order.
[0111] The second determining module is further configured to determine the cluster centers between subsets and within subsets of any test example set; determine the subset distance between any two test example sets based on the cluster centers between subsets and within subsets, wherein the subset distance is used to characterize the time required to switch between any two test example sets; and determine the test order between subsets based on the subset distance.
[0112] This application also provides an electronic device 40, please refer to... Figure 4 It includes a processor 410 and a memory 420, wherein the memory 420 is used to store computer programs; the processor 410 is used to execute the programs stored in the memory 420 to implement the test case processing method described in any embodiment of this application.
[0113] The aforementioned memory can refer to devices inside a computer used to store data and programs, including RAM, hard disks, etc. RAM can be used to temporarily store running programs and data, while hard disks can be used to store programs and data long-term. Memory enables the computer to read and write data and execute programs. The aforementioned processor is responsible for executing instructions in computer programs and performing data processing. It can also be responsible for controlling and executing various operations, including arithmetic operations, logical operations, and data transmission.
[0114] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the test case processing method described in any embodiment of this application.
[0115] The aforementioned computer storage media can refer to the media used in computer memory to store certain discontinuous physical quantities. Computer storage media mainly include semiconductors, magnetic cores, magnetic drums, magnetic tapes, laser discs, etc. Computer-readable storage media include stored programs, which can be a set of instructions that a computer can recognize and execute, running on an electronic computer to meet certain information needs.
[0116] In this application, "multiple" refers to two or more.
[0117] In this application, unless otherwise expressly defined, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection between two components. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances.
[0118] The terms “first,” “second,” “third,” “fourth,” etc., in this application (if present) are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0119] In this application, the term "and / or" 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, or B existing alone. Additionally, in this application, the character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0120] Unless otherwise specified, all steps in this application may be performed sequentially or randomly. For example, if a method includes steps A and B, it means that the method may include steps A and B performed sequentially, or it may include steps B and A performed sequentially. For example, if a method may also include step C, it means that step C may be added to the method in any order. For example, the method may include steps A, B, and C, or it may include steps A, C, and B, or it may include steps C, A, and B, etc.
[0121] The above are merely preferred embodiments of this application and are not intended to limit this application. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for processing test cases, characterized in that, include: Obtain multiple test cases; Determine the target distance between any two test cases among the plurality of test cases, wherein the target distance is used to characterize the time required to switch between any two test cases; Determine the target test order of the plurality of test cases based on the target distance between any two test cases; Tests are performed based on the target test order and the multiple test cases.
2. The method according to claim 1, characterized in that, Determining the target distance between any two test cases among the plurality of test cases includes: Obtain an initial condition set and an expected result set, wherein the initial condition set includes: the initial conditions required to start executing each test case, and the expected result set includes: the expected results to be achieved when ending the execution of each test case; Based on the initial condition set and the expected result set, the target distance between any two test cases is determined.
3. The method according to claim 2, characterized in that, Based on the initial condition set and the expected result set, determine the target distance between any two test cases, including: From the set of expected results, determine the target expected result corresponding to the first test case among any two test cases, and from the set of initial conditions, determine the target initial conditions corresponding to the second test case among any two test cases; Based on the target expected result and the target initial conditions, the target distance between the first test case and the second test case is determined, wherein the target distance is used to characterize the time required to switch from the first test case to the second test case.
4. The method according to claim 1, characterized in that, Based on the target distance between any two test cases, determine the target test order of the plurality of test cases, including: Based on the target distance between any two test cases, a total distance objective function is constructed, wherein the total distance objective function is used to represent the objective function established with the total distance between the target distances of any two test cases as the improvement objective; The target test order is obtained by solving the total distance objective function.
5. The method according to claim 1, characterized in that, Based on the target distance between any two test cases, determine the test order of the plurality of test cases, including: Using a preset clustering algorithm, the multiple test cases are clustered to obtain multiple test case sets; The target test order is determined based on the target distance between any two test cases in the plurality of test case sets.
6. The method according to claim 5, characterized in that, The target test order is determined based on the target distance between any two test cases in the plurality of test case sets, including: Based on the target distance between any two test cases in any set of test cases, determine the test order within a subset of at least one test case in any set of test cases; The test order within at least one subset of test cases from the multiple sets of test examples is merged to obtain the target test order.
7. The method according to claim 6, characterized in that, Based on the target distance between any two test cases in any set of test cases, determine the test order within a subset of any test case in any set of test cases, including: Based on the target distance between any two test cases in any set of test cases, a target distance function within a subset is constructed, wherein the target distance function within the subset is used to represent the target function established with the total distance between any two test cases in any set of test cases as the improvement objective; Solve the distance objective function within the subset to determine the testing order within the subset.
8. The method according to claim 7, characterized in that, Solving the distance objective function within the subset and determining the testing order within the subset includes: Using a pre-trained neural network model, the distance objective function within the subset is solved to obtain the test order within the subset.
9. The method according to claim 6, characterized in that, The test order within at least one subset of test cases from the plurality of test case sets is merged to obtain the target test order, including: Obtain the test order among subsets of the multiple test example sets; Based on the test order among the subsets, the test order within at least one subset of test cases in the multiple test case sets is merged to obtain the target test order.
10. The method according to claim 9, characterized in that, Obtaining the test order among subsets of the multiple test example sets includes: Determine the cluster centers between subsets and within subsets of any given set of test cases; Based on the cluster centers between the subsets and the cluster centers within the subsets, the subset distance between any two test example sets is determined, wherein the subset distance is used to characterize the time required to switch between any two test example sets; The testing order among the subsets is determined based on the distance between the subsets.
11. An electronic device, characterized in that, Including processor and memory, among which, Memory, used to store computer programs; A processor for executing a program stored in memory to implement the method described in any one of claims 1-10.