Dynamic test report generation method, system and equipment based on template engine and automation tool and medium
Through the dynamic test report generation method based on template engine and automation tools, the problems of low efficiency and insufficient flexibility of traditional report generation methods are solved, and efficient, flexible and accurate test report generation is achieved, reducing labor costs and improving report quality.
Patent Information
- Application Number
- CN202510188488.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-20
- Publication Date
- 2025-06-27
AI Technical Summary
Traditional test report generation methods are inefficient, lack of flexibility, error-prone and difficult to maintain, resulting in high cost and low quality of report generation.
Using a dynamic test report generation method based on the template engine and automation tools, we can automatically generate test reports through steps such as managing templates, inputting and processing data, analyzing data, filling templates and generating reports.
Improves the efficiency and flexibility of test report generation, reduces manual intervention, reduces error rate and maintenance costs, and improves the accuracy and reliability of reports.
Smart Images

Figure CN120218030A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software testing, and in particular to a method, system, device and medium for generating a dynamic test report based on a template engine and an automation tool. Background Art
[0002] In the fields of software testing, product quality inspection, and scientific research, the generation of test reports is an important and frequent task. Traditional test report generation methods usually rely on manual writing or the use of fixed report templates, which have the following problems:
[0003] ① Inefficiency: Manually writing reports is time-consuming and labor-intensive, especially when the amount of test data is large or the report format is complex.
[0004] ② Lack of flexibility: Fixed templates are difficult to adapt to the needs of different projects or test scenarios, resulting in duplication of report content or missing information.
[0005] ③ Error-prone: Manual operation can easily introduce errors, affecting the accuracy and reliability of the report.
[0006] ④Difficult to maintain: Template updates and modifications require a lot of manual intervention, which increases maintenance costs.
[0007] Therefore, how to generate test reports efficiently, flexibly and accurately, reduce labor costs and improve report quality is a technical problem that needs to be solved urgently. Summary of the invention
[0008] The technical task of the present invention is to provide a dynamic test report generation method, system, device and medium based on a template engine and an automation tool to solve the problem of how to generate test reports efficiently, flexibly and accurately, reduce labor costs and improve report quality.
[0009] The technical task of the present invention is achieved in the following manner: a method for generating a dynamic test report based on a template engine and an automation tool, the method being specifically as follows:
[0010] Manage Templates: Create, edit and store report templates;
[0011] Input and process data: receive project names, test data and uploaded image files input by users;
[0012] Parse data: parse the test data into structured dictionary or list data, and save the image to the specified directory;
[0013] Fill template: dynamically fill data into the template;
[0014] Generate report: Convert the filled template into final Word and PDF report files;
[0015] Output report: Save the generated report files to the server or directly return them to the user for download.
[0016] Preferably, the report template is a report template containing placeholders, which are used to dynamically fill in information such as project names, test data, and picture paths.
[0017] Preferably, the formats of the report templates include Word documents, PDF documents, and HTML pages.
[0018] Preferably, when filling the template, use the Jinja2 template engine to dynamically fill in information such as project names, test data, and picture paths into the template;
[0019] Among them, for Word documents, use the docxtpl library for template rendering;
[0020] For PDF documents, use WeasyPrint or ReportLab for generation.
[0021] More preferably, when generating reports, support batch report generation, which is applicable to multi-project or multi-test scenarios.
[0022] A dynamic test report generation system based on a template engine and automation tools, the system includes:
[0023] A template management module for creating, editing, and storing report templates;
[0024] A data input and processing module for receiving the project name, test data, and uploaded picture files input by the user;
[0025] A data parsing module for parsing test data into structured dictionary or list data and saving the pictures to a specified directory;
[0026] A template filling module for dynamically filling data into the template;
[0027] A report generation module for converting the filled template into final Word and PDF report files;
[0028] A report output module for saving the generated report files to the server or directly returning them to the user for download.
[0029] Preferably, the report template is a report template containing placeholders, which are used to dynamically fill in information such as project names, test data, and picture paths; the formats of the report templates include Word documents, PDF documents, and HTML pages;
[0030] The template filling module dynamically fills the project name, test data, and picture path information into the template through the Jinja2 template engine; among them, for Word documents, the docxtpl library is used for template rendering; for PDF documents, WeasyPrint or ReportLab is used for generation.
[0031] More preferably, the working process of the system is specifically as follows:
[0032] (1) After the report template is created, whether the report template document is successfully maintained in the system:
[0033] ① If so, execute step (2);
[0034] ② If not, jump to step (5);
[0035] (2) Determine whether the project name, test data, and picture information are successfully input:
[0036] ① If so, execute step (3);
[0037] ② If not, jump to step (5);
[0038] (3) Parse and analyze the input project name, test data, and picture information, and determine whether the report file is successfully generated:
[0039] ① If so, execute step (4);
[0040] ② If not, jump to step (5);
[0041] (4) Output the report file;
[0042] (5) End.
[0043] An electronic device, comprising: a memory and at least one processor;
[0044] Wherein, a computer program is stored on the memory;
[0045] The at least one processor executes the computer program stored in the memory, so that the at least one processor executes the dynamic test report generation method based on the template engine and automation tools as described above.
[0046] A computer-readable storage medium, in which a computer program is stored, and the computer program can be executed by a processor to implement the dynamic test report generation method based on the template engine and automation tools as described above.
[0047] The dynamic test report generation method, system, device, and medium based on the template engine and automation tools of the present invention have the following advantages:
[0048] (1) The present invention automatically fills a predefined report template by inputting key information (such as project name, test data, pictures, etc.) and generates a final report file, realizing efficient, flexible, and accurate test report generation;
[0049] (2) The present invention can generate test reports efficiently, flexibly, and accurately, and is applicable to fields such as software testing, product quality inspection, and scientific research; by implementing the present invention, the report generation efficiency can be significantly improved, the labor cost can be reduced, and the report quality can be enhanced;
[0050] (3) Compared with the prior art, the present invention has the advantages of high efficiency, flexibility, accuracy, easy maintainability, and scalability, as follows:
[0051] ① High efficiency: The generation efficiency of test reports is significantly improved through automated tools and template engines;
[0052] ② Flexibility: Supports multiple file formats and dynamic data filling, meeting the requirements of different projects or test scenarios;
[0053] ③ Accuracy: Reduces manual intervention, lowers the error rate, and improves the accuracy of reports;
[0054] ④ Easy maintainability: The template update and modification are simple and convenient, reducing the maintenance cost;
[0055] ⑤ Scalability: Supports batch report generation and is applicable to multiple projects or test scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] The present invention will be further described below with reference to the accompanying drawings.
[0057] FIG Figure 1 is a schematic diagram of a dynamic test report generation method based on a template engine and an automated tool;
[0058] FIG Figure 2 is a flowchart of the working process of a dynamic test report generation system based on a template engine and an automated tool. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0059] The dynamic test report generation method, system, device, and medium of the present invention based on a template engine and an automated tool will be described in detail below with reference to the accompanying drawings of the specification and specific embodiments.
[0060] Embodiment 1:
[0061] As shown in FIG Figure 1 This embodiment provides a dynamic test report generation method based on a template engine and an automated tool, which is as follows:
[0062] S1, Management Template: Create, edit, and store report templates;
[0063] S2, Input and Process Data: Receive the project name, test data, and uploaded picture files input by the user;
[0064] S3, Parse Data: Parse the test data into structured dictionary or list data, and save the pictures to the specified directory;
[0065] S4, Fill Template: Dynamically fill the data into the template;
[0066] S5, Generate Report: Convert the filled template into the final Word document and PDF document report files;
[0067] S6, Output Report: Save the generated report files to the server or directly return them to the user for download.
[0068] In this embodiment, the report template in step S1 includes a report template with placeholders, and the placeholders are used to dynamically fill in the information of the project name, test data, and picture path.
[0069] The format of the report template in step S1 of this embodiment includes Word documents, PDF documents, and HTML pages.
[0070] When filling the template in step S4 of this embodiment, the information of the project name, test data, and picture path is dynamically filled into the template through the Jinja2 template engine;
[0071] Among them, for Word documents, the docxtpl library is used for template rendering;
[0072] For PDF documents, WeasyPrint or ReportLab is used for generation.
[0073] When generating the report in step S5 of this embodiment, batch report generation is supported, which is applicable to multi-project or multi-test scenarios.
[0074] Embodiment 2:
[0075] This embodiment provides a dynamic test report generation system based on a template engine and an automation tool. The system includes:
[0076] A template management module for creating, editing, and storing report templates;
[0077] A data input and processing module for receiving the project name, test data, and uploaded picture files input by the user;
[0078] A data parsing module for parsing the test data into structured dictionary or list data, and saving the pictures to the specified directory;
[0079] A template filling module for dynamically filling data into a template;
[0080] A report generation module for converting the filled template into final Word document and PDF document report files;
[0081] A report output module for saving the generated report files to a server or directly returning them to the user for downloading.
[0082] The report template in this embodiment is a report template containing placeholders, and the placeholders are used for dynamically filling information such as project names, test data, and picture paths; the formats of the report templates include Word documents, PDF documents, and HTML pages.
[0083] In this embodiment, the template filling module dynamically fills the project name, test data, and picture path information into the template through the Jinja2 template engine; among them, for Word documents, the docxtpl library is used for template rendering; for PDF documents, WeasyPrint or ReportLab is used for generation.
[0084] As shown in the appendix Figure 2 The working process of the system is specifically as follows:
[0085] (1) After the report template is created, check whether the report template document is successfully maintained in the system:
[0086] ① If so, execute step (2);
[0087] ② If not, jump to step (5);
[0088] (2) Determine whether the project name, test data, and picture information are successfully input:
[0089] ① If so, execute step (3);
[0090] ② If not, jump to step (5);
[0091] (3) Parse and analyze the input project name, test data, and picture information, and determine whether the report file is successfully generated:
[0092] ① If so, execute step (4);
[0093] ② If not, jump to step (5);
[0094] (4) Output the report file;
[0095] (5) End.
[0096] Example 3:
[0097] An embodiment of the present invention further provides an electronic device, including: a memory and a processor;
[0098] Wherein, the memory stores computer-executable instructions;
[0099] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the dynamic test report generation method based on a template engine and an automation tool in any embodiment of the present invention.
[0100] The processor may be a central processing unit (CPU), or may also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0101] The memory can be used to store computer programs and / or modules. The processor realizes various functions of the electronic device by running or executing the computer programs and / or modules stored in the memory, and by calling the data stored in the memory. The memory mainly includes a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function, etc.; the data storage area can store data created according to the use of the terminal, etc. In addition, the memory may further include high-speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash memory card, at least one magnetic disk storage period, a flash memory device, or other volatile solid-state storage devices.
[0102] Embodiment 4:
[0103] This embodiment further provides a computer-readable storage medium, in which multiple instructions are stored. The instructions are loaded by the processor, so that the processor executes the dynamic test report generation method based on a template engine and an automation tool in any embodiment of the present invention. Specifically, a system or device equipped with a storage medium can be provided. On the storage medium, software program codes for implementing the functions in any one of the above embodiments are stored, and the computer (or CPU or MPU) of the system or device is made to read and execute the program codes stored in the storage medium.
[0104] In this case, the program code read from the storage medium itself can implement the functions in any one of the above embodiments. Therefore, the program code and the storage medium storing the program code constitute a part of the present invention.
[0105] Examples of storage media for providing program code include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RYM, DVD-RW, DVD+RW), magnetic tapes, non-volatile memory cards, and ROMs. Optionally, the program code can be downloaded from a server computer via a communication network.
[0106] In addition, it should be clear that not only can the functions of any one of the above embodiments be realized by executing the program code read by a computer, but also by causing an operating system or the like operating on the computer to perform part or all of the actual operations based on the instructions of the program code.
[0107] Furthermore, it can be understood that the program code read from the storage medium is written into the memory provided in the expansion board inserted into the computer or into the memory provided in the expansion unit connected to the computer, and then based on the instructions of the program code, the CPU or the like installed on the expansion board or the expansion unit is caused to perform part and all of the actual operations, thereby realizing the functions of any one of the above embodiments.
[0108] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some or all of the technical features; and these modifications or replacements 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 generating a dynamic test report based on a template engine and an automation tool, characterized in that: The method is as follows: Manage Templates: Create, edit and store report templates; Input and process data: receive project names, test data and uploaded image files input by users; Parse data: parse the test data into structured dictionary or list data, and save the image to the specified directory; Fill template: dynamically fill data into the template; Generate report: convert the filled template into the final Word document and PDF document report file; Output report: Save the generated report file to the server or directly return it to the user for download.
2. The method for generating a dynamic test report based on a template engine and an automation tool according to claim 1, characterized in that: The report template contains a placeholder report template, which is used to dynamically fill in the project name, test data, and image path information.
3. The method for generating a dynamic test report based on a template engine and an automation tool according to claim 1, characterized in that: The report template formats include Word documents, PDF documents and HTML pages.
4. The method for generating a dynamic test report based on a template engine and an automation tool according to claim 1, characterized in that: When filling the template, the project name, test data and image path information are dynamically filled into the template through the Jinja2 template engine; Among them, for Word documents, the docxtpl library is used for template rendering; For PDF documents, use WeasyPrint or ReportLab to generate them.
5. The method for generating a dynamic test report based on a template engine and an automation tool according to any one of claims 1 to 4, characterized in that: When generating reports, batch generation of reports is supported, which is suitable for multi-project or multi-test scenarios.
6. A dynamic test report generation system based on template engine and automation tool, characterized in that: The system includes: Template management module, used to create, edit and store report templates; Data input and processing module, used to receive project names, test data and uploaded image files input by users; Data parsing module, used to parse test data into structured dictionary or list data and save the image to the specified directory; Template filling module, used to dynamically fill data into the template; Report generation module, used to convert the filled template into the final Word document and PDF document report file; The report output module is used to save the generated report file to the server or directly return it to the user for download.
7. The dynamic test report generation system based on template engine and automation tool according to claim 6, characterized in that: The report template contains a placeholder report template, which is used to dynamically fill in the project name, test data and image path information; the report template format includes Word document, PDF document and HTML page; The template filling module dynamically fills the project name, test data and image path information into the template through the Jinja2 template engine; for Word documents, the docxtpl library is used for template rendering; for PDF documents, WeasyPrint or ReportLab is used for generation.
8. The dynamic test report generation system based on template engine and automation tool according to claim 6 or 7, characterized in that: The working process of the system is as follows: (1) After the report template is created, is the report template document maintained successfully in the system? ①If yes, proceed to step (2); ②If not, jump to step (5); (2) Determine whether the project name, test data, and image information are successfully entered: ①If yes, proceed to step (3); ②If not, jump to step (5); (3) Parse and analyze the input project name, test data, and image information, and determine whether the report file is successfully generated: ①If yes, proceed to step (4); ②If not, jump to step (5); (4) Output report file; (5)End.
9. An electronic device, characterized in that: include: memory and at least one processor; Wherein, the memory stores a computer program; The at least one processor executes the computer program stored in the memory, so that the at least one processor executes the dynamic test report generation method based on the template engine and automation tool as described in any one of claims 1 to 5.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which can be executed by a processor to implement the method for generating a dynamic test report based on a template engine and an automation tool as described in any one of claims 1 to 5.