Automatic generation method and device of automatic driving simulation test script, generation equipment and storage medium
By writing test cases into memory and automatically converting them into code using a script generation module, the problem of low efficiency in writing test scripts for autonomous driving systems is solved, achieving automated generation and improving development speed.
Patent Information
- Application Number
- CN202211064004.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-31
- Publication Date
- 2025-12-30
- Estimated Expiration
- 2042-08-31
AI Technical Summary
In existing technologies, autonomous driving systems are updated and replaced rapidly, but test scripts are inefficient and difficult to keep up with the pace of iteration, resulting in time-consuming and inefficient work.
By writing test cases into the memory in the form of step documents, the test case information is converted into code using preset scripts in the script generation module, generating autonomous driving simulation test scripts. This is achieved through a combination of Python scripts and simulation software, enabling automated generation.
This greatly improves the generation speed of autonomous driving simulation test scripts, reduces the time cost of manual writing, and improves the iterative efficiency of algorithm development.
Smart Images

Figure CN115422057B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of autonomous vehicle simulation testing, specifically relating to the automated generation method, apparatus, generation equipment, and storage medium for autonomous driving simulation test scripts. Background Technology
[0002] Autonomous driving simulation testing is the application of computer simulation technology in the automotive field. Currently, simulation testing of the functional logic of autonomous driving systems can be divided into three parts: test cases, scenario construction, and test scripts. Test cases are specific functionalities of the autonomous driving system determined through expert review and can be retained and reused. Test scenarios and test scripts are built and written based on test cases and change as the autonomous driving system iterates. However, with the rapid pace of updates to autonomous driving systems, the continuous increase in test cases, and the rapid development of scenario traversal technologies, the writing of test scripts clearly cannot keep up with the pace of iteration. Manually writing script code based on test cases is a time-consuming and inefficient task. Summary of the Invention
[0003] The purpose of this invention is to provide an automated method, apparatus, generation device, and storage medium for generating autonomous driving simulation test scripts, which automatically converts the textual descriptions of test cases into test script code based on existing test cases and a pre-designed test script framework.
[0004] To achieve the above-mentioned technical objectives, the technical solution adopted by the present invention is as follows:
[0005] In a first aspect, embodiments of this application provide an automated generation method for autonomous driving simulation test scripts, applied to an automated generation device for autonomous driving simulation test scripts. The device includes a memory and a script generation module, the script generation module being used to automatically generate autonomous driving simulation test scripts. The method includes:
[0006] All test cases are written into the memory in the form of step documents. The script generation module is equipped with preset scripts. The test cases are obtained sequentially through the preset scripts and retrieved according to the case number of the test case to determine that the current test case is the latest version test case.
[0007] The preset script converts the text information of the current test case into code, writes it into a preset test script framework, and generates a test script.
[0008] Confirm that the test script was successfully generated;
[0009] Determine whether test scripts have been generated for all test cases, and write the successfully generated test scripts into the memory.
[0010] In conjunction with the first aspect, in some optional implementations, all test cases are written into the memory in the form of step documents. The script generation module has preset scripts, which sequentially retrieve the test cases and search based on their case numbers to determine if the current test case is the latest version. This includes:
[0011] The first sub-function of the preset script obtains all configuration information of the test case and generates a case number storage variable to store the case numbers of all test cases.
[0012] Searching based on the current test case number determines that the current test case is the latest version.
[0013] In conjunction with the first aspect, in some optional implementations, based on the search results, the preset script converts the text information of the test case into code, writes it into a preset test script framework, and generates a test script, including:
[0014] The test case is determined to be the latest version of the test case. The information of the test case in the step document is crawled through the second sub-function of the preset script, and the information of the test case is saved as an array. The information in the array is further segmented, transformed and reconstructed into statements, and the test case is converted into code. The code is written into the preset script framework to generate the test script.
[0015] In conjunction with the first aspect, in some optional implementations, the information of the test case is segmented, transformed, and reconstructed in one go, the test case is converted into code, the code is written into a preset script framework, and the test script is generated, including:
[0016] The third sub-function of the preset script is used to segment the information in the cell of the current test case's step document to obtain segmentation information.
[0017] The segmentation information is converted into code statements that can be recognized by the preset simulation software through the fourth sub-function of the preset script to obtain the converted code;
[0018] The converted code is recombined according to semantic logic through the fifth sub-function of the preset script and written into the preset test script framework to obtain the test script of the test case.
[0019] In conjunction with the first aspect, in some optional implementations, determining that the test script was successfully generated includes:
[0020] The information of the test script is queried through the preset script, and compared with the information of the test cases in the step document to determine that all the information of the test cases has been written.
[0021] The test script is subjected to simulation testing. If the test script passes the simulation test, the test script corresponding to the current test case is successfully generated.
[0022] In conjunction with the first aspect, in some alternative implementations, the method further includes:
[0023] If the currently described test case is not the latest version, write the test case number to the error log.
[0024] Alternatively, if the information of the test case is not fully written into the test script, write the test case number into the error log;
[0025] Alternatively, if the test script simulation fails, the case number of the test case corresponding to the test script will be written to the error log;
[0026] After the test scripts for all test cases are automatically generated, the script editor opens the error log and modifies the corresponding test cases.
[0027] In conjunction with the first aspect, in some optional implementations, determining whether all test cases have generated test scripts and writing successfully generated test scripts into the memory includes:
[0028] When the preset script runs, it will capture the case number in the stored variable. If the preset script captures a new case number, it will obtain the corresponding test case and perform the operation of automatically generating a test script.
[0029] If the preset script does not capture a new case number, then all test cases have already generated test scripts;
[0030] All the generated test scripts are written into the memory.
[0031] Secondly, embodiments of this application also provide an automated generation device for autonomous driving simulation test scripts, applied to an automated generation device for autonomous driving simulation test scripts. The device includes a memory and a script generation module, the script generation module being used to automatically generate autonomous driving simulation test scripts. The device includes:
[0032] Storage unit: Used to store all test cases and test scripts automatically generated based on the test cases;
[0033] Processing unit: Used to acquire information from test cases, convert textual test information into code, write the code into a preset test script framework, and automatically generate test scripts for test cases.
[0034] Thirdly, embodiments of this application also provide an automated generation device for autonomous driving simulation test scripts. The device includes a memory and a script generation module. The script generation module is used to automatically generate autonomous driving simulation test scripts. The memory stores a computer program. When the computer program is executed by the script generation module, the automated generation device for autonomous driving simulation test scripts performs the above-described method.
[0035] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program that, when run on a computer, causes the computer to perform the methods described above.
[0036] The invention employing the above technical solution has the following advantages:
[0037] Simply write the test cases into the storage as step documents, use the preset script in the script generation module to crawl the information in the step documents, rewrite the test case information into an array in the cell, and then further split and transform the array information to convert the test cases into code. Then refactor the code according to semantic logic and write it into the test script framework to automatically generate test scripts, which greatly improves the speed of algorithm development and iteration. Attached Figure Description
[0038] The present invention can be further illustrated by the non-limiting embodiments given in the accompanying drawings;
[0039] Figure 1 A block diagram of an automated generation device for autonomous driving simulation test scripts provided in an embodiment of this application.
[0040] Figure 2 This is a flowchart illustrating the automated generation method for autonomous driving simulation test scripts provided in this application embodiment.
[0041] Figure 3 A block diagram of an automated generation device for autonomous driving simulation test scripts provided in an embodiment of this application.
[0042] Icons: 10. Automated generation device for autonomous driving simulation test scripts; 11. Memory; 12. Script generation module; 200. Automated generation device for autonomous driving simulation test scripts; 210. Storage unit; 220. Processing unit. Detailed Implementation
[0043] The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that similar or identical parts are referred to by the same reference numerals in the drawings or description. Implementations not shown or described in the drawings are forms known to those skilled in the art. In addition, directional terms mentioned in the embodiments, such as "up," "down," "top," "bottom," "left," "right," "front," and "back," are only for reference to the directions in the drawings and are not intended to limit the scope of protection of the present invention.
[0044] like Figure 1 As shown in the figure, this application embodiment provides an automated generation device 10 for autonomous driving simulation test scripts, including a memory 11 and a script generation module 12. The script generation module 12 is used to automatically generate autonomous driving simulation test scripts, and the memory 11 stores computer programs.
[0045] The memory 11 can be used, but is not limited to, storing test case step documents, test case number storage variables, and generated test case files.
[0046] In this embodiment, test cases are written into the memory 11 in the form of step documents. The script generation module 12 uses a preset script to crawl information from the step documents, rewriting the test case information into arrays within cells. These arrays are then further segmented and transformed to convert the test cases into code. The code is then reconstructed according to semantic logic and written into the test script framework, thus automatically generating the test script. Then, based on the judgment logic within the preset script, it is determined whether the test script was successfully generated and whether all test cases have generated corresponding test scripts. If it is determined that all generated test cases have generated corresponding test scripts, the test scripts are written into the memory 11.
[0047] When the computer program is executed by the script generation module 12, the automated generation device 10 for the autonomous driving simulation test script performs the following method.
[0048] like Figure 2 As shown, this application also provides a method for automatically generating autonomous driving simulation test scripts. The method for automatically generating autonomous driving simulation test scripts may include the following steps:
[0049] Step 110: All test cases are written into the memory 11 in the form of a step document. The script generation module 12 is set with a preset script. The test cases are obtained sequentially through the preset script, and the test case number is used to search and determine that the current test case is the latest version test case.
[0050] Step 120: The preset script converts the text information of the current test case into code, writes it into the preset test script framework, and generates the test script;
[0051] Step 130: Confirm that the test script was successfully generated;
[0052] Step 140: Determine whether all the test cases have generated test scripts, and write the successfully generated test scripts into the memory 11.
[0053] In the above implementation, the preset algorithm in the script generation module 12 retrieves test cases from the memory 11, saves the test case information as an array, and further segments, transforms, and reconstructs the test case information using a preset script, converting it into code and writing it into a preset test script framework to generate a test script. Based on the built-in logic of the preset algorithm, it is determined that the test cases have been successfully generated and that all test cases have generated test scripts.
[0054] As an optional implementation, all test cases are written into the memory 11 in the form of step documents. The script generation module 12 is equipped with a preset script. The test cases are obtained sequentially through the preset script, and the current test case is determined to be the latest version test case based on the case number. This includes:
[0055] The first sub-function of the preset script obtains all configuration information of the test case and generates a case number storage variable to store the case numbers of all test cases.
[0056] Searching based on the current test case number determines that the current test case is the latest version.
[0057] The test case information is divided into two parts: observation conditions and operation injection. It is saved as a step document in the form of an Excel workbook and named after the case number. The first column of the step document, A1:A36, is filled with '%' to avoid execution. B1:G2 contains the original test overview, including case ID, test overview, test conditions, execution operation, judgment conditions, etc. B4:G36 contains all the test steps and pass conditions, where B4:G4 is the header and B5:B25 is the step label, i.e. Step1-Step20.
[0058] In this embodiment, the preset script is named Write_script.py. The first sub-function of the preset script can quickly modify configuration information, such as document version number, file path, and case number information, to enable repeated script calls. This sub-function script includes built-in logic for searching case numbers (Case_num), crawling and saving the case numbers of all cases. If a duplicate case number is found, a prompt message will be issued when generating the test script, facilitating testers to quickly locate the problem.
[0059] The pre-defined script contains pandas functions in Python. These functions interact with Excel to crawl the above information and save it as an array. The Casecondition array stores the text information of the observation conditions, and the Caseoperation array stores the text information of the operation injection. The entire interaction process is saved as a Python function for easy calling and named PitchCaseInfo.py.
[0060] As an optional implementation, based on the search results, the preset script converts the text information of the test case into code, writes it into a preset test script framework, and generates a test script, including:
[0061] The test case is determined to be the latest version of the test case. The information of the test case in the step document is crawled through the second sub-function of the preset script, and the information of the test case is saved as an array. The information in the array is further segmented, transformed and reconstructed into statements, and the test case is converted into code. The code is written into the preset script framework to generate the test script.
[0062] The second sub-function of the preset script is a pandas function in Python. It interacts with Excel through the pandas function in Python, crawls out the above information and saves it in the form of an array. The Casecondition array is used to save the text information of the observation conditions, and the Caseoperation array is used to save the text information of the operation injection. The entire interaction process is saved as a Python function for easy calling, named PitchCaseInfo.py.
[0063] In this embodiment, the Python script framework of the Scanner simulation software is used, and the `mice.` function is employed for test script framework design. Following the steps 1-20 in the documentation, each step generates a custom `def` function, containing fixed code for each step. A pre-defined script, `Write_script.py`, then adds the different code for each case to the corresponding step. Each test script executes in the order of Steps 1-20.
[0064] As an optional implementation, the information of the test case is segmented, transformed, and reconstructed in one go, the test case is converted into code, the code is written into a preset script framework, and the test script is generated, including:
[0065] The third sub-function of the preset script is used to segment the information in the cell of the current test case's step document to obtain segmentation information.
[0066] The segmentation information is converted into code statements that can be recognized by the preset simulation software through the fourth sub-function of the preset script to obtain the converted code;
[0067] The converted code is recombined according to semantic logic through the fifth sub-function of the preset script and written into the preset test script framework to obtain the test script of the test case.
[0068] In this embodiment, the third sub-function of the preset script is Python's built-in regular expression function `re.`. This third sub-function is used to segment the signal names and signal values in the cells based on logical operators. Since the information stored in the array is all equations, including signals, operators, and parameter values, statement segmentation uses operators as logical markers. The logical operators involved are the following recognizable symbols and text: ==, >=, <=, ~=, =, >, <, ~, greater than or equal to, less than or equal to, less than, greater than, not equal to, equal to, ≥, ≤, not, is, ≠, <, reaches, exceeds.
[0069] The fourth sub-function of the preset script is the meta-correlation function, which converts the segmented signal names and values into the information required by the test script. The information needed by the test script here is the Python `mice` function statement that the Scanner simulation software used in this application can recognize. The observed signal name is converted into the function format of `mice.getExportChannelByName()`, and the manipulated signal name is converted into the function format of `mice.setExportChannelByName()`.
[0070] The fifth sub-function of the default script is the comb refactoring function. The comb refactoring function recombines the converted Python statements according to their original semantic logic, thereby completely converting the cell information into code.
[0071] After the transformation is complete, each line of code is populated into the pre-written logic framework. A For loop is used, with the loop ending at the maximum step size of the current test case. The code for each step size consists of fixed logic framework code and changing observation and operation condition code.
[0072] As an optional implementation, determining that the test script was successfully generated includes:
[0073] The information of the test script is queried through the preset script, and compared with the information of the test cases in the step document to determine that all the information of the test cases has been written.
[0074] The test script is subjected to simulation testing. If the test script passes the simulation test, the test script corresponding to the current test case is successfully generated.
[0075] In this embodiment, the preset script `Write_script.py` first includes built-in logic to determine if a test case is empty. If the current test case lacks or omits required information, the script will record the corresponding test case number and issue a prompt during runtime. If the current test case contains all required information, a simulation test is performed. The simulation step size logic needs to be customized, using a feedback mechanism every step. A 30-second delay is set for each step. If no command to execute the next step is given within 30 seconds, the step is considered blocked. If a condition is not met when executing the last step, the step is considered failed, meaning the test has failed. Otherwise, the current test script passes the simulation test, meaning the current test script was successfully generated.
[0076] As an optional implementation, the method further includes:
[0077] If the currently described test case is not the latest version, write the test case number to the error log.
[0078] Alternatively, if the information of the test case is not fully written into the test script, write the test case number into the error log;
[0079] Alternatively, if the test script simulation fails, the case number of the test case corresponding to the test script will be written to the error log;
[0080] After the test scripts for all test cases are automatically generated, the script editor opens the error log and modifies the corresponding test cases.
[0081] In this embodiment, when an abnormal situation occurs, an error log is recorded, which makes it convenient for script editors to open the error log and modify the corresponding test cases.
[0082] As an optional implementation, determining whether all test cases have generated test scripts and writing successfully generated test scripts into the memory 11 includes:
[0083] When the preset script runs, it will capture the case number in the stored variable. If the preset script captures a new case number, it will obtain the corresponding test case and perform the operation of automatically generating a test script.
[0084] If the preset script does not capture a new case number, then all test cases have already generated test scripts;
[0085] All the generated test scripts are written into the memory 11.
[0086] In this embodiment, during the process of writing all the step documents, the preset script saves the case numbers of all test cases in the case number storage variable. When generating the test script, the case numbers in the storage variable will be gradually retrieved. If no new case numbers are retrieved, it means that all test cases have generated test scripts.
[0087] like Figure 3 As shown, this application also provides an automated generation device 200 for autonomous driving simulation test scripts. The automated generation device 200 includes at least one software function module that can be stored in a storage module or embedded in the operating system (OS) of the automated generation device 10 for autonomous driving simulation test scripts, either as software or firmware. The script generation module 12 is used to execute executable modules stored in the storage module, such as the software function modules and computer programs included in the automated generation device 200 for autonomous driving simulation test scripts.
[0088] The automated generation device 200 for autonomous driving simulation test scripts includes a storage unit 210 and a processing unit 220. The functions of each unit are as follows:
[0089] Storage unit 210 is used to store all test cases and test scripts automatically generated based on the test cases;
[0090] The processing unit 220 is used to acquire information within the test case, convert the test information in text form into code, write the code into a preset test script framework, and automatically generate the test script for the test case.
[0091] In this embodiment, the storage module may be, but is not limited to, random access memory, read-only memory, programmable read-only memory, erasable programmable read-only memory, electrically erasable programmable read-only memory, etc.
[0092] Understandable, Figure 1 The automated generation device 10 for autonomous driving simulation test scripts shown is only a schematic diagram. The automated generation device 10 for autonomous driving simulation test scripts may also include components that are larger than those shown in the diagram. Figure 1 More components are shown. Figure 1 The components shown can be implemented using hardware, software, or a combination thereof.
[0093] It should be noted that, for the sake of convenience and brevity, the specific working process of the automated generation device 10 and the automated generation apparatus 200 for generating autonomous driving simulation test scripts described above can be referred to the corresponding process of each step in the aforementioned method, and will not be elaborated further here.
[0094] This application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program that, when run on a computer, causes the computer to execute the automated generation method for autonomous driving simulation test scripts as described in the above embodiments.
[0095] Based on the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by hardware or by using software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solution of this application can be embodied in the form of a software product. The software product can be stored in a non-volatile storage medium (such as CD-ROM, USB flash drive, mobile hard drive, etc.) and includes several instructions to cause a computer device (such as a personal computer, braking device, or network device, etc.) to execute the methods described in the various implementation scenarios of this application.
[0096] In summary, this application provides an automated method, apparatus, generation device, and storage medium for generating autonomous driving simulation test scripts. In this solution, test cases are written into the memory 11 in the form of step documents. A preset script within the script generation module 12 crawls the information from the step documents, rewrites the test case information into arrays within cells, and then further segments and transforms the array information to convert the test cases into code. The code is then reconstructed according to semantic logic and written into the test script framework, thus automatically generating the test script, greatly improving the speed of algorithm development and iteration.
[0097] In the embodiments provided in this application, it should be understood that the disclosed apparatus, systems, and methods can also be implemented in other ways. The apparatus, systems, and methods embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code, which includes one or more executable instructions for implementing a specified logical function. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions. Furthermore, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0098] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. An automatic generation method of an automatic driving simulation test script, characterized by: The application discloses an automatic generation device for an automatic driving simulation test script, and relates to the technical field of automatic driving simulation test scripts. All test cases are written in the form of step documents in the memory, and a preset script is arranged in the script generation module; the test cases are sequentially acquired through the preset script, and the current test case is determined as the latest version test case according to the case number of the test case. The preset script converts the text information of the current test case into code and writes the code into a preset test script framework to generate a test script. It is determined whether the test script is successfully generated. It is determined whether all the test cases have generated test scripts, and the successfully generated test scripts are written into the memory. According to the retrieval result, the preset script converts the text information of the test case into code and writes the code into a preset test script framework to generate a test script, including: The current test case is determined as the latest version test case, the information of the test case in the step document is acquired through a second subfunction of the preset script, and the information of the test case is saved as an array; the information in the array is further subjected to sentence segmentation, conversion and reconstruction, the test case is converted into code, and the code is written into a preset script framework to generate the test script.
2. The method of claim 1, wherein: All test cases are written in the form of step documents in the memory, and a preset script is arranged in the script generation module; the test cases are sequentially acquired through the preset script, and the current test case is determined as the latest version test case according to the case number of the test case, including: All configuration information of the test case is acquired through a first subfunction of the preset script, and a case number storage variable is generated to save the case numbers of all the test cases. The current test case is determined as the latest version test case according to the case number of the test case.
3. The method of claim 1, wherein: The information of the test case is subjected to sentence segmentation, conversion and reconstruction at one time, the test case is converted into code, and the code is written into a preset script framework to generate the test script, including: The information in the cell of the step document of the current test case is segmented through a third subfunction of the preset script to obtain segmented information. The segmented information is converted into code statements that can be recognized by a preset simulation software through a fourth subfunction of the preset script to obtain converted code. The converted code is combined again according to semantic logic through a fifth subfunction of the preset script, and is written into the preset test script framework to obtain the test script of the test case.
4. The method of claim 1, wherein: It is determined that the test script is successfully generated, including: The information of the test script is inquired through the preset script, and is compared with the information of the test case in the step document to determine that all the information of the test case has been written in; The test script is subjected to simulation test, and if the test script passes the simulation test, the test script corresponding to the current test case is successfully generated.
5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: retrieving a test case that is not the latest version of the test case, and writing the case number of the test case into an error log; or, the information of the test case is not completely written into the test script, and writing the case number of the test case into an error log; or, the test script simulation fails, and writing the case number of the test case corresponding to the test script into an error log; After automatically generating the test scripts of all the test cases, a script editor opens the error log and modifies the corresponding test cases.
6. The method of claim 1, wherein: determining whether all the test cases have generated test scripts, and writing the test scripts successfully generated into the memory, comprising: The preset script runs to capture the case number in the storage variable, if the preset script captures a new case number, the corresponding test case is obtained, and the operation of automatically generating the test script is performed; if the preset script does not capture a new case number, all the test cases have generated test scripts; writing all the test scripts generated into the memory.
7. An automated generation device for autonomous driving simulation test scripts, characterized in that: The application discloses an automatic generation device of an automatic driving simulation test script. The device is used for executing the method in any one of claims 1-6.
8. An automatic driving simulation test script automatic generation device, characterized by: The device comprises a memory and a script generation module, the script generation module is used for automatically generating an automatic driving simulation test script, and the memory stores a computer program.
9. A computer-readable storage medium, characterized in that: The computer readable storage medium stores a computer program, and when the computer program runs on a computer, the computer executes the method in any one of claims 1-6.
Citation Information
Patent Citations
Software automation test architecture method based on reflection mechanism
CN113900953A