Test report generation method and device, computer equipment, readable storage medium and program product

By using the pre-trained screenshot generation model in the CLI environment to convert the test data into picture files, the problem of inefficient screenshot generation of automated test reports in the CLI environment is solved, and efficient generation of automated test reports is achieved.

CN119576792APending Publication Date: 2025-03-07CHINA TELECOM CLOUD TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411768577.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-03-07

AI Technical Summary

Technical Problem

In the CLI environment, it is difficult for the existing technology to realize screenshot generation in automated test reports, resulting in inefficient screenshot generation.

Method used

By receiving test data on the test executor, the pre-trained screenshot generation model is used to convert the test data into picture files, and the picture files are stored in the test data result directory to generate an automated test report.

Benefits of technology

When automated testing in the CLI environment, the automatic generation of test data related screenshots and the output of automated test reports are realized, reducing manual intervention and improving the generation efficiency of test reports.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119576792A_ABST
    Figure CN119576792A_ABST
Patent Text Reader

Abstract

The invention relates to a test report generation method and device, computer equipment, a computer readable storage medium and a computer program product, and relates to the technical field of computers, and the method applied to a test execution machine comprises the steps that when an automatic test trigger instruction is received, a test case is sent to a test machine; receiving test data returned by the test machine and obtained by executing the test case under the character interface; associating each group of execution commands in the test data with corresponding command execution results, naming the test data based on the name of the test case, and storing the test data in a test data result directory; inputting the received test data into a pre-trained screenshot generation model to obtain a picture file, and storing the picture file into a test data result directory; generating an automatic test report based on the command execution result and the picture file in the calling test data result directory; therefore, the generation efficiency of the test report is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a test report generation method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art

[0002] With the widespread use of cloud computing, automated testing technology under cloud hosts has developed rapidly, posing higher challenges to automated test reports. How to enhance the persuasiveness of automated test reports has become the focus of the testing industry. At present, adding screenshots of the test execution process has become an indispensable part of the test report. In the GUI (Graphical User Interface) environment, it is relatively convenient to generate screenshots in automated test reports, which can be quickly generated by combining screenshot tools and automated testing tools; while in the CLI (Command Line Interface) environment, the existing technical solutions mainly rely on manual generation of screenshots, and traditional screenshot automation generation tools cannot be used, which leads to low efficiency in screenshot generation in the CLI environment.

[0003] Therefore, under the CLI, how to generate screenshots becomes a difficult problem that needs to be solved urgently in automated testing. Summary of the invention

[0004] Based on this, it is necessary to provide a test report generation method, apparatus, computer device, computer-readable storage medium and computer program product that can generate screenshots and output test reports including screenshots when performing automated testing under CLI to address the above technical problems.

[0005] In a first aspect, the present application provides a test report generation method, which is applied to a test execution machine, comprising:

[0006] When receiving a trigger instruction for automated testing, the test case is sent to the test machine based on the test scheduler;

[0007] Receiving test data returned by the test machine after executing the test case in a character interface; the test data at least includes at least one set of execution commands and corresponding command execution results associated with the test case;

[0008] Associating each group of the execution commands in the test data with the corresponding command execution results, naming the test data based on the name of the test case, and storing the result in a test data result directory;

[0009] Input the received test data into a pre-trained screenshot generation model to obtain an image file corresponding to the test data, and store the image file in the test data result directory; the image file at least includes the execution command associated with the test case and the corresponding command execution result;

[0010] Generate an automated test report based on calling the command execution results and the image files in the test data result directory.

[0011] In one embodiment, the step of inputting the received test data into a pre-trained screenshot generation model to obtain a picture file corresponding to the test data includes:

[0012] The received test data is input into a pre-trained screenshot generation model, and based on a preset size value of the image file for the screenshot generation model and the length of each row of data in the test data, an image file corresponding to the test data is obtained.

[0013] In one embodiment, the row data of the test data includes a command data row and a result data row; the command data row includes the execution command, and the result data row includes the command execution result;

[0014] The step of obtaining the picture file corresponding to the test data based on the preset size value of the picture file for the screenshot generation model and the length of each row of data in the test data includes:

[0015] When the length of any of the row data in the test data is greater than a preset width value in the preset size value of the image file for the screenshot generation model, intercepting the row data at least once;

[0016] A line break is performed based on at least one interception position to obtain a picture file corresponding to the test data.

[0017] In one of the embodiments, after the line break is performed based on at least one interception position, the method further includes:

[0018] Obtaining the number of rows of the test data, and determining a data height value of the test data based on the number of rows and a character height value of the test data;

[0019] In a case where the data height value is less than or equal to a preset height value in the preset size value, the data height value is determined as the height value of the picture file.

[0020] In one of the embodiments, the test data also includes a command prompt;

[0021] At least part of the command data line includes the command prompt and the associated execution command.

[0022] In one embodiment, the generating of the automated test report based on calling the command execution result and the image file in the test data result directory includes:

[0023] Based on the name of the test case, at least the command execution result and the image file corresponding to the name of the test case are called from the test data result directory to generate an automated test report.

[0024] In a second aspect, the present application further provides a test report generating device, which is applied to a test execution machine, comprising:

[0025] A test trigger module is used to send test cases to the test machine based on the test scheduler when receiving a trigger instruction of the automated test;

[0026] A test data acquisition module, used to receive the test data returned by the test machine after executing the test case in a character interface; the test data at least includes at least one set of execution commands and corresponding command execution results associated with the test case;

[0027] A data processing module, used for associating each group of the execution commands in the test data with the corresponding command execution results, naming the test data based on the name of the test case, and storing the result in a test data result directory;

[0028] An image generation module, used for inputting the received test data into a pre-trained screenshot generation model, obtaining an image file corresponding to the test data, and storing the image file in the test data result directory; the image file at least includes the execution command associated with the test case and the corresponding command execution result;

[0029] The report generation module is used to generate an automated test report based on calling the command execution results and the image files in the test data result directory.

[0030] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0031] When receiving a trigger instruction for automated testing, the test case is sent to the test machine based on the test scheduler;

[0032] Receiving test data returned by the test machine after executing the test case in a character interface; the test data at least includes at least one set of execution commands and corresponding command execution results associated with the test case;

[0033] Associating each group of the execution commands in the test data with the corresponding command execution results, naming the test data based on the name of the test case, and storing the result in a test data result directory;

[0034] Input the received test data into a pre-trained screenshot generation model to obtain an image file corresponding to the test data, and store the image file in the test data result directory; the image file at least includes the execution command associated with the test case and the corresponding command execution result;

[0035] Generate an automated test report based on calling the command execution results and the image files in the test data result directory.

[0036] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:

[0037] When receiving a trigger instruction for automated testing, the test case is sent to the test machine based on the test scheduler;

[0038] Receiving test data returned by the test machine after executing the test case in a character interface; the test data at least includes at least one set of execution commands and corresponding command execution results associated with the test case;

[0039] Associating each group of the execution commands in the test data with the corresponding command execution results, naming the test data based on the name of the test case, and storing the result in a test data result directory;

[0040] Input the received test data into a pre-trained screenshot generation model to obtain an image file corresponding to the test data, and store the image file in the test data result directory; the image file at least includes the execution command associated with the test case and the corresponding command execution result;

[0041] Generate an automated test report based on calling the command execution results and the image files in the test data result directory.

[0042] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:

[0043] When receiving a trigger instruction for automated testing, the test case is sent to the test machine based on the test scheduler;

[0044] Receiving test data returned by the test machine after executing the test case in a character interface; the test data at least includes at least one set of execution commands and corresponding command execution results associated with the test case;

[0045] Associating each group of the execution commands in the test data with the corresponding command execution results, naming the test data based on the name of the test case, and storing the result in a test data result directory;

[0046] Input the received test data into a pre-trained screenshot generation model to obtain an image file corresponding to the test data, and store the image file in the test data result directory; the image file at least includes the execution command associated with the test case and the corresponding command execution result;

[0047] Generate an automated test report based on calling the command execution results and the image files in the test data result directory.

[0048] The above-mentioned test report generation method, device, computer equipment, computer-readable storage medium and computer program product, the test report generation method can be applied to a test execution machine, by sending a test case to the test machine based on a test scheduler when receiving a trigger instruction for automated testing; receiving test data returned by the test machine after executing the test case in a character interface; the test data at least includes at least one group of execution commands and corresponding command execution results associated with the test case; each group of execution commands in the test data is associated with the corresponding command execution results, and the test data is named based on the name of the test case and stored in the test data result directory. directory; input the received test data into the pre-trained screenshot generation model to obtain the image file corresponding to the test data, and store the image file in the test data result directory; the image file at least includes the execution command associated with the test case and the corresponding command execution result; based on calling the command execution result and the image file in the test data result directory, an automated test report is generated; thereby realizing the automatic generation of screenshots related to the test data during automated testing in the CLI environment, and the output of automated test reports including the screenshots, reducing manual intervention, that is, there is no need to manually capture the required screenshots, which is conducive to improving the efficiency of test report generation. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0050] Figure 1 An application environment diagram of a test report generating method in an embodiment;

[0051] Figure 2 A schematic flow chart of a test report generating method according to another embodiment;

[0052] Figure 3 A schematic diagram of simulating a CLI terminal environment in one embodiment;

[0053] Figure 4 A schematic diagram of automated test screenshot generation in one embodiment;

[0054] Figure 5 It is a structural block diagram of a test report generating device in one embodiment;

[0055] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0056] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0057] The test report generation method provided in the present application can be applied to an application scenario that at least includes a test execution machine and a test machine, wherein the application scenario of the test execution machine and the test machine is used to simulate a CLI terminal environment.

[0058] Since there is a lack of automated test screenshot methods in a CLI environment in the relevant technology, the present application provides a test report generation method for automated testing in a Linux cloud host. Specifically, the execution process of test commands is recorded by simulating a CLI terminal environment, and the use case execution process is generated as a test screenshot, that is, a picture file, aiming to solve the problem of low screenshot efficiency in a CLI environment. At the same time, relevant test reports are generated based on picture files, which is conducive to improving the readability of automated test reports.

[0059] In an exemplary embodiment, Figure 1As shown, a test report generation method is provided, which is described by taking the method applied to the above-mentioned test execution machine as an example, and includes the following steps 101 to 105. Among them:

[0060] Step 101: upon receiving a trigger instruction for automated testing, a test case is sent to a test machine based on a test scheduler.

[0061] The trigger instruction of the automated test is an instruction for instructing the automated test to start executing. The test execution machine can be used to trigger the automated test, receive the test data output by the test machine that has executed the automated test, and can also generate an image file based on the test data, and generate a test report including the image file. The test machine can be used to receive test cases and execute the automated test process corresponding to the relevant test cases.

[0062] Among them, a test case refers to a description of a test task for a specific software product, reflecting the test plan, method, technology and strategy. Its content can include test objectives, test environment, input data, test steps, expected results, test scripts, etc., and finally form a document. Simply put, a test case is a set of test inputs, execution conditions and expected results compiled for a special goal, which is used to verify whether a specific software requirement is met. A test case can mainly contain four contents: test case title, preconditions, test steps and expected results. The test case title mainly describes the test of a certain function; the precondition refers to the condition that the test case title needs to meet; the test steps mainly describe the operation steps of the test case; and the expected result refers to the compliance with the expected requirements.

[0063] Exemplarily, when the test execution machine receives a trigger instruction for an automated test triggered by a user, it means that an automated test is to be performed on the associated test machine. At this time, the information on the automated test to be executed can be transmitted to the test scheduler to call the test scheduler to send the test case to the test machine after receiving the test execution action.

[0064] When the test machine receives the test case, it will execute the relevant automated test in the character interface and record the execution commands and results of the case execution process.

[0065] Step 102, receiving the test data returned by the test machine after executing the test case in the character interface; the test data at least includes at least one set of execution commands and corresponding command execution results associated with the test case.

[0066] Among them, the character interface is also known as CLI (Command Line Interface), or it can be called command line interface, which is a user interface that allows users to input commands through the keyboard, and the computer executes them after receiving the commands. Test data refers to the relevant data involved in the process of the test machine executing the test case under CLI and after the execution is completed.

[0067] The test data may include an execution command and a command execution result corresponding to the execution command. The execution command here is used to realize the automatic execution of the relevant test case.

[0068] Exemplarily, after the test executor sends the test case to the test machine based on the test scheduler, it can wait to receive the test data returned by the test machine, specifically the relevant test data obtained by executing the test case in the character interface, or at least the test data including the execution command associated with the test case and the corresponding command execution result.

[0069] Another implementation method is that after the test machine completes the execution of the test case, the test data is uploaded to the test execution machine so that the test execution machine can receive the test data.

[0070] The test execution machine obtains the test data of the relevant test cases executed by the test machine, which is conducive to providing data support for the subsequent generation of relevant test reports.

[0071] Step 103 , associating each group of execution commands in the test data with the corresponding command execution results, naming the test data based on the name of the test case, and storing them in the test data result directory.

[0072] Exemplarily, after the test execution machine receives the test data uploaded by the test machine, it can further associate each group of corresponding execution commands with the corresponding command execution results, that is, associate and match the command execution results corresponding to the execution commands with the execution commands. Furthermore, the test data can be named based on the name of the test case, so that the relevant naming of the test data includes the name of the corresponding test case, and then the named test data is stored in a specified path, such as in the test data result directory, which is convenient for the accuracy of subsequent screenshot generation and also helps to improve the readability of subsequent screenshots.

[0073] Among them, the test data result directory is only provided by this application, and is a name for a storage location in an optional path, but this application is not limited to this.

[0074] Step 104, input the received test data into the pre-trained screenshot generation model, obtain the image file corresponding to the test data, and store the image file in the test data result directory; the image file at least includes the execution command associated with the test case and the corresponding command execution result.

[0075] Among them, the screenshot generation model is used to control the specific regulation involved in the generation of relevant image files, so as to generate image files with good quality and good readability.

[0076] Exemplarily, the test executor may further input the received test data into a pre-trained screenshot generation model to obtain the image file corresponding to the test data under the CLI with the help of the screenshot generation model, and store the image file in the above-mentioned test data result directory, so that the test data and the image files related to the test data can be stored in the same path, which is convenient for the rapid and accurate extraction of the test data and the image files when the test data and the corresponding image files are needed in the future.

[0077] Regarding the information included in the image file, the present application provides an optional implementation method that includes at least the execution commands for the test case under the CLI and the corresponding command execution results, and includes all execution commands for the test case and the corresponding command execution results.

[0078] It should also be added that the received test data is input into the pre-trained screenshot generation model to obtain the image files corresponding to the test data, which can be one or multiple images; that is, the screenshot generation model may output one image file or multiple image files. The image files here can be understood as screenshot images.

[0079] Step 105: Generate an automated test report based on the command execution results and image files in the test data result directory.

[0080] The automated test report is a file that displays the process of executing test cases on the test machine and the test results.

[0081] Exemplarily, when the test data associated with the test case and the corresponding image files are stored simultaneously in the test data result directory, the test execution machine can further generate an automated test report of the test machine executing the relevant test cases based on the command execution results and image files in the test data result directory.

[0082] In the test report generation method applied to the test execution machine, upon receiving the trigger instruction of the automated test, the test case is sent to the test machine based on the test scheduler; the test data obtained by executing the test case in the character interface sent back by the test machine is received; the test data at least includes at least one group of execution commands and corresponding command execution results associated with the test case; each group of execution commands in the test data and the corresponding command execution results are associated, and the test data is named based on the name of the test case and stored in the test data result directory; the received test data is input into the pre-trained screenshot generation model to obtain the image file corresponding to the test data, and the image file is stored in the test data result directory; the image file at least includes the execution command associated with the test case and the corresponding command execution result; based on calling the command execution result and the image file in the test data result directory, an automated test report is generated; thereby realizing the automatic generation of screenshots related to the test data during automated testing in the CLI environment, and the output of automated test reports including the screenshots, reducing manual intervention, that is, there is no need to manually capture the required screenshots, which is beneficial to improving the efficiency of test report generation.

[0083] In an exemplary embodiment, the above step 104 is executed by inputting the received test data into a pre-trained screenshot generation model to obtain a picture file corresponding to the test data. It can be optionally executed as follows: inputting the received test data into a pre-trained screenshot generation model, and obtaining a picture file corresponding to the test data based on a preset size value for the picture file of the screenshot generation model and the length of each line of data in the test data.

[0084] Exemplarily, the test execution machine may further input the received test data into the pre-trained screenshot generation model, so as to obtain the final one or more picture files corresponding to the test data under the CLI by using the preset size value of the picture file set by the screenshot generation model and combining the length of each line of data in the test data. This helps to avoid the integrity of the test data displayed in the picture file.

[0085] The row data of the test data, that is, a row of data in the test data; for the row data, the present application provides an optional implementation mode, the row data of the test data includes a command data row and a result data row; the command data row includes an execution command, and the result data row includes a command execution result; that is, there is a type of row data that includes an execution command, and there is another type of row data that includes a command execution result; wherein the execution command and the command execution result are located in different (data) rows under the CLI interface.

[0086] Based on this, in an exemplary embodiment, for the above steps, based on the preset size value of the image file of the screenshot generation model and the length of each row of data in the test data, the image file corresponding to the test data is obtained, and the following can be selected to be executed:

[0087] When the length of any row of data in the test data is greater than a preset width value in a preset size value of the image file for the screenshot generation model, the row of data is intercepted at least once;

[0088] A line break is performed based on at least one interception position to obtain an image file corresponding to the test data.

[0089] Exemplarily, the length of each line of data in the test data is obtained, and the length of each line of data is compared with the preset width value in the preset size value of the image file of the screenshot generation model. When the length of the line of data is greater than the preset width value of the image file, if the line of data is not processed, all data information included in the line of data cannot be displayed in the corresponding generated image file, and data missing will occur.

[0090] Therefore, the present application provides an optional implementation method, in which, when the comparison result is that the length of the line data is greater than the preset width value of the image file, the line data is truncated, wherein the truncation position can be one or more, and then, based on the one or more truncation positions corresponding to the line data, the line data is wrapped, so that the line data with excessive length can be processed as two lines or multiple lines in the subsequently generated image file, thereby avoiding data missing in the image file and ensuring the accuracy of the image file.

[0091] It should also be added that when a row of data is intercepted twice, it does not mean that the row of data should be processed as three rows in the image file. The row of data can also be processed as two rows in the image file based on demand, as long as the row of data is not missing in the image file. The interception position for line breaks can be determined based on the specific content of the row of data to improve the readability of the row of data. For example, line breaks can be selected between different types of data.

[0092] It should also be added that, for example, after a row of data is truncated and wrapped once, first sub-row data and second sub-row data arranged in two rows are obtained. Among them, when the length of the first sub-row data is less than the preset width value of the image file, but the length of the second sub-row data is still greater than the preset width value of the image file, the second sub-row data can be further truncated and wrapped until the row of data is no longer larger than the preset width value of the image file, thereby ensuring the accuracy of the information displayed in the image file.

[0093] In an exemplary embodiment, after the above-mentioned line break based on at least one interception position is performed, further steps may include:

[0094] Obtain the number of rows of the test data, and determine the data height value of the test data based on the number of rows and the character height value of the test data;

[0095] When the data height value is less than or equal to a preset height value in the preset size value, the data height value is determined as the height value of the picture file.

[0096] For example, after wrapping all lines of data that are too long in the test data, that is, when a picture file with no missing data can be generated based on the test data after the line wrapping process, you can choose to directly output the relevant picture file, but the height of the directly generated picture file may be too high, which is very different from the screenshot in the ordinary sense.

[0097] Therefore, the present application also provides an optional implementation method. After all line data that are too long in the test data are wrapped, that is, when an image file without missing data can be generated based on the test data after the line wrapping processing, the total number of lines of the test data can be further obtained, and then based on the total number of lines and the character height value of the test data, the data height values ​​corresponding to all data included in the test data are determined, and then, the data height value corresponding to the test data is compared with the preset height value in the preset size value for the image file. When the comparison result is that the data height value is less than or equal to the preset height value in the preset size value, the data height value is determined as the height value of the image file. Based on this, the output image file is more like an image file obtained by manual screenshot, thereby reducing the difference between screenshots in the ordinary sense.

[0098] Furthermore, after comparing the data height value corresponding to the test data with the preset height value in the preset size value for the image file, if the comparison result is that the data height value is greater than the preset height value of the image file, the test data can be split into two image files or multiple image files for output. In two adjacent image files, it can be selected that there is a row of data that is the same, that is, the last row of data of the previous image file is the first row of data of the next image file; it can also be selected that there is no duplication of data rows in two adjacent image files, that is, the next row of data of the last row of data of the previous image file is the first row of data of the next image file.

[0099] In an exemplary embodiment, the test data further includes a command prompt; and at least a portion of the command data lines include the command prompt and an associated execution command.

[0100] Exemplarily, the command data row can be optionally set to include a command prompt and an associated execution command, while the result data row includes the command execution result; that is, there is one type of row data that includes a command prompt and an execution command, and there is another type of row data that includes a command execution result; wherein the command prompt and the execution command are located in a data row under the CLI interface, and the corresponding matching command execution result is located in another data row under the CLI interface.

[0101] Among them, in the command data line, the command prompt can be located before the corresponding execution command, for example, the command prompt is located on the left side of the corresponding execution command. However, this is only an optional implementation method provided by the present application, and the present application is not limited thereto.

[0102] In an exemplary embodiment, the above step 105, based on calling the command execution results and image files in the test data result directory, generates an automated test report, which can be selectively performed as follows: based on the name of the test case, at least the command execution results and image files corresponding to the name of the test case are called from the test data result directory to generate an automated test report. This is conducive to improving the convenience and accuracy of extracting command execution results and image files, and also conducive to improving the accuracy of the automated test report finally generated.

[0103] For the test report generation method provided in this application, an optional implementation method is also provided, such as Figure 2 As shown, the following steps 301 to 306 are included, wherein:

[0104] Step 301, triggering a test on a test execution machine;

[0105] Step 302: After receiving the test execution action, the test scheduler sends the test case (script) to the test machine;

[0106] Step 303, the test machine records the execution commands and results of the test case execution process according to the test case;

[0107] Step 304, after the use case is executed, the test machine uploads the test data to the test execution machine;

[0108] Step 305, the test execution machine fills the received test data into the screenshot generation device, generates a picture file of a specified format according to the recorded operation results, and saves it to the directory of the use case results;

[0109] Step 306: Generate an automated test report based on the execution results of the test script and the generated screenshot file.

[0110] For further information, please refer to Figure 3 and Figure 4 The test report generation method provided in the present application also provides an optional implementation method, including two processes of simulating a CLI terminal environment and a screenshot generation device, wherein:

[0111] The first step is to simulate the CLI terminal environment:

[0112] like Figure 3 As shown in the simulation of the CLI terminal environment, automated testing is performed under the Linux system, and the execution results of the commands are used to determine whether they are consistent with expectations; the screenshot range is the entire area of ​​the commands and execution results. During automated testing in the CLI environment, the execution commands and execution results of the use cases are recorded, and the content required for the screenshot is generated by simulating the terminal environment, thereby realizing automatic generation of screenshots, reducing manual intervention, and improving operational efficiency.

[0113] The content displayed in the Linux command line mainly consists of the terminal prompt, input commands, and the output of the executed commands. The display format of the Linux command prompt can be expressed as ,in:

[0114] Indicates the username of the currently logged in user, which can be accessed through the built-in command get;

[0115] Indicates the host name of the current host, which can be accessed through the built-in command get;

[0116] Indicates the current directory, through the built-in command get;

[0117] represents the prompt for a normal user, and Indicates the superuser (root) prompt.

[0118] In the actual CLI interactive interface, the terminal prompt and the executed command are displayed in the same line, and the command execution result is displayed in a new line; let the test command be recorded as , the execution result is recorded as , the data content of a command in the CLI interactive environment is recorded as ,but .

[0119] In automated testing, each test case may execute more than one command. Therefore, the metadata of the screenshot is a collection of multiple commands and their execution results. Let the metadata of the screenshot be ,but .

[0120] At the same time, it is necessary to associate the command and the command execution result record, store it in the specified path, and name it with the name of the test case to facilitate subsequent screenshot generation.

[0121] The second process, screenshot generation device:

[0122] like Figure 4 As shown in the automated test screenshot generation, the device generates screenshot metadata based on the screenshot Generate a screenshot of the use case. The specific implementation process is as follows:

[0123] Define the canvas size and unify the size of the screenshot. The size of the canvas is the primary control condition for screenshot generation, which can be determined by the width. and height (Unit is pixel ). Generally, the width and height of the screenshot are determined by the screen size of the automated test execution machine. and height .

[0124] In order to more realistically simulate the terminal output display under CLI, the metadata of the screenshot needs to be considered The actual length of each line in the text file to avoid incomplete content on the screenshot. The content of Bank of China is , the length of the line content is recorded as ,but , ;in The number of rows of metadata. The length of a line in the screenshot metadata is determined by pixels, while the length of a line in the screenshot metadata is determined by characters. Pixels and characters have different meanings in their respective fields, and there is no direct one-to-one correspondence between the two. In general, a character The font size can be set to 16 pixels, that is , then the relationship between the width of the canvas and the character is ; means that each line on the canvas can display a maximum of 100 characters; if the line length , the row content remains the same; , the line content needs to be intercepted; if is the number of times each line of content needs to be intercepted, then ; In the first character of the line that meets the interception condition Insert the line break character " ", the line content after interception can be expressed as , determine the height of the canvas according to the number of rows of metadata, that is, ; Use the program's image generation tool to generate screenshots, save them in png format, and name them after the test case to facilitate matching with the execution results.

[0125] It can be seen that the test report generation method provided by the present application does not require a graphical user interface (GUI), and can perform automatic test screenshot generation under the character interface CLI. It does not rely on GUI and manual screenshot operations, thereby expanding the application scenarios of automatic test screenshots. It has good flexibility, that is, it supports custom settings of operating conditions for triggering screenshots, which can be flexibly set according to test requirements. It has the advantage of high integration, that is, it realizes automatic test screenshot generation by recording the operation process in the terminal environment, and has high integration and extensibility with automated testing tools.

[0126] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0127] Based on the same inventive concept, the embodiment of the present application also provides a test report generation device for implementing the test report generation method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more test report generation device embodiments provided below can refer to the limitations of the test report generation method above, and will not be repeated here.

[0128] In an exemplary embodiment, Figure 5 As shown, a test report generating device 800 is provided, comprising: a test triggering module 81, a test data acquiring module 82, a data processing module 83, an image generating module 84 and a report generating module 85, wherein:

[0129] A test trigger module 81 is used to send a test case to a test machine based on a test scheduler when a trigger instruction of an automated test is received;

[0130] The test data acquisition module 82 is used to receive the test data returned by the test machine after executing the test case in the character interface; the test data at least includes at least one set of execution commands and corresponding command execution results associated with the test case;

[0131] The data processing module 83 is used to associate each group of execution commands in the test data with the corresponding command execution results, name the test data based on the name of the test case, and store them in the test data result directory;

[0132] The image generation module 84 is used to input the received test data into the pre-trained screenshot generation model, obtain the image file corresponding to the test data, and store the image file in the test data result directory; the image file at least includes the execution command associated with the test case and the corresponding command execution result;

[0133] The report generation module 85 is used to generate an automated test report based on the command execution results and image files in the test data result directory.

[0134] In an exemplary embodiment, the image generation module 84 is used to input the received test data into a pre-trained screenshot generation model to obtain an image file corresponding to the test data. Specifically, it is used to: input the received test data into a pre-trained screenshot generation model, and based on the preset size value of the image file for the screenshot generation model and the length of each line of data in the test data, obtain the image file corresponding to the test data.

[0135] In an exemplary embodiment, the row data of the test data includes a command data row and a result data row; the command data row includes an execution command, and the result data row includes a command execution result; the image generation module 84 is used to obtain the image file corresponding to the test data based on the preset size value of the image file for the screenshot generation model and the length of each row of data in the test data, and is specifically used to: when the length of any row of data in the test data is greater than the preset width value in the preset size value of the image file for the screenshot generation model, intercept the row of data at least once; and wrap the line based on at least one interception position to obtain the image file corresponding to the test data.

[0136] In an exemplary embodiment, after the image generation module 84 is used to perform line breaks based on at least one clipping position, it is also used to: obtain the number of lines of the test data, and determine the data height value of the test data based on the number of lines and the character height value of the test data; when the data height value is less than or equal to a preset height value in the preset size value, determine the data height value as the height value of the image file.

[0137] In an exemplary embodiment, the test data further includes a command prompt; and at least a portion of the command data lines include the command prompt and an associated execution command.

[0138] In an exemplary embodiment, the report generation module 85 is used to generate an automated test report based on calling the command execution results and image files in the test data result directory, and is specifically used to: based on the name of the test case, at least call the command execution results and image files corresponding to the name of the test case from the test data result directory to generate an automated test report.

[0139] Each module in the above-mentioned test report generation device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0140] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal. The terminal may be, for example, at least one of the test execution machine or the test machine described in the present application. The internal structure diagram thereof may be as follows: Figure 6As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, a test report generation method is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.

[0141] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0142] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:

[0143] When receiving a trigger instruction for automated testing, the test case is sent to the test machine based on the test scheduler;

[0144] The test data returned by the receiving test machine is obtained by executing the test case in the character interface; the test data at least includes at least one set of execution commands and corresponding command execution results associated with the test case;

[0145] Associating each group of execution commands in the test data with the corresponding command execution results, naming the test data based on the name of the test case, and storing them in the test data result directory;

[0146] Input the received test data into the pre-trained screenshot generation model to obtain an image file corresponding to the test data, and store the image file in the test data result directory; the image file at least includes an execution command associated with the test case and a corresponding command execution result;

[0147] Generate an automated test report based on the command execution results and image files in the test data result directory.

[0148] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0149] When receiving a trigger instruction for automated testing, the test case is sent to the test machine based on the test scheduler;

[0150] The test data returned by the receiving test machine is obtained by executing the test case in the character interface; the test data at least includes at least one set of execution commands and corresponding command execution results associated with the test case;

[0151] Associating each group of execution commands in the test data with the corresponding command execution results, naming the test data based on the name of the test case, and storing them in the test data result directory;

[0152] Input the received test data into the pre-trained screenshot generation model to obtain an image file corresponding to the test data, and store the image file in the test data result directory; the image file at least includes an execution command associated with the test case and a corresponding command execution result;

[0153] Generate an automated test report based on the command execution results and image files in the test data result directory.

[0154] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:

[0155] When receiving a trigger instruction for automated testing, the test case is sent to the test machine based on the test scheduler;

[0156] The test data returned by the receiving test machine is obtained by executing the test case in the character interface; the test data at least includes at least one set of execution commands and corresponding command execution results associated with the test case;

[0157] Associating each group of execution commands in the test data with the corresponding command execution results, naming the test data based on the name of the test case, and storing them in the test data result directory;

[0158] Input the received test data into the pre-trained screenshot generation model to obtain an image file corresponding to the test data, and store the image file in the test data result directory; the image file at least includes an execution command associated with the test case and a corresponding command execution result;

[0159] Generate an automated test report based on the command execution results and image files in the test data result directory.

[0160] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0161] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0162] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0163] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A test report generation method, characterized in that: Applied to a test execution machine, the method comprises: When receiving a trigger instruction for automated testing, the test case is sent to the test machine based on the test scheduler; Receiving test data returned by the test machine after executing the test case in a character interface; the test data at least includes at least one set of execution commands and corresponding command execution results associated with the test case; Associating each group of the execution commands in the test data with the corresponding command execution results, naming the test data based on the name of the test case, and storing the result in a test data result directory; Input the received test data into a pre-trained screenshot generation model to obtain an image file corresponding to the test data, and store the image file in the test data result directory; the image file at least includes the execution command associated with the test case and the corresponding command execution result; Generate an automated test report based on calling the command execution results and the image files in the test data result directory.

2. The method according to claim 1, characterized in that The step of inputting the received test data into a pre-trained screenshot generation model to obtain a picture file corresponding to the test data includes: The received test data is input into a pre-trained screenshot generation model, and based on a preset size value of the image file for the screenshot generation model and the length of each row of data in the test data, an image file corresponding to the test data is obtained.

3. The method according to claim 2, characterized in that The row data of the test data includes a command data row and a result data row; the command data row includes the execution command, and the result data row includes the command execution result; The step of obtaining the picture file corresponding to the test data based on the preset size value of the picture file for the screenshot generation model and the length of each row of data in the test data includes: When the length of any of the row data in the test data is greater than a preset width value in the preset size value of the image file for the screenshot generation model, intercepting the row data at least once; A line break is performed based on at least one interception position to obtain a picture file corresponding to the test data.

4. The method according to claim 3, characterized in that After the line breaking is performed based on at least one interception position, the method further includes: Obtaining the number of rows of the test data, and determining a data height value of the test data based on the number of rows and a character height value of the test data; In a case where the data height value is less than or equal to a preset height value in the preset size value, the data height value is determined as the height value of the picture file.

5. The method according to claim 3, characterized in that: The test data also includes a command prompt; At least part of the command data line includes the command prompt and the associated execution command.

6. The method according to claim 1, characterized in that The step of generating an automated test report based on calling the command execution result and the image file in the test data result directory includes: Based on the name of the test case, at least the command execution result and the image file corresponding to the name of the test case are called from the test data result directory to generate an automated test report.

7. A test report generating device, characterized in that: Applied to a test execution machine, the device comprises: A test trigger module is used to send test cases to the test machine based on the test scheduler when receiving a trigger instruction of the automated test; A test data acquisition module, used to receive the test data returned by the test machine after executing the test case in a character interface; the test data at least includes at least one set of execution commands and corresponding command execution results associated with the test case; A data processing module, used for associating each group of the execution commands in the test data with the corresponding command execution results, naming the test data based on the name of the test case, and storing the result in a test data result directory; An image generation module, used for inputting the received test data into a pre-trained screenshot generation model, obtaining an image file corresponding to the test data, and storing the image file in the test data result directory; the image file at least includes the execution command associated with the test case and the corresponding command execution result; The report generation module is used to generate an automated test report based on calling the command execution results and the image files in the test data result directory.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Function test method and system for automatic driving hardware platform

    CN115480963A

  • Method and device for automatically testing convergence and distribution equipment

    CN117785585A

  • Interactive automatic-test GUI for testing devices and equipment using shell-level, CLI, and SNMP commands

    US20030191590A1

  • Test report generating method, apparatus and device, and storage medium

    WO2019218444A1