An automated testing method, platform, device, and storage medium
By generating graphical reports through automated testing methods, the problem of unintuitive test results in gtest code is solved, the testing process is simplified, and efficiency is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- YUNHE ZHIWANG (SHANGHAI) TECHNOLOGY CO LTD
- Filing Date
- 2022-11-14
- Publication Date
- 2026-05-05
AI Technical Summary
In existing technologies, the test results of gtest code cannot be displayed intuitively and cannot retain historical test results, resulting in a complex and time-consuming testing process.
This paper provides an automated testing method that obtains test cases, generates a pytest file, executes and asserts the results, generates a graphical test report, and sends the report to a specified address.
It enables intuitive display of test results and retention of historical results, simplifies the testing process, and improves testing efficiency and understandability.
Smart Images

Figure CN115904962B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of software testing technology, and in particular to an automated testing method, platform, device and storage medium. Background Technology
[0002] With the development of computer software technology, the speed of software system function iteration and release is getting faster and faster, the version release cycle is getting shorter and shorter, and the system is becoming more and more complex. As a result, software quality is gradually gaining importance among users, making software testing, as a way to ensure software quality, even more crucial. In the chip development process, testing the functionality of the software can confirm whether the code meets user needs, improve software quality and ensure software security, and also reduce software development costs and business risks.
[0003] The inventors discovered that current SDK testing suffers from at least the following problems: Existing technologies require testers to manually perform multiple tests and summarize the data, making the testing process complex and time-consuming; while the gtest unit testing framework is commonly used when testing SDKs, the output results can only be displayed on the terminal, which is not intuitive for developers and does not allow them to view historical results, making it difficult for customers to view them. Summary of the Invention
[0004] The purpose of this invention is to provide an automated testing method, platform, device, and storage medium, which aims to solve the technical problems in the prior art where the test results of gtest code cannot be displayed intuitively and cannot retain historical test results.
[0005] To achieve the above objectives, the present invention provides an automated testing method, which includes the following steps:
[0006] Obtain at least one test case;
[0007] Obtain the automation script and generate the corresponding pytest file for the test cases based on the automation script;
[0008] Execute the pytest file to get the actual execution results;
[0009] Assertions are made on the expected results and the actual execution results to obtain the test results;
[0010] A graphical test report is generated based on the test results.
[0011] Preferably, it further includes:
[0012] Set up the test environment;
[0013] The specific steps involved in setting up the test environment are as follows:
[0014] Install Python 3.8;
[0015] Install automation scripts, Allure tools, and Jinja2 templates;
[0016] Verify the installed program.
[0017] Preferably, the process involves obtaining an automated script and generating a pytest file corresponding to the test cases based on the automated script, specifically including:
[0018] The test cases are compiled using CMake to generate executable files; the test cases are gtest files.
[0019] The automated script calls the executable file and then passes in the jinja2 template to generate the corresponding gtest file pytest; the automated script is a Python script, and the pytest file corresponds to the gtest file name.
[0020] Preferably, the execution result includes execution success and execution failure; the expected result and the actual execution result are asserted, and if the assertion is successful, the test case is marked as passed, and if the assertion fails, the test case is marked as failed.
[0021] Preferably, in the graphical test report, different test results are marked with different colors; and the test report includes the test pass rate, output and print information during the pytest file test process, and historical test results.
[0022] Preferably, the graphical test report is sent to a designated address.
[0023] Preferably, after obtaining the automation script and generating the corresponding pytest file for the test cases based on the automation script, the method further includes:
[0024] Automatically count the number of pytest files generated;
[0025] The test results also include the start time of the test cases and the duration of the test.
[0026] This invention also provides an automated testing platform, which includes:
[0027] The test case management module is used to obtain at least one test case to be tested;
[0028] The test case processing module is used to obtain automated scripts and generate pytest files corresponding to the test cases based on the automated scripts.
[0029] The execution module is used to execute the pytest file and obtain the actual execution results;
[0030] The assertion module is used to assert the expected results and the actual execution results to obtain the test results;
[0031] The test report module generates graphical test reports based on the test results.
[0032] This invention also provides an automated testing device, which includes a memory and a processor. The memory stores a computer program that can be executed by the processor to implement the automated testing method described above.
[0033] This invention also provides a computer-readable storage medium storing a computer program that can be executed by a processor of the device in which the computer-readable storage medium is located, to implement the automated testing method described above.
[0034] In one embodiment described above, test cases are created and tested. After the tests are completed, expected and actual execution results are generated. Assertions are then made on the expected and actual results. If the assertion is successful, the test case is marked as passed; if the assertion fails, the test case is marked as failed. A corresponding test report is generated and sent to the relevant personnel via email, enabling rapid generation of test reports and feedback of test results. This embodiment is easier for testers to understand and is simpler than existing technologies, making it a simple automated testing framework. Attached Figure Description
[0035] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly described below.
[0036] Figure 1 This is a flowchart illustrating an automated testing method provided in the first embodiment of the present invention.
[0037] Figure 2 This is a schematic diagram of the results of an automated testing device provided in the second embodiment of the present invention. Detailed Implementation
[0038] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the various embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0039] Please see Figure 1 The first embodiment of the present invention provides an automated testing method applied to an automated testing platform. The automated testing method of this embodiment includes:
[0040] S101, Obtain at least one test case.
[0041] Specifically, in this embodiment, the first step is to set up a test environment on the automated testing platform. This setup includes installing Python 3.8, automation scripts (Python scripts), the Allure tool, and the Jinja2 module. Finally, the installed programs are verified, thus completing the test environment setup.
[0042] In this embodiment, the test cases to be tested can be gtest files. All test cases can be obtained through inherent test commands, or a portion of the test cases can be selected by choosing the corresponding command filter.
[0043] In this embodiment, the which and show commands can be used for verification, but it is not limited to these.
[0044] S102, Obtain the automation script, and generate the pytest file corresponding to the test cases based on the automation script.
[0045] In this embodiment:
[0046] First, CMake is called to compile the test cases and generate executable files.
[0047] Specifically, compiling the gtest file with cmake will generate the corresponding executable file for the test in the build directory.
[0048] Then, the executable file is called in the automation script, and the jinja2 template is passed in to generate the corresponding gtest file pytest file.
[0049] It should be noted that the pytest file corresponds to the gtest file.
[0050] S103, execute the pytest script and obtain the actual execution result.
[0051] S104 asserts the expected results and the actual execution results to obtain the test results.
[0052] In this embodiment, the pytest file can be run using the Allure tool to generate the actual execution results. These results include both successful and failed executions. Then, assertions are made on the expected and actual results; if the assertion succeeds, the test case is marked as passed; if the assertion fails, the test case is marked as failed.
[0053] S105 generates a graphical test report based on the test results.
[0054] Specifically, after all pytest files have been executed, a graphical test report is generated based on the test results. Different test results are marked with different colors; for example, a test passed is marked in green, a test failed in red, and a test not executed is marked in yellow. Of course, it should be noted that the actual marking colors can be set according to the actual situation, and this invention does not impose specific limitations.
[0055] In this embodiment, the test report may also include the test pass rate, output print information during the pytest file test process, and historical test results.
[0056] The content of the generated test report can be defined according to actual needs, and this invention does not impose specific limitations.
[0057] Step 106: Send the test results to the specified address.
[0058] In this embodiment, based on the generated test report, the number of each test result is counted, and the results are sent in document format to a designated address, such as a designated email address or an enterprise DingTalk group. Specifically, the sent document information must indicate the corresponding test case name.
[0059] In addition, when generating test reports, the corresponding test cases can be obtained, the pass rate of automated tests can be calculated, and the names of the test cases can be obtained, thereby linking the requirements with the test reports.
[0060] In summary, by creating and testing test cases, generating expected and actual execution results after testing, and then asserting on the expected and actual results, the test case is marked as passed if the assertion is successful and marked as failed if the assertion fails. A corresponding test report is generated and sent to the relevant personnel via email, enabling rapid test report generation and feedback of test results. This embodiment is easier for testers to understand and simpler than existing technologies, making it a simple automated testing framework.
[0061] The following provides a further description of some preferred embodiments of the present invention.
[0062] Preferably, after obtaining the automation script and generating the corresponding pytest file for the test cases based on the automation script, the method further includes:
[0063] Automatically count the number of pytest files generated;
[0064] The test results also include the start time of the test cases and the duration of the test.
[0065] Compared to the first embodiment, the automated script in this embodiment can automatically calculate the number of pytest files generated; at the same time, the test results include the test case start time and test duration.
[0066] Please see Figure 2 The second embodiment of the present invention also provides an automated testing platform, which includes:
[0067] Test case management module 210 is used to obtain at least one test case;
[0068] The test case processing module 220 is used to obtain the automation script and generate the corresponding pytest file for the test case based on the automation script;
[0069] Execution module 230 is used to execute the pytest file and obtain the actual execution results;
[0070] The assertion module 240 is used to assert the expected results and the actual execution results to obtain the test results;
[0071] Test report module 250 generates graphical test reports based on test results.
[0072] The third embodiment of the present invention also provides an automated testing device, which includes a memory and a processor. The memory stores a computer program, which can be executed by the processor to implement the automated testing method described above.
[0073] The fourth embodiment of the present invention also provides a computer-readable storage medium storing a computer program that can be executed by a processor of the device in which the computer-readable storage medium is located, so as to implement the automated testing method described above.
[0074] Although the present invention has been described in detail through the preferred embodiments above, it should be understood that the above description should not be considered as a limitation of the present invention. Various modifications and substitutions to the present invention will be apparent to those skilled in the art after reading the above description. Therefore, the scope of protection of the present invention should be defined by the appended claims.
Claims
1. An automated testing method, characterized in that, Includes the following steps: Obtain at least one test case; Obtain the automation script and generate the corresponding pytest file for the test cases based on the automation script; specifically: call cmake to compile the test cases and generate an executable file; the test cases are gtest files; call the executable file in the automation script, and then pass in the jinja2 template to generate the corresponding pytest file for the gtest file; wherein the automation script is a Python script, and the pytest file corresponds to the gtest file name; Execute the pytest file to get the actual execution results; Assertions are made on the expected results and the actual execution results to obtain the test results; A graphical test report is generated based on the test results.
2. The automated testing method according to claim 1, characterized in that, Also includes: Set up the test environment; The specific steps involved in setting up the test environment are as follows: Install Python 3.8; Install automation scripts, Allure tools, and Jinja2 templates; Verify the installed program.
3. The automated testing method according to claim 1, characterized in that, The execution results include successful execution and execution failure; assertions are made on the expected results and the actual execution results. If the assertion is successful, the test case is marked as passed; if the assertion fails, the test case is marked as failed.
4. The automated testing method according to claim 1, characterized in that, In the graphical test report, different test results are marked with different colors; and the test report includes the test pass rate, the output and print information during the pytest file test process, and historical test results.
5. The automated testing method according to claim 1, characterized in that, Also includes: Send the graphical test report to the specified address.
6. The automated testing method according to claim 1, characterized in that, After obtaining the automation script and generating the corresponding pytest file for the test cases based on the automation script, the process also includes: Automatically count the number of pytest files generated; The test results also include the start time of the test cases and the duration of the test.
7. An automated testing platform, characterized in that, include: The test case management module is used to obtain at least one test case to be tested; The test case processing module is used to obtain an automated script and generate a pytest file corresponding to the test cases based on the automated script. Specifically, it calls cmake to compile the test cases and generate an executable file; the test cases are gtest files; the automated script calls the executable file and then passes in the jinja2 template to generate the pytest file corresponding to the gtest file; the automated script is a Python script, and the pytest file corresponds to the gtest file. The execution module is used to execute the pytest file and obtain the actual execution results; The assertion module is used to assert the expected results and the actual execution results to obtain the test results; The test report module generates graphical test reports based on the test results.
8. An automated testing device, characterized in that, It includes a memory and a processor, wherein the memory stores a computer program that can be executed by the processor to implement the automated testing method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Instruction set batch testing device and method for processor
CN102567164A
Automatic testing method and storage medium
CN113868140A
Software automation test system and method
CN114691489A