Automatic test script generation method and system and program product
By automatically generating test scripts using the singleton pattern and thread pool technology, the problem of low efficiency and limited scenarios in automotive intelligent cockpit HMI testing is solved, achieving efficient and comprehensive automated testing.
Patent Information
- Application Number
- CN202511491998.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-17
- Publication Date
- 2026-02-10
AI Technical Summary
In existing technologies, automotive intelligent cockpit HMI testing relies on manual or ADB testing, which has problems such as scattered test cases, manual reset of instrument status, low efficiency of complex logic processing, and limited stress test scenarios.
It uses a singleton pattern to load source files, uses a thread pool to parse data and generate automated commands, automatically generates test environment initialization, test result checking and functional test commands, processes illegal characters with regular expressions, and dynamically combines to generate various stress test scenarios.
It improved testing efficiency, reduced testing manpower and material resources by 90%, enhanced the coverage of stress testing scenarios, eliminated human error, and simplified the operation process.
Smart Images

Figure CN121501649A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of automated testing technology, and in particular to a method, system and program product for automatically generating test scripts. Background Technology
[0002] In recent years, with the booming development of the automotive electronics industry, intelligent cockpits have emerged. As the core of the intelligent cockpit, the cockpit domain controller coordinates and manages HMI devices such as the central control screen, LCD instrument panel, and head-up display, making its related functional logic extremely complex. Testing the cockpit domain controller can significantly optimize product development cycles while ensuring product quality.
[0003] Currently, testing of automotive smart cockpit HMIs mainly relies on manual testing or ADB (Android Debug Bridge) testing, with relatively little work done on Windows and QNX systems. Furthermore, existing testing methods for Windows and QNX systems have the following problems:
[0004] Traditional automated testing of instrument functions relies on manually written test scripts, and the large number of test cases consumes a huge amount of time.
[0005] The test cases were scattered across multiple Excel spreadsheets, lacking a unified management mechanism.
[0006] The instrument status needs to be manually reset before and after testing, which leads to contamination of the testing environment.
[0007] Complex logic processing is inefficient and cannot automatically parse bitwise operations in Excel (such as 1U< <n)。
[0008] The stress test scenario is limited. Summary of the Invention
[0009] The purpose of this invention is to provide a test script automated generation method, test script automated generation system and program product, which can automatically generate commands and scripts required for instrument function testing based on raw data, and greatly improve generation efficiency.
[0010] This invention provides the following solution:
[0011] According to one aspect of the present invention, a method for automatically generating test scripts is provided, the method comprising:
[0012] By using a singleton-pattern source file loading class, source files are loaded one by one.
[0013] The thread pool utilizes multiple source file parsing threads to extract MCU signal data, test case data, alarm pop-up data, alarm light data, and power data from the source files.
[0014] Based on the parsed data, the automated command generation function automatically generates test environment initialization commands, test result checking commands, and functional test commands.
[0015] After classifying or combining the automatically generated commands, the commands are transmitted to the serial port for testing.
[0016] Optionally, multiple source file parsing threads within the thread pool are used to parse MCU signal data, test case data, alarm pop-up data, alarm light data, and power data from the source files, including:
[0017] Create a thread pool;
[0018] The ThreadPoolExecutor object is used to concurrently execute multiple data extraction tasks. Select the number of rows and columns of the target data to extract the required MCU signal data, test case data, alarm light data, alarm pop-up data, and power data.
[0019] The extracted data is stored in memory as a linked list.
[0020] Optionally, based on the parsed data, the automated command generation function can automatically generate test environment initialization commands, test result checking commands, and functional test commands, including:
[0021] Process illegal characters and construct bitwise operation calculation functions to calculate power data values from raw data;
[0022] Based on requirements, multiple command generation modules are constructed to form a command generation engine, which uses raw data and processed power data to generate different types of test commands.
[0023] Optional, different types of test commands include: test environment initialization commands, test result checking commands, and functional test commands;
[0024] The functional test commands include: functional status initialization command, single function raw information viewing command, test expected result viewing command, instrument functional test run command, and instrument functional test result saving command.
[0025] Optionally, illegal characters are processed and bitwise operation functions are constructed to calculate power data values from the raw data, including:
[0026] Create the regular expression used for matching;
[0027] Extract power mode data corresponding to a single regular expression;
[0028] Extract power mode data corresponding to combinations of multiple regular expressions.
[0029] Optionally, the automatically generated commands can be categorized or combined, and then transmitted to the serial port to run tests, including:
[0030] Commands are classified based on keywords or feature values in the generated commands.
[0031] Optionally, after categorizing or combining the automatically generated commands, the commands can be transmitted to the serial port to run tests. This also includes:
[0032] Using a dynamic combination algorithm, when the system has n valid icons, C can be generated. 5 n× 4 5 Various stress testing scenarios.
[0033] Optionally, after categorizing or combining the automatically generated commands, the commands can be transmitted to the serial port to run tests. This also includes:
[0034] Set the global default values for the test environment;
[0035] Initialize the test case environment.
[0036] According to two aspects of the present invention, a test script automated generation system is provided, the test script automated generation system comprising:
[0037] The loading unit is configured to load source files one by one using a source file loading class that employs the singleton pattern;
[0038] The data parsing unit is configured to use multiple source file parsing threads in the thread pool to parse MCU signal data, test case data, alarm pop-up data, alarm light data, and power data from the source files;
[0039] The command generation unit is configured to automatically generate test environment initialization commands, test result checking commands, and functional test commands based on the parsed data using the automated command generation function.
[0040] The test unit is configured to categorize or combine various automatically generated commands, transmit the commands to the serial port, and run the test.
[0041] According to three aspects of the present invention, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the test script automated generation method described above.
[0042] The above solution achieves the following beneficial technical effects:
[0043] Efficiency is improved; traditionally, manually written automated test commands take several weeks, while this method generates standardized test commands using standardized raw data in just about ten minutes.
[0044] Quality improvements, elimination of human error, and increased coverage of stress testing scenarios;
[0045] Resource savings, reducing testing manpower and material resources by 90%;
[0046] Simplified operation, one-click generation of function / stress test scripts, and automatic generation of verification points. Attached Figure Description
[0047] Figure 1 This is a flowchart of a test script automated generation method provided by one or more embodiments of the present invention;
[0048] Figure 2 This is a flowchart of the data parsing operation in the test script automated generation method provided by one or more embodiments of the present invention;
[0049] Figure 3 This is a flowchart of the command generation operation in the test script automated generation method provided by one or more embodiments of the present invention;
[0050] Figure 4 This is a flowchart of the power data calculation sub-operation in the command generation operation provided by one or more embodiments of the present invention;
[0051] Figure 5 This is a flowchart of the test operation in the test script automated generation method provided by one or more embodiments of the present invention;
[0052] Figure 6 This is a flowchart of the test operation in the test script automated generation method provided by one or more embodiments of the present invention;
[0053] Figure 7 This is a flowchart of the test operation in the test script automated generation method provided by one or more embodiments of the present invention;
[0054] Figure 8 This is a flowchart of a test script automated generation method provided by one or more embodiments of the present invention;
[0055] Figure 9 This is a flowchart of a test script automated generation method provided by one or more embodiments of the present invention;
[0056] Figure 10This is a structural diagram of a test script automated generation device provided in one or more embodiments of the present invention. Detailed Implementation
[0057] The technical solution of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0058] Figure 1 This is a flowchart of a test script automated generation method provided by one or more embodiments of the present invention. See also... Figure 1 The method for automatically generating test scripts includes the following steps:
[0059] S11 loads source files one by one by using a singleton source file loading class.
[0060] S12 uses multiple source file parsing threads in the thread pool to parse MCU signal data, test case data, alarm pop-up data, alarm light data, and power data from the source files.
[0061] S13, based on the parsed data, automatically generates test environment initialization commands, test result checking commands, and functional test commands using the automated command generation function.
[0062] S14 categorizes or combines the automatically generated commands and then transmits them to the serial port to run the test.
[0063] In this embodiment, the source file refers to the data source file for the test. Typically, the source file is an Excel spreadsheet file. The Excel spreadsheet file stores a large amount of source data needed during the testing process. This source data includes: relevant data for the function under test and relevant data for the UI interface under test. Only after reading the aforementioned Excel spreadsheet file can the relevant automated tests run.
[0064] It should be understood that during the source file reading process, each source file can only be read and loaded once.
[0065] To avoid duplicate loading of the same source file during data reading, a dedicated source file loading class is created in this embodiment. The file loading process of this source file loading class employs the singleton pattern. By using the singleton pattern, it is ensured that the same source file will only be loaded once during the file loading process, and will not be loaded repeatedly.
[0066] After the source file loading operation is completed, it is necessary to parse the data needed for automated testing from the loaded source file.
[0067] To ensure the efficiency of the data parsing process described above, this embodiment employs a multi-threaded approach. Specifically, a dedicated thread pool is first created to manage the data parsing threads. This thread pool then manages the creation, execution, and lifecycle of different data parsing threads.
[0068] Data parsing threads created and started by the thread pool can be either general data parsing threads, known as unified data parsing threads, or they can be threads specifically designed for particular types of tasks. These latter types of threads are typically created and run for data parsing tasks involving specific data types. For example, it might be necessary to uniformly parse the lifecycle of various data collection tasks running within the cockpit controller, without considering other data unrelated to the data collection tasks or other aspects of the data collection tasks. In this case, a dedicated data parsing thread can be created specifically to perform this type of data parsing requirement and complete the task accordingly.
[0069] Regardless of the type of data parsing thread, it must complete the task of parsing the target data stored within the source file. That is, before the data parsing thread runs, the target data is stored in cells of specific rows and columns of the source file. After the data parsing thread runs, this target data should be stored in the system's memory. In some typical cases, after the data parsing thread runs, this target data is stored in the system's memory as a linked list. By simply calling the variable names corresponding to the target data, the specific values of these target data variables can be obtained.
[0070] After completing the above data parsing tasks, the various parsed data can be used to automatically generate test commands.
[0071] The generated automated test commands can include: test environment initialization commands, test result checking commands, and functional test commands.
[0072] The test environment initialization command mainly performs a series of operations to initialize the test environment. These initialization operations can include setting up the network environment, configuring important environment variables, etc.
[0073] The test result check command primarily compares the obtained test results with the predicted test results to see if the results meet our expectations. Of course, the test result check command also includes some test result data statistics and processing functions.
[0074] Functional test commands are very simple; they are purely functional test instructions.
[0075] After automating the generation of test commands, these commands can be recorded in the corresponding shell scripts. In some implementations, when these automated test commands need to be executed, the corresponding shell scripts can be read directly to retrieve them.
[0076] Once the test commands are generated, automated tests can be run based on these generated automated test commands.
[0077] It should be understood that running automated tests typically involves...
[0078] Figure 2 This is a flowchart of the data parsing operation in the automated test script generation method provided by one or more embodiments of the present invention. See also Figure 2 The system utilizes multiple source file parsing threads within a thread pool to extract MCU signal data, test case data, alarm pop-up data, alarm light data, and power data from the source files. The process includes the following steps:
[0079] S21, create a thread pool.
[0080] S22, the ThreadPoolExecutor object is used to concurrently execute multiple data extraction tasks. Select the number of rows and columns of the target, and extract the required MCU signal data, test case data, alarm light data, alarm pop-up data, and power data.
[0081] S23, save the extracted data into memory in the form of a linked list.
[0082] As described above, in this embodiment, the data parsing operation is performed by multiple threads. These threads are collectively referred to as data parsing threads in this embodiment.
[0083] Using multiple threads to complete data parsing tasks offers the advantage of concurrency. Before all data has been parsed, the overall workload of the data parsing task can be enormous. However, by distributing this enormous workload across multiple different threads, the workload of each thread is reduced, which is beneficial for improving job efficiency and the quality of the data parsing task.
[0084] In this embodiment, the lifecycle management of all data parsing threads is handled by a data structure called a thread pool. The thread pool manages the entire lifecycle of each data parsing thread from creation to termination.
[0085] In other words, the creation, operation, and eventual termination of each data parsing thread are all handled by this thread pool structure.
[0086] So, to actually perform the data parsing task, the first issue is to create a thread pool to manage the lifecycle of all data parsing threads. In some typical scenarios, the thread pool is created by its own constructor.
[0087] After the thread pool is created, a single object named ThreadPoolExecutor runs multiple different data extraction tasks. It should be understood that each data extraction task corresponds to a data parsing object, which is essentially a data parsing thread.
[0088] As described earlier in this application, data parsing threads can be of different types. That is, data parsing threads can belong to a large parent class, and then to different subclasses. Each class corresponds to a specific type of data extraction task, that is, a data parsing task.
[0089] Each subclass should have constructors and destructors that conform to its own characteristics in order to manage the lifecycle of objects belonging to that subclass.
[0090] Each subclass should also have execution code corresponding to its own data parsing logic, so that objects belonging to this subclass can complete the data parsing task.
[0091] In some typical scenarios, after the data parsing task is completed, the parsed target data is stored in a linked list structure. Once the target data is stored, the data parsing task is finished.
[0092] Figure 3 This is a flowchart of the command generation operation in the test script automated generation method provided by one or more embodiments of the present invention. See also Figure 3 Based on the parsed data, the automated command generation function automatically generates test environment initialization commands, test result checking commands, and functional test commands, including the following operation steps:
[0093] S31 processes illegal characters and constructs a bitwise operation calculation function to calculate the power data value from the original data.
[0094] S32, based on requirements, constructs multiple command generation modules to form a command generation engine, using raw data and processed power data to generate different types of test commands.
[0095] This application embodiment can perform various types of command generation operations. This embodiment takes the command generation process corresponding to the parsed power data as an example to illustrate the automatic test command generation process.
[0096] It should be understood that the raw data contains a large number of non-standard and illegal characters. During the calculation of power data values, these illegal characters need to be removed to ensure that the data entering subsequent calculation steps is structured and follows a predictable pattern.
[0097] After a series of standardization processes, including the removal of illegal characters, the original data has been processed into data conforming to certain format specifications. At this point, the power data value can be calculated based on the data's inherent formatting rules. In this embodiment, regular expression matching is used to calculate the power data value.
[0098] The process of regular expression matching includes matching single regular expressions and matching combinations of multiple regular expressions. Regardless of the form, regular expression matching can calculate the required power data values from the raw data.
[0099] After obtaining the power data value through calculation, the corresponding command can be generated using the calculated power data value.
[0100] Figure 4 This is a flowchart of the power data calculation sub-operation in the command generation operation provided in one or more embodiments of the present invention. See also Figure 4 The process involves handling illegal characters and constructing bitwise operation functions to calculate power data values from the raw data, including the following steps:
[0101] S41, Create the regular expression used for matching.
[0102] S42 extracts the power mode data corresponding to a single regular expression.
[0103] S43, extract the power mode data corresponding to the combination of multiple regular expressions.
[0104] As described in the foregoing embodiments of this application, the calculation of power data values in this application embodiment is accomplished by regular expression matching.
[0105] Because the power data value is calculated using regular expression matching, the creation of the regular expression must be performed first before the power data value calculation is executed.
[0106] The regular expressions created in this embodiment all have the following general form: \(1U << (\d+)\). Using the above general form, running regular expression matching can find the correct power data value and complete the calculation of power mode data.
[0107] The matching process of regular expressions includes matching single regular expressions and matching combinations of multiple regular expressions. In actual execution, matching of single regular expressions is performed first, followed by matching of combinations of multiple regular expressions.
[0108] After the two matching processes are completed, the correct power mode data can be obtained. This power mode data can then be used during the automatic command generation process.
[0109] Figure 5 This is a flowchart of the test operations in the test script automated generation method provided by one or more embodiments of the present invention. See also Figure 5 After classifying or combining the automatically generated commands, the commands are transmitted to the serial port to run the test, including the following steps:
[0110] S51, classify commands based on keywords or feature values in the generated commands.
[0111] Commands can be classified either based on their execution function or based on the object they execute. The specific classification depends on the keywords or characteristic values used in the classification process.
[0112] For example, if a keyword closely related to air conditioning data is used during the classification process, the classification is based on the category of the command execution object. As another example, if a keyword closely related to black-box testing is used during the classification process, the classification is based on the category of its execution function.
[0113] Categorizing automatically generated commands is important because it facilitates their use in subsequent processes. For example, if a command is categorized under "Air Conditioner Function Test," it is more likely to be used in subsequent air conditioner stress tests or other air conditioner-related tests.
[0114] Figure 6 This is a flowchart of the test operations in the test script automated generation method provided by one or more embodiments of the present invention. See also Figure 6 After classifying or combining the automatically generated commands, the commands are transmitted to the serial port to run the test, including the following steps:
[0115] S61, through a dynamic combination algorithm, when the system has n valid icons, C can be generated.5 n× 4 5 Various stress testing scenarios.
[0116] Combining different commands is primarily used in stress testing.
[0117] Stress testing, as the name suggests, involves subjecting the system under significant test pressure. Therefore, the number of test commands executed during stress testing is typically enormous.
[0118] Under normal circumstances, the amount of raw command data generated is limited. The simplest way to construct a massive test command set using the valid command set is to combine different commands from the valid command set, generating multiple different combination sets. Each combination set contains multiple test commands, and each combination set is distinct from the others. This ensures the capacity of the final stress test data and facilitates the execution of stress tests.
[0119] Figure 7 This is a flowchart of the test operations in the test script automated generation method provided by one or more embodiments of the present invention. See also Figure 7 After classifying or combining the automatically generated commands, the commands are transmitted to the serial port to run the test, including the following steps:
[0120] S71 sets the global default value for the test environment.
[0121] S72 initializes the test case environment.
[0122] The command execution process described above also includes management operations for the test environment. These operations can be divided into two main categories: the first is setting the global default values for the test environment, and the second is initializing the test case environment.
[0123] Figure 8 This is a flowchart of a test script automated generation method provided by one or more embodiments of the present invention. See also... Figure 8 The method for automatically generating test scripts includes the following steps:
[0124] The data entities involved in the execution process include: Excel single-instance loading 801, multi-threaded parsing 802, MCU signal data 803, test cases 804, alarm pop-up data 805, alarm light data 806, power data 807, automated test command generation module 808, test environment initialization command 809, test result checking command 810, functional test command 811, command classification 812, Shell script 813, stress test 814, UI interface transmission to serial port 815, and UI interface transmission to serial port 816.
[0125] Excel Singleton Loading Error 801: Executing the Singleton pattern refers to the source file loading process. The Singleton pattern is used to avoid repeated loading of the file.
[0126] Multi-threaded parsing (802) utilizes multiple threads to complete the data parsing of source files. Employing multi-threading significantly improves the efficiency of data parsing operations.
[0127] MCU signal data 803, test case 804, alarm pop-up data 805, alarm light data, and power data 807 are the execution results of the data parsing process.
[0128] The automated test command generation module 808 can perform automated command generation operations. The generated results of the automated commands include the test environment initialization command 809, the test result check command 810, and the functional test command 811.
[0129] After the command is generated, it can be used to execute command classification (812), save the shell script (813), and perform stress testing (814). Finally, the generated command script is transmitted to serial ports (815 and 816) through the UI interface.
[0130] Figure 9 This is a flowchart of a test script automated generation method provided by one or more embodiments of the present invention. See also... Figure 9 The method for automatically generating test scripts includes the following steps:
[0131] S901, Start automated instrument function test.
[0132] S902, pass in the table path, and start generating test commands.
[0133] S903 calls the ExcelLoader singleton to load data.
[0134] S904 generates automated test commands.
[0135] S905 transmits automated test commands.
[0136] S906, Start executing the command.
[0137] Test environment initialization, test case execution, test result acquisition, test result detection, and environment reset.
[0138] S907 generates a stress test command.
[0139] S908, begin stress testing.
[0140] S909 outputs the test script file and checks the results.
[0141] S910 provides feedback on test results to users.
[0142] Figure 10 This is a structural diagram of a test script automated generation system provided in one or more embodiments of the present invention. See also... Figure 10 The automated test script generation system includes: a loading unit 1001, a data parsing unit 1002, a command generation unit 1003, and a test unit 1004.
[0143] Loading unit 1001 is configured to load source files one by one using a source file loading class that adopts the singleton pattern.
[0144] The data parsing unit 1002 is configured to use multiple source file parsing threads in the thread pool to parse MCU signal data, test case data, alarm pop-up data, alarm light data, and power data from the source files.
[0145] The command generation unit 1003 is configured to automatically generate test environment initialization commands, test result checking commands, and functional test commands based on the parsed data using the automated command generation function.
[0146] Test unit 1004 is configured to classify or combine various automatically generated commands, transmit the commands to the serial port, and run the test.
[0147] Optional, data parsing unit 1002: creating sub-units, extracting sub-units, and saving sub-units.
[0148] The sub-unit is used to create a thread pool.
[0149] The extraction sub-unit is used by the ThreadPoolExecutor object to concurrently execute multiple data extraction tasks, select the number of rows and columns of the target, and extract the required MCU signal data, test case data, alarm light data, alarm pop-up data, and power data.
[0150] The storage subunit is used to save the extracted data into memory in the form of a linked list.
[0151] Optionally, the command generation unit 1003 includes: a calculation subunit and a generation subunit.
[0152] The computation subunit is used to process illegal characters and construct bitwise operation calculation functions to calculate power data values from raw data.
[0153] The generation subunit is used to build multiple command generation modules to form a command generation engine according to requirements, using raw data and processed power data to generate different types of test commands.
[0154] Optional, different types of test commands include: test environment initialization commands, test result checking commands, and functional test commands;
[0155] The functional test commands include: functional status initialization command, single function raw information viewing command, test expected result viewing command, instrument functional test run command, and instrument functional test result saving command.
[0156] Optionally, the computational subunit is specifically used for:
[0157] Create the regular expression used for matching;
[0158] Extract power mode data corresponding to a single regular expression;
[0159] Extract power mode data corresponding to combinations of multiple regular expressions.
[0160] Optionally, test unit 1004 includes a classification subunit.
[0161] The classification subunit is used to classify commands based on keywords or feature values in the generated commands, making it easier for users to view the test execution process.
[0162] Optionally, test unit 1004 may also include: combination subunit.
[0163] The combined subunit is used to generate C using a dynamic combination algorithm when there are n valid icons in the system. n 5 ×4 5 This method improves coverage by more than 5 orders of magnitude compared to traditional fixed-scenario methods for various stress testing scenarios.
[0164] Optionally, test unit 1004 may also include: setting subunit and initializing subunit.
[0165] The configuration sub-unit is used to set the global default values for the test environment.
[0166] The initialization subunit is used to initialize the test case environment.
[0167] It is worth noting that although only some basic functional modules are disclosed in the embodiments of this invention, it does not mean that the composition of this system is limited to the above-mentioned basic functional modules. On the contrary, what this embodiment intends to express is that, based on the above-mentioned basic functional modules, those skilled in the art can arbitrarily add one or more functional modules in combination with existing technology to form an infinite number of embodiments or technical solutions. That is to say, this system is open rather than closed. The fact that this embodiment only discloses a few basic functional modules should not be considered as the scope of protection of the claims of this invention being limited to the disclosed basic functional modules. At the same time, for the convenience of description, the above device is described separately according to its functions as various units and modules. Of course, in implementing this invention, the functions of each unit and module can be implemented in one or more software and / or hardware.
[0168] The present invention also provides a computer-readable storage medium, comprising: storing a computer program executable by a vehicle, wherein when the computer program is run on the vehicle, the vehicle performs the steps of the test script automated generation method.
[0169] Specifically, the computer storage medium in this embodiment of the invention can be any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. For example, a computer-readable storage medium can be—but is not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this embodiment, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0170] The present invention also provides a computer program product, comprising: a computer program executed by a vehicle, wherein when the computer program is run on the vehicle, the vehicle performs the steps of the test script automated generation method.
[0171] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for automatically generating test scripts, characterized in that, The method for automatically generating test scripts includes: By using a singleton-pattern source file loading class, source files are loaded one by one. The thread pool utilizes multiple source file parsing threads to extract MCU signal data, test case data, alarm pop-up data, alarm light data, and power data from the source files. Based on the parsed data, the automated command generation function automatically generates test environment initialization commands, test result checking commands, and functional test commands. After classifying or combining the automatically generated commands, the commands are transmitted to the serial port for testing.
2. The method according to claim 1, characterized in that, Utilizing multiple source file parsing threads within a thread pool, MCU signal data, test case data, alarm pop-up data, alarm light data, and power data are parsed from the source files, including: Create a thread pool; The ThreadPoolExecutor object is used to concurrently execute multiple data extraction tasks. Select the number of rows and columns of the target data to extract the required MCU signal data, test case data, alarm light data, alarm pop-up data, and power data. The extracted data is stored in memory as a linked list.
3. The method according to claim 1, characterized in that, Based on the parsed data, the automated command generation function automatically generates test environment initialization commands, test result checking commands, and functional test commands, including: Process illegal characters and construct bitwise operation calculation functions to calculate power data values from raw data; Based on requirements, multiple command generation modules are constructed to form a command generation engine, which uses raw data and processed power data to generate different types of test commands.
4. The method according to claim 3, characterized in that, Different types of test commands include: test environment initialization commands, test result checking commands, and functional test commands; The functional test commands include: functional status initialization command, single function raw information viewing command, test expected result viewing command, instrument functional test run command, and instrument functional test result saving command.
5. The method according to claim 3, characterized in that, Process illegal characters and construct bitwise operation functions to calculate power data values from the raw data, including: Create the regular expression used for matching; Extract power mode data corresponding to a single regular expression; Extract power mode data corresponding to combinations of multiple regular expressions.
6. The method according to claim 1, characterized in that, After categorizing or combining the automatically generated commands, the commands are transmitted to the serial port for testing, including: Commands are classified based on keywords or feature values in the generated commands.
7. The method according to claim 1, characterized in that, After categorizing or combining the automatically generated commands, the commands are transmitted to the serial port for testing, which also includes: Using a dynamic combination algorithm, when the system has n valid icons, C can be generated. 5 n× 4 5 Various stress testing scenarios.
8. The method according to claim 1, characterized in that, After categorizing or combining the automatically generated commands, the commands are transmitted to the serial port for testing, which also includes: Set the global default values for the test environment; Initialize the test case environment.
9. A test script automated generation system, characterized in that, The automated test script generation system includes: The loading unit is configured to load source files one by one using a source file loading class that employs the singleton pattern; The data parsing unit is configured to use multiple source file parsing threads in the thread pool to parse MCU signal data, test case data, alarm pop-up data, alarm light data, and power data from the source files; The command generation unit is configured to automatically generate test environment initialization commands, test result checking commands, and functional test commands based on the parsed data using the automated command generation function. The test unit is configured to categorize or combine various automatically generated commands, transmit the commands to the serial port, and run the test.
10. A computer program product, characterized in that, It includes a computer program that, when executed by a processor, implements the test script automation method according to any one of claims 1 to 8.