Test case script generation tool and generation method
By using test case script generation tools and methods, test case table data is processed automatically, solving the problems of low efficiency and high labor costs in traditional testing processes. This enables efficient and standardized test script generation, adapts to changes in multiple scenarios, and reduces the risks of manual coding.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-11
- Publication Date
- 2026-04-03
AI Technical Summary
Traditional testing processes struggle to cope with the increasing number of project testing tasks, and the automation of test cases is time-consuming and labor-intensive. Existing technologies have failed to generate efficient automated test scripts.
This invention provides a test case script generation tool and method, including an operation interface, a main function, a module for extracting test case information, a module for splitting test case execution steps, and a module for defining and transforming execution steps. It generates test scripts through an automated process, and uses pandas to parse tabular data and split and concatenate operation steps to generate standardized script code.
Significantly improves test script generation efficiency, reduces labor costs, ensures script standardization and consistency, reduces manual coding errors, adapts to rapid business iteration, expands the applicable user base, and improves test quality and reproducibility.
Smart Images

Figure CN121785912A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of automotive testing technology. Specifically, this invention relates to a test case script generation tool and generation method. Background Technology
[0002] With the rapid development of the automotive industry and the increasing number of projects, traditional testing processes are struggling to cope with the growing number of project testing tasks, especially the automation of test cases, which consumes even more time and manpower.
[0003] Chinese Patent 101162426A discloses a data-driven test case design and testing method and an automated testing platform. The method includes: designing test cases based on requirements analysis, designing test logic and test data respectively; the data-driven design platform automatically generates forward-order test cases and reverse-order test cases based on the test logic and test data, wherein each reverse-order test case has a corresponding forward-order test case; the automated testing platform obtains the corresponding forward-order test cases based on the reverse-order test cases, stores them in pairs in a database, and performs automated testing.
[0004] Existing technologies fail to generate automated test scripts for test cases, resulting in low testing efficiency and high manual costs. Summary of the Invention
[0005] The present invention aims to provide a test case script generation tool and method to improve testing efficiency and reduce labor costs.
[0006] To achieve the above objectives, the technical solution adopted by the present invention is as follows: This invention provides a test case script generation tool, including an operation interface, a main function, a test case information extraction module, a test case execution step splitting module, and an execution step definition and conversion module; The user interface is used to import the path to the test case form file; the script path is displayed after the script is generated. The main function is used to retrieve test case information from the test case table file based on the path of the test case table file; the main function is used to concatenate the script codes of multiple test cases returned by the test case execution step module into a single script and store it, and return the path of the script to the operation interface. The test case information extraction module is used to output the operation step information from multiple test cases to the test case execution step splitting module based on the test case information. The Split Test Case Execution Steps module is used to split the operation step information in the test case, breaking the operation step into a single step and outputting it sequentially to the Execution Step Definition and Conversion module; when the Execution Step Definition and Conversion module returns the code of a single step, the module concatenates the code of the single step into the script code of the test case according to the operation steps of the test case and outputs it to the main function. The execution step definition and conversion module is used to convert individual steps into code and output them to the split test case execution step module.
[0007] The user interface includes a file import path box and a script output path box.
[0008] The input from the user interface to the main function is the path to the test case table file; the input from the split test case execution step module to the main function is the script code for multiple test cases; and the output from the main function to the user interface is the script storage path.
[0009] The input to the Use Case Information Extraction module is use case information, and the output is the operation step information from multiple use cases.
[0010] The input from the extract test case information module to the split test case execution step module is the operation step information of multiple test cases, and the output from the split test case execution step module to the execution step definition and transformation module is a single step after the operation steps of the test case are split.
[0011] The input from the execution step definition and transformation module to the split test case execution step module is the code for a single step, and the output from the split test case execution step module to the main function is the script code for the test cases.
[0012] This invention provides a method for generating test case scripts for a tool: Step 1: Import the path to the test case table file using the file path box in the operation interface; Step 2: The main function retrieves test case information based on the path of the test case table file and outputs multiple test case information to the test case information extraction module; Step 3: The test case information extraction module processes multiple test case information separately and outputs the operation step information in the test case information to the test case execution step splitting module; Step 4: The test case execution step splitting module splits the operation step information into individual step operation texts, and outputs the individual step operation texts sequentially to the test case execution step definition and conversion module; Step 5: The test case execution step definition and conversion module converts the operation text of each individual step into code and returns it to the test case execution step splitting module; Step Six: The test case execution step module combines the code of individual steps into the test case script code according to the operation steps of the test case and outputs it to the main function; Step 7: When the main function receives the script code of all test cases, it concatenates the script code of the test cases into a single script and stores it, then returns the path of the script to the operation interface.
[0013] In step two, the main function uses the pandas tool to parse the dataframe data in the test case table file, and then loops through and extracts the content of each row, which is then passed to the test case information extraction module.
[0014] In step five: the test case execution step definition and conversion module stores the code corresponding to the operation text of a single step before it starts working; when the test case execution step definition and conversion module works, it matches the corresponding code according to the input operation text.
[0015] The technical effects of this invention are as follows: (1) This invention significantly improves the efficiency of test script generation and significantly reduces labor costs. Traditional test script writing requires testers to manually write code line by line, which involves a huge amount of repetitive work when facing multiple test case scenarios, and the writing efficiency is significantly affected by the proficiency of the personnel. This invention realizes the batch generation of test scripts through an automated process, eliminating the need for manual line-by-line coding throughout the process, greatly shortening the script production cycle, reducing manpower input, and improving the overall efficiency of testing work.
[0016] (2) This invention lowers the technical threshold for test script writing and expands the user base of the tool. Traditional test script writing requires testers to be proficient in the syntax rules of programming languages such as Python. Business testers without a development background need to invest a lot of time to learn programming knowledge, which is difficult to get started with. In this invention, testers only need to fill in the operation steps, parameters and other information of the test cases in the table according to the unified specifications. They do not need to master complex programming syntax and can generate executable test scripts through the tool.
[0017] (3) This invention ensures the standardization and consistency of test scripts and improves test quality. When scripts are written manually, different testers have different coding habits and styles, which can easily lead to problems such as syntax errors, inconsistent logic, and missing steps, directly affecting the reliability of test results. This invention pre-encapsulates standardized code templates through the execution step definition and conversion module, ensuring that all operation steps match unified code logic and format; the splitting and splicing steps also follow fixed rules, ensuring that the generated script code has a unified style and standardized syntax, avoiding personalized deviations caused by manual coding. This reduces test failures caused by non-standard scripts and improves the accuracy and reproducibility of test results.
[0018] (4) This invention has the advantages of excellent maintainability and scalability, and adaptability to rapid business iteration. When the test scenario, operation type or business requirements change, there is no need to modify the overall framework of the tool. Only the mapping relationship between operation text and code needs to be added or adjusted in the execution step definition and conversion module to quickly adapt to new test requirements.
[0019] (5) This invention has the advantages of reducing manual coding errors and improving the accuracy of script generation. Manual coding is prone to problems such as parameter errors, syntax errors, disordered step order, or missing information, and error debugging is time-consuming and labor-intensive. This invention avoids the risk of manual intervention through a fully automated process: pandas can accurately extract test case information from each row of table data, avoiding misreading or omissions when manually reading test cases; the operation steps are broken down according to fixed rules to ensure the integrity of the steps; the conversion module generates code based on a pre-set standardized code template for keyword matching, eliminating common manual coding problems such as parameter errors and syntax errors from the source, and ensuring that the generated script is completely consistent with the expected logic of the test cases. Attached Figure Description
[0020] This manual includes the following figures, which illustrate the following: Figure 1 This is a flowchart illustrating a test case script generation tool and method according to the present invention. Detailed Implementation
[0021] The specific embodiments of the present invention will be further described in detail below with reference to the accompanying drawings, in order to help those skilled in the art to have a more complete, accurate and in-depth understanding of the inventive concept and technical solution of the present invention, and to facilitate its implementation.
[0022] This invention provides a test case script generation tool, including an interface, a main function, a test case information extraction module, a test case execution step splitting module, and an execution step definition and conversion module. The interface is used to import the path of a test case table file and display the script path after generation. The main function retrieves test case information from the test case table file based on its path. When the test case execution step splitting module returns script code for multiple test cases, the main function concatenates the script codes of these multiple test cases into a single script, stores it, and returns the script path to the interface. The test case information extraction module outputs the operation step information from multiple test cases to the test case execution step splitting module based on the test case information. The test case execution step splitting module splits the operation step information in the test cases into individual steps and outputs them sequentially to the execution step definition and conversion module. The test case execution step splitting module concatenates the code of a single step according to the test case's operation steps into the test case's script code and outputs it to the main function when the execution step definition and conversion module returns the code of that single step. The execution step definition and conversion module is used to convert individual steps into code and output them to the split test case execution step module.
[0023] The user interface includes a file import path box and a script output path box.
[0024] The input from the user interface to the main function is the path to the test case table file; the input from the split test case execution step module to the main function is the script code for multiple test cases; and the output from the main function to the user interface is the script storage path.
[0025] The input to the Use Case Information Extraction module is use case information, and the output is the operation step information from multiple use cases.
[0026] The input from the extract test case information module to the split test case execution step module is the operation step information of multiple test cases, and the output from the split test case execution step module to the execution step definition and transformation module is a single step after the operation steps of the test case are split.
[0027] The input from the execution step definition and transformation module to the split test case execution step module is the code for a single step, and the output from the split test case execution step module to the main function is the script code for the test cases.
[0028] This invention provides a method for generating test case scripts for a tool: Step 1: Import the path to the test case table file using the file path box in the operation interface; Step 2: The main function retrieves test case information based on the path of the test case table file and outputs multiple test case information to the test case information extraction module; Step 3: The test case information extraction module processes multiple test case information separately and outputs the operation step information in the test case information to the test case execution step splitting module; Step 4: The test case execution step splitting module splits the operation step information into individual step operation texts, and outputs the individual step operation texts sequentially to the test case execution step definition and conversion module; Step 5: The test case execution step definition and conversion module converts the operation text of each individual step into code and returns it to the test case execution step splitting module; Step Six: The test case execution step module combines the code of individual steps into the test case script code according to the operation steps of the test case and outputs it to the main function; Step 7: When the main function receives the script code of all test cases, it concatenates the script code of the test cases into a single script and stores it, then returns the path of the script to the operation interface.
[0029] In step two, the main function uses the pandas tool to parse the dataframe data in the test case table file, and then loops through and extracts the content of each row, which is then passed to the test case information extraction module.
[0030] In step five: the test case execution step definition and conversion module stores the code corresponding to the operation text of a single step before it starts working; when the test case execution step definition and conversion module works, it matches the corresponding code according to the input operation text.
[0031] The present invention will now be described in detail.
[0032] This invention provides a test case script generation tool, including a user interface, a main function, a module for extracting test case information, a module for splitting test case execution steps, and a module for defining and converting execution steps. The tool is computer-based and developed using Python. The user interface is used to import the path to the test case table file; after the script is generated, the path to the script is displayed.
[0033] The main function is used to retrieve test case information from the test case table file based on the path of the test case table file; when splitting the script code of multiple test cases returned by the test case execution step module, the main function concatenates the script code of multiple test cases into a single script and stores it, and returns the path of the script to the operation interface.
[0034] The Use Case Information Extraction module is used to output the operation step information from multiple use cases to the Use Case Execution Step Splitting module based on the use case information.
[0035] The Split Test Case Execution Steps module is used to split the operation step information in the test case, breaking the operation step into a single step and outputting it sequentially to the Execution Step Definition and Conversion module; when the Execution Step Definition and Conversion module returns the code of a single step, the module concatenates the code of the single step into the test case script code according to the operation steps of the test case and outputs it to the main function.
[0036] The execution step definition and conversion module is used to convert individual steps into code and output them to the split test case execution step module.
[0037] The method for generating a test case script generation tool according to the present invention is as follows: import the path of the test case table file through the file path box in the operation interface; the main function parses the contents of the test case table file using the pandas tool, reads its dataframe data, and extracts each row of content in a loop, and passes each row of content to the test case information extraction module.
[0038] After obtaining the test case information, the test case information extraction module reads the corresponding test case operation step information based on the header content of the test case information, and then passes the operation step information to the test case execution step splitting module.
[0039] After receiving the execution steps, the test execution step splitting module breaks down the test execution steps into individual steps and passes the operation text of each individual step to the execution step definition and conversion module.
[0040] The execution step definition and conversion module encapsulates the code corresponding to different operation texts in the pre-operation module. After obtaining the operation text of a single step, the execution step definition and conversion module determines the operation type based on keywords in the text, such as: sending a signal, judgment result, etc. After determining the keyword type, the parameters are passed to the encapsulated code function corresponding to the operation type to generate the corresponding code, and the code is returned to the test case execution step splitting module. The test case execution step splitting module concatenates the code generated by each operation step according to the order of the operation steps into the script code of a test case and returns it to the main function.
[0041] The main function concatenates the script code of all test cases into a single script, stores it in the user-specified path, and returns the path to the user interface.
[0042] The beneficial effects of the present invention are described in detail below.
[0043] This invention significantly improves test script generation efficiency and reduces labor costs. Traditional test script writing requires testers to manually write code line by line, resulting in a huge amount of repetitive work when dealing with multiple test cases, and the writing efficiency is significantly affected by the skill level of the tester. This invention achieves batch generation of test scripts through an automated process, eliminating the need for manual line-by-line coding throughout the entire process, greatly shortening the script production cycle, reducing manpower input, and improving the overall efficiency of testing work.
[0044] This invention lowers the technical barrier to test script writing and expands the user base of the tool. Traditional test script writing requires testers to be proficient in the syntax rules of programming languages such as Python. Business testers without a development background need to invest a lot of time learning programming knowledge, making it difficult to get started. In this invention, testers only need to fill in the operation steps, parameters, and other information of the test cases in a table according to a unified standard. They do not need to master complex programming syntax to generate executable test scripts through the tool.
[0045] This invention ensures the standardization and consistency of test scripts, improving test quality. When scripts are written manually, differences in coding habits and styles among different testers can easily lead to problems such as syntax errors, inconsistent logic, and missing steps, directly affecting the reliability of test results. This invention pre-packages standardized code templates through an execution step definition and conversion module, ensuring that all operation steps match unified code logic and format; the splitting and splicing steps also follow fixed rules, ensuring that the generated script code has a consistent style and standardized syntax, avoiding the personalized deviations brought about by manual coding. This reduces test failures caused by non-standard scripts, improving the accuracy and reproducibility of test results.
[0046] This invention has the advantages of excellent maintainability and scalability, and adaptability to rapid business iteration. When the test scenario, operation type or business requirements change, there is no need to modify the overall framework of the tool. Only the mapping relationship between operation text and code needs to be added or adjusted in the execution step definition and conversion module to quickly adapt to new test requirements.
[0047] This invention offers advantages such as reducing human coding errors and improving the accuracy of script generation. Manual coding is prone to problems like parameter errors, syntax errors, incorrect step sequences, or missing information, and error debugging is time-consuming and labor-intensive. This invention avoids the risks of human intervention through a fully automated process: pandas parsing of table data accurately extracts test case information from each row, avoiding misreading or omissions when manually reading test cases; operation steps are broken down according to fixed rules to ensure completeness; the conversion module generates code based on a pre-set standardized code template using keyword matching, eliminating common human coding problems such as parameter errors and syntax errors from the source, ensuring that the generated script is completely consistent with the expected logic of the test cases.
[0048] The present invention has been described above by way of example with reference to the accompanying drawings. Obviously, the specific implementation of the present invention is not limited to the above-described manner. Any non-substantial improvements made using the inventive concept and technical solution; or the direct application of the inventive concept and technical solution to other situations without modification, are all within the protection scope of the present invention.
Claims
1. A test case script generation tool, characterized in that: It includes the user interface, main function, module for extracting test case information, module for splitting test case execution steps, and module for defining and converting execution steps; The user interface is used to import the path to the test case form file; the script path is displayed after the script is generated. The main function is used to retrieve test case information from the test case table file based on the path of the test case table file; the main function is used to concatenate the script codes of multiple test cases returned by the test case execution step module into a single script and store it, and return the path of the script to the operation interface. The test case information extraction module is used to output the operation step information from multiple test cases to the test case execution step splitting module based on the test case information. The Split Test Case Execution Steps module is used to split the operation step information in the test case, breaking the operation step into a single step and outputting it sequentially to the Execution Step Definition and Conversion module; when the Execution Step Definition and Conversion module returns the code of a single step, the module concatenates the code of the single step into the script code of the test case according to the operation steps of the test case and outputs it to the main function. The execution step definition and conversion module is used to convert individual steps into code and output them to the split test case execution step module.
2. The test case script generation tool as described in claim 1, characterized in that: The user interface includes a file import path box and a script output path box.
3. The test case script generation tool as described in claim 1, characterized in that: The input from the user interface to the main function is the path to the test case table file; the input from the split test case execution step module to the main function is the script code for multiple test cases; and the output from the main function to the user interface is the script storage path.
4. The test case script generation tool as described in claim 1, characterized in that: The input to the Use Case Information Extraction module is use case information, and the output is the operation step information from multiple use cases.
5. A test case script generation tool as described in claim 1, characterized in that: The input from the extract test case information module to the split test case execution step module is the operation step information of multiple test cases, and the output from the split test case execution step module to the execution step definition and transformation module is a single step after the operation steps of the test case are split.
6. The test case script generation tool as described in claim 1, characterized in that: The input from the execution step definition and transformation module to the split test case execution step module is the code for a single step, and the output from the split test case execution step module to the main function is the script code for the test cases.
7. A method for generating test case scripts as described in any one of claims 1-6, characterized in that: Step 1: Import the path to the test case table file using the file path box in the operation interface; Step 2: The main function retrieves test case information based on the path of the test case table file and outputs multiple test case information to the test case information extraction module; Step 3: The test case information extraction module processes multiple test case information separately and outputs the operation step information in the test case information to the test case execution step splitting module; Step 4: The test case execution step splitting module splits the operation step information into individual step operation texts, and outputs the individual step operation texts sequentially to the test case execution step definition and conversion module; Step 5: The test case execution step definition and conversion module converts the operation text of each individual step into code and returns it to the test case execution step splitting module; Step Six: The test case execution step module combines the code of individual steps into the test case script code according to the operation steps of the test case and outputs it to the main function; Step 7: When the main function receives the script code of all test cases, it concatenates the script code of the test cases into a single script and stores it, then returns the path of the script to the operation interface.
8. The method for generating a test case script generation tool as described in claim 7, characterized in that: In step two, the main function uses the pandas tool to parse the dataframe data in the test case table file, and then loops through and extracts the content of each row, which is then passed to the test case information extraction module.
9. The method for generating a test case script generation tool as described in claim 7, characterized in that: In step five: the test case execution step definition and conversion module stores the code corresponding to the operation text of each individual step before starting work; When the test case execution step definition and conversion module works, it matches the corresponding code based on the input operation text.
Citation Information
Patent Citations
Example design test method for testing based on data driving and automatically testing platform
CN101162426A