Batch processing automated test method, device, computer equipment and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- IND BANK CO
- Filing Date
- 2023-02-08
- Publication Date
- 2026-08-07
AI Technical Summary
[0004]但上述两种方法的测试能力有限,不能满足批处理的自动化测试需求
[0066]上述批处理自动化测试方法、装置、计算机设备、存储介质和计算机程序产品,对于业务逻辑批处理的测试用例自动化执行,得到自动化测试执行结果,将自动化测试执行结果和期望执行结果从用例级文件的信息、内容摘要和内容这三个层级,由粗至细依次进行比较,在用例级文件的信息、内容摘要和内容这三个层次均一致时,才确定自动化测试执行结果符合期望执行结果,相对应的,若在由粗至细的三个层次的比较中,在当前层次比较不一致时,可确定自动化测试执行结果不符合期望执行结果,无需进入下一次层更精细度的比较。该方法不仅可以实现业务逻辑批处理的自动化测试,还能够对于自动化测试执行结果是否符合预期进行自动判断,测试人员只需要准备测试用例和测试配置参数,整个过程无需人工参与,实现了业务逻辑批处理测试的低代码化,提高了批处理测试的处理效率。
Smart Images

Figure CN116361149B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of testing technology, and in particular to a batch automated testing method, apparatus, computer equipment, storage medium, and computer program product. Background Technology
[0002] With the development of smart terminals and internet technology, people's lives are becoming increasingly inseparable from a wide variety of applications (APPs). Testing is a crucial step in the application development process, allowing for the early detection of problems.
[0003] To improve testing efficiency, automated testing methods have emerged. Common automated testing methods include code-driven testing and graphical user interface (GUI) testing. Code-driven testing typically tests the public (usually) interfaces of classes, modules, or libraries using various input parameters to verify that the returned results are correct. GUI testing, on the other hand, uses a testing framework to generate user interface events, such as keystrokes and mouse clicks, and observes the changes that result in changes to the user interface to verify that the program's observable behavior is correct.
[0004] However, the testing capabilities of the two methods mentioned above are limited and cannot meet the needs of automated batch testing. Summary of the Invention
[0005] Therefore, it is necessary to provide a batch processing automated testing method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can meet the automated testing needs of batch processing and improve testing efficiency in response to the above-mentioned technical problems.
[0006] Firstly, this application provides a batch automated testing method. The method includes:
[0007] Obtain test cases and test configuration parameters for batch processing of business logic;
[0008] The test cases of the business logic batch processing are executed according to the test configuration parameters to obtain the automated test execution results;
[0009] Obtain the expected execution result;
[0010] The information in the test case-level file is compared with the results of the automated test execution and the expected results.
[0011] If the information in the test case-level file of the automated test execution result is consistent with the expected execution result, then the content summaries of the automated test execution result and the expected execution result are compared.
[0012] If the content summary of the automated test execution result is consistent with the expected execution result, then the content of the automated test execution result and the expected execution result are compared.
[0013] If the content of the automated test execution result is consistent with the expected execution result, then it is determined that the automated test execution result conforms to the expected execution result.
[0014] In one embodiment, the information in the use case-level file includes the number of files and the file names;
[0015] The comparison of the automated test execution results with the information in the test case-level file of the expected execution results includes:
[0016] If the number of test case level files in the automated test execution result is the same as the number of test case level files in the expected execution result, then the test case level files in the automated test execution result will be sorted according to the order of the test case level files in the expected execution result.
[0017] According to the sorting, the file names of the test case level files in each of the automated test execution results and the test case level files of the expected execution results in the same sorting are compared in turn;
[0018] If the file names of the test case level files in all the automated test execution results are the same as those of the test case level files in the expected execution results with the same order, then it is determined that the information of the test case level files in the automated test execution results and the expected execution results is consistent.
[0019] If the file names of any test case-level file in the automated test execution result are different from those of the test case-level files in the expected execution result with the same order, then it is determined that the information in the test case-level files of the automated test execution result and the expected execution result is inconsistent.
[0020] In one embodiment, the method further includes:
[0021] The same message digest algorithm is used to calculate the content digest of the automated test execution result and the content digest of the expected execution result, respectively. The message digest algorithm is MD5 or SHA-1.
[0022] In another embodiment, the comparison between the automated test execution result and the expected execution result includes:
[0023] The automated test execution results and the expected execution results are preprocessed;
[0024] If the preprocessed file of the automated test execution result is not empty, then compare the number of rows in the automated test execution result with the expected execution result;
[0025] If the number of lines in the automated test execution result and the expected execution result are the same, then each line in the automated test execution result and the expected execution result are compared in order of file content.
[0026] If each row of the automated test result matches the row corresponding to the expected execution result, then the content of the automated test execution result and the expected execution result are determined to be consistent.
[0027] If the automated test execution result in any row differs from the expected execution result, then it is determined that the content of the automated test execution result and the expected execution result are inconsistent.
[0028] In another embodiment, if the number of rows in the automated test execution result is the same as the number of rows in the expected execution result, the method further includes:
[0029] If the order of the file content is uncertain, then each line of the automated test execution result will be traversed sequentially in the expected execution result;
[0030] When any row in the automated test result is found to be non-matching in the expected execution result, it is determined that the content of the automated test result and the expected execution result are inconsistent.
[0031] When every row in the automated test result has a matching row in the expected execution result, it is determined that the content of the automated test execution result and the expected execution result are consistent.
[0032] In another embodiment, the method further includes:
[0033] If the information in the test case-level file of the automated test execution result is inconsistent with the expected execution result, or if the content summary of the automated test execution result is inconsistent with the expected execution result, or if the content of the automated test execution result is inconsistent with the expected execution result, then an error report is generated based on the differences.
[0034] Secondly, this application also provides a batch processing automated testing apparatus. The apparatus includes:
[0035] The configuration module is used to obtain test cases and test configuration parameters for batch processing of business logic;
[0036] The testing module is used to execute test cases of the business logic batch processing according to the test configuration parameters, and obtain automated test execution results;
[0037] The expected result acquisition module is used to obtain the expected execution result;
[0038] The information comparison module is used to compare the information in the test case-level file with the expected execution result of the automated test.
[0039] The summary comparison module is used to compare the content summaries of the automated test execution results and the expected execution results if the information in the test case level files of the automated test execution results and the expected execution results is consistent.
[0040] The content comparison module is used to compare the content of the automated test execution result and the expected execution result if the content summary of the automated test execution result is consistent.
[0041] The output module is used to determine that the automated test execution result conforms to the expected execution result if the content of the automated test execution result is consistent with the expected execution result.
[0042] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0043] Obtain test cases and test configuration parameters for batch processing of business logic;
[0044] The test cases of the business logic batch processing are executed according to the test configuration parameters to obtain the automated test execution results;
[0045] Obtain the expected execution result;
[0046] The information in the test case-level file is compared with the results of the automated test execution and the expected results.
[0047] If the information in the test case-level file of the automated test execution result is consistent with the expected execution result, then the content summaries of the automated test execution result and the expected execution result are compared.
[0048] If the content summary of the automated test execution result is consistent with the expected execution result, then the content of the automated test execution result and the expected execution result are compared.
[0049] If the content of the automated test execution result is consistent with the expected execution result, then it is determined that the automated test execution result conforms to the expected execution result.
[0050] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0051] Obtain test cases and test configuration parameters for batch processing of business logic;
[0052] The test cases of the business logic batch processing are executed according to the test configuration parameters to obtain the automated test execution results;
[0053] Obtain the expected execution result;
[0054] The information in the test case-level file is compared with the results of the automated test execution and the expected results.
[0055] If the information in the test case-level file of the automated test execution result is consistent with the expected execution result, then the content summaries of the automated test execution result and the expected execution result are compared.
[0056] If the content summary of the automated test execution result is consistent with the expected execution result, then the content of the automated test execution result and the expected execution result are compared.
[0057] If the content of the automated test execution result is consistent with the expected execution result, then it is determined that the automated test execution result conforms to the expected execution result.
[0058] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:
[0059] Obtain test cases and test configuration parameters for batch processing of business logic;
[0060] The test cases of the business logic batch processing are executed according to the test configuration parameters to obtain the automated test execution results;
[0061] Obtain the expected execution result;
[0062] The information in the test case-level file is compared with the results of the automated test execution and the expected results.
[0063] If the information in the test case-level file of the automated test execution result is consistent with the expected execution result, then the content summaries of the automated test execution result and the expected execution result are compared.
[0064] If the content summary of the automated test execution result is consistent with the expected execution result, then the content of the automated test execution result and the expected execution result are compared.
[0065] If the content of the automated test execution result is consistent with the expected execution result, then it is determined that the automated test execution result conforms to the expected execution result.
[0066] The aforementioned batch processing automated testing methods, devices, computer equipment, storage media, and computer program products automatically execute test cases for business logic batch processing, obtaining automated test execution results. These results are then compared with the expected execution results at three levels: information, content summary, and content of the test case-level file, from coarse to fine. Only when all three levels are consistent is the automated test execution result considered to meet the expected result. Conversely, if inconsistencies are found at the current level, the automated test execution result is considered not to meet the expected result, eliminating the need for further finer comparisons. This method not only automates business logic batch processing testing but also automatically determines whether the automated test execution results meet expectations. Testers only need to prepare test cases and test configuration parameters; the entire process requires no manual intervention, achieving low-code testing of business logic batch processing and improving processing efficiency. Attached Figure Description
[0067] Figure 1 This is a diagram illustrating the application environment of a batch automated testing method in one embodiment.
[0068] Figure 2 This is a flowchart illustrating a batch automated testing method in one embodiment;
[0069] Figure 3 This is a flowchart illustrating the steps in one embodiment to compare the results of automated test execution with information from a test case-level file representing the expected execution results.
[0070] Figure 4 This is a flowchart illustrating the steps involved in comparing the results of automated test execution with the expected results in one embodiment.
[0071] Figure 5 This is a structural block diagram of a batch processing automated testing device in one embodiment;
[0072] Figure 6 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0073] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0074] The batch automated testing method provided in this application can be applied to, for example... Figure 1 The application environment shown is illustrated. In this environment, test terminal 102 communicates with automated testing platform 104 via a network. A data storage system can store the data that the automated testing platform 104 needs to process. The data storage system can be integrated into the automated testing platform 104 or placed in the cloud or on another network server.
[0075] Testers configure test cases and test configuration parameters for the business logic batch processing via test terminal 102. The automated testing platform obtains the test cases and test configuration parameters for the business logic batch processing. It executes the test cases for the business logic batch processing according to the test configuration parameters to obtain the automated test execution results. It then obtains the expected execution results. The platform compares the information in the test case-level files of the automated test execution results and the expected execution results. If the information in the test case-level files of the automated test execution results and the expected execution results is consistent, it compares the content summaries of the automated test execution results and the expected execution results. If the content summaries of the automated test execution results and the expected execution results are consistent, it compares the content of the automated test execution results and the expected execution results. If the content of the automated test execution results and the expected execution results is consistent, it is determined that the automated test execution results meet the expected execution results.
[0076] The test terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, and smart in-vehicle devices. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted devices. The automated test platform 104 can be implemented using a standalone server or a server cluster consisting of multiple servers.
[0077] In one embodiment, such as Figure 2 As shown, a batch processing automated testing method is provided, which can be applied to... Figure 1 Taking the automated testing platform in [the document] as an example, the steps include:
[0078] Step 202: Obtain the test cases and test configuration parameters for the business logic batch processing.
[0079] Specifically, testers log into the automated testing platform via a terminal and fill in batch test cases and test data on the platform's front end. They can fill in batch test cases on the platform's front end and also import batch test cases in tables.
[0080] In this embodiment, batch processing specifically refers to batch processing of business logic. Taking the testing of the transaction interface as an example, compared to the real-time transaction interface that directly returns data, batch processing in production typically involves configuring a scheduled task to summarize the online transaction data from the previous few days on day T+1 and generate a data output file for downstream services.
[0081] Test configuration parameters include test data and execution steps. Test data refers to the input data for the batch processing task. For example, for a credit card data platform, the test data consists of the application files prepared before executing the batch processing. Execution steps refer to the method of running the batch processing task. In production, this is typically done by configuring a scheduled task. This scheduled task can be executed manually; functional testers only need to log in to a page and click "execute." To automate the process, the API called by the scheduled task can be viewed through a browser, allowing the program to trigger this action.
[0082] The automated testing platform can only receive a string, while test cases and test configuration parameters are in JSON format. When uploading test cases and test configuration parameters, the terminal needs to encrypt the test cases before transmission. Encrypting the test cases also saves memory space.
[0083] Step 204: Execute the test cases of the business logic batch processing according to the test configuration parameters to obtain the automated test execution results.
[0084] Specifically, the automated testing platform decrypts the test cases in the business logic batch processing, completes data parameterization, and then begins batch execution of each test case, obtaining the automated test execution results for each test case. The automated test execution results are stored in a designated folder.
[0085] Step 206: Obtain the expected execution result.
[0086] The expected execution result is the standard test result of the test case, which can be a manual test result, pre-stored in a designated folder in the automated testing platform.
[0087] Step 208: Compare the information in the test case-level file with the results of the automated test execution and the expected results.
[0088] A test case-level file refers to each file in the test case execution results. A single test case may have multiple test case-level files. Information about a test case-level file may include the number of files and their filenames. If the information in the test case-level files of the automated test execution results matches the expected execution results, then proceed to step 210.
[0089] Step 210: Compare the content summary of the automated test execution result and the expected execution result.
[0090] Specifically, a digest algorithm is used to calculate the content digests of both the automated test execution result and the expected execution result. A digest algorithm is an algorithm that produces a specific output format. Its characteristic is that regardless of the length of the original data input by the user, the output ciphertext is of a fixed length after calculation. The principle of this algorithm is to extract information from the original data according to certain operational rules; this extraction is the digest. The content of the digested data is closely related to the original data; even a slight change in the original data will result in a completely different output "digest." Therefore, by comparing the content digests of the automated test execution result and the expected execution result, if their content digests are different, it indicates that the original data content is also different.
[0091] Since the content summary data volume is much smaller than the original data, comparing the content summaries instead of the original content can improve comparison efficiency. If the comparison result of step 210 shows that the content summary of the automated test execution result matches the expected execution result, then step 212 is executed.
[0092] It is worth noting that compared to comparing information in use case files, the comparison of content summaries is more granular. The information in use case files is compared first, and only after the information in use case files passes the comparison is the content summaries compared more finely. This allows test cases with inconsistent information to be filtered out using the coarse-grained rule of use case file information, avoiding the waste of resources caused by directly performing more fine-grained matching on all automated test results.
[0093] In another embodiment, prior to the step of comparing the content digests of the automated test execution result and the expected execution result, the batch automated testing method further includes: calculating the content digests of the automated test execution result and the expected execution result respectively using the same message digest algorithm, wherein the message digest algorithm is MD5 or SHA-1.
[0094] Step 212: Compare the automated test execution result with the expected execution result. If the automated test execution result and the expected execution result are consistent, proceed to step 214.
[0095] Specifically, when the summary of the automated test execution result matches the expected execution result, a more detailed comparison can be performed, namely, a comparison of the content of the automated test execution result and the expected execution result. This content comparison can involve checking whether the content of each line in the file is consistent.
[0096] It's worth noting that content comparison offers a finer granularity compared to summary comparison. The summary comparison is performed first, and only after the summary information passes the comparison is the content itself compared. This allows for the filtering of inconsistencies in test cases using the relatively coarse-grained summary rule, avoiding the waste of resources caused by directly performing more detailed matching on all automated test results.
[0097] Step 214: Determine if the automated test execution results meet the expected results.
[0098] In other words, whether the automated test execution result meets the expected execution result is determined through a comparison at three levels of granularity: information in the test case file, content summary, and content. The comparison proceeds from coarse to fine. Only when all three levels—test case file, content summary, and content—are consistent is the automated test execution result considered to meet the expected result. Conversely, if the comparison at one level is inconsistent, the automated test execution result is considered not to meet the expected result, and there is no need to proceed to the next level of more granular comparison, thus saving resources.
[0099] The aforementioned batch processing automated testing method automatically executes test cases for batch processing of business logic, obtaining automated test execution results. These results are then compared with the expected results at three levels: information, summary, and content in the test case file, from coarse to fine. Only when all three levels are consistent is the automated test execution result considered to meet the expected result. Conversely, if there is a discrepancy at the current level, the automated test execution result is considered not to meet the expected result, eliminating the need for a further, more granular comparison. This method not only automates the testing of batch processing of business logic but also automatically determines whether the automated test execution results meet expectations. Testers only need to prepare test cases and test configuration parameters; the entire process requires no manual intervention, achieving low-code testing of business logic batch processing and improving processing efficiency.
[0100] In another embodiment, the information in the use case-level files includes the number of files and the file names.
[0101] like Figure 3As shown, the information in the test case-level file is compared between the automated test execution results and the expected execution results, including:
[0102] Step 302: Compare the number of test case level files in the automated test execution result with the number of test case level files in the expected execution result. If the number of test case level files in the automated test execution result is the same as the number of test case level files in the expected execution result, proceed to step 304.
[0103] Step 304: Sort the test case level files in the automated test execution results according to the order of the test case level files in the expected execution results.
[0104] Step 306: According to the sorting, compare the file names of the test case level files in each automated test execution result with the file names of the test case level files in the expected execution results of the same sorting.
[0105] Step 308: If the file names of the test case level files in all automated test execution results are the same as those of the test case level files in the expected execution results with the same order, then it is determined that the information in the test case level files of the automated test execution results and the expected execution results is consistent.
[0106] Step 310: If the file names of the test case level files in any automated test execution result are different from those of the test case level files in the expected execution result with the same order, then it is determined that the information in the test case level files of the automated test execution result and the expected execution result is inconsistent.
[0107] The comparison of test case-level files follows a coarse-to-fine process. Before comparing the content of the test case-level files, the number of files is compared first. If the number of files is the same, the file names are then compared. Before comparing file names, the test case-level files in the automated test execution results are sorted according to the order of the test case-level files in the expected execution results. This ensures that the test case-level files in the automated test execution results can be mapped to those in the expected execution results. Then, the file names of test case-level files with the same sequence number in the automated test execution results are compared with those in the expected execution results. If the file names of all test case-level files in the automated test execution results are the same as those in the same sorted expected execution results, then the test case-level files in the automated test execution results are consistent with those in the expected execution results. If the file name of any test case-level file in the automated test execution results is different from that in the same sorted expected execution results, then the test case-level files in the automated test execution results are inconsistent with those in the expected execution results.
[0108] In this embodiment, the comparison of the test case-level file information of the automated test execution results and the expected execution results is carried out sequentially from two dimensions: file quantity and file name. Among them, the file name comparison has a higher granularity than the file quantity comparison. By setting two different granularity comparison dimensions, coarse first and fine later, the file name comparison is only performed when the file quantity is inconsistent. In this way, test cases with inconsistent file quantity can be filtered out by the relatively coarse-grained rule of file quantity, avoiding the waste of resources caused by directly matching all file information by file name.
[0109] In another implementation, for example, such as Figure 4 As shown, the comparison between the automated test execution results and the expected execution results includes:
[0110] Step 402: Preprocess the automated test execution results and the expected execution results.
[0111] Preprocessing includes encoding format conversion and deletion of predefined format data.
[0112] Specifically, the file encoding format is obtained. If the file type is .gz, it is decompressed, replaced with a temporary file, and the date information in the file is excluded. The file is then trimmed to .bak format. File types supported include .gz, .dat, .flg, and .csv.
[0113] Step 404: Determine whether the file containing the preprocessed automated test execution results is empty. If the file containing the preprocessed automated test execution results is not empty, proceed to step 406.
[0114] Specifically, an empty file indicates that there is no content, which may be caused by an exception during the automated testing process. If the file resulting from the automated test is an empty file, an error message will be returned.
[0115] Step 406: Compare the number of rows in the automated test execution result with the number of rows in the expected execution result. If the number of rows in the automated test execution result and the expected execution result are the same, proceed to step 408.
[0116] After excluding empty files, the number of lines in the automated test execution result is compared with the expected execution result. Theoretically, the number of lines should be the same. If they are the same, the content can be considered inconsistent. If they are different, an error message is returned.
[0117] Step 408: Compare each line of the automated test execution result with the expected execution result in the order of the file content.
[0118] If each row of the automated test result is consistent with the row corresponding to the expected execution result, then proceed to step 410 to determine that the content of the automated test execution result and the expected execution result are consistent.
[0119] If the automated test execution result of any row differs from the expected execution result, then proceed to step 412 to determine that the content of the automated test execution result and the expected execution result are inconsistent.
[0120] The order of the text content is related to the execution order of the test cases.
[0121] Specifically, if the automated test execution result of any row is different from the expected execution result, then the content of the automated test execution result and the expected execution result are inconsistent. If every row of the automated test result is consistent with the row corresponding to the expected execution result, then the content of the automated test execution result and the expected execution result are consistent.
[0122] Understandably, the comparison of empty files, line counts, and line content also follows a coarse-to-fine three-level process. Only when all three levels—empty files, line counts, and line content—are consistent can it be determined that the automated test execution result matches the expected execution result. Conversely, if the comparison at each of the three levels proceeds from coarse to fine, and there is a discrepancy, it can be determined that the automated test execution result does not match the expected execution result, eliminating the need to proceed to the next level of more granular comparison, thus saving resources.
[0123] For cases where the order of file content is uncertain, each line of the automated test execution result is sequentially traversed in the expected execution result. When any line in the automated test result does not have a matching line in the expected execution result, it is determined that the content of the automated test execution result and the expected execution result are inconsistent. When every line in the automated test result has a matching line in the expected execution result, it is determined that the content of the automated test execution result and the expected execution result are consistent.
[0124] Specifically, in some cases, the data in each line of the file generated by batch automated testing may be random. This is internal logic of the batch processing task and is unrelated to the execution order of the test cases. In other words, unless the upstream and downstream systems agree that a certain order must be followed (the rules will be specified in advance), as long as the data is available, the order is not important. The downstream processes will analyze the data themselves. In this case, a traversal approach can be used. The first line of the automated test execution result is compared with each line of the expected execution result until the two lines are the same. This process is repeated until the traversal ends or a difference is found. If a difference is found, the number of the line containing the difference is returned.
[0125] In this embodiment, when the generation of batch automated test data is independent of the execution order, a traversal method can be used to judge the automated test results and the expected execution results to ensure comparison accuracy.
[0126] Furthermore, the results of automated test execution can include two files: a data file and a structure file. The data file records the data required by downstream services, while the structure file describes the data structure, such as the location of a specific field. In some cases, the results may also include a database file. After executing some batch processing tasks, a few rows of data are added to the database. Exporting these rows to a database file facilitates comparison of the results. In this case, content comparison can also include comparison of single-row lengths. For data of variable length, fields are ignored. If the first index of a different location is different, it is checked whether that location falls within the scope of ignored fields. If not, the index value is output. The data file matches fields in the corresponding structure file based on the index, while the database file obtains the field names of the differences through text analysis.
[0127] Among them, the fields that can be ignored are pre-configured by the testers.
[0128] In another embodiment, if the information in the use case-level file of the automated test execution result is inconsistent with the expected execution result, or if the content summary of the automated test execution result is inconsistent with the expected execution result, or if the content of the automated test execution result is inconsistent with the expected execution result, an error report is generated based on the differences.
[0129] Specifically, the information, content summary, and content comparison results of the use case-level files are all written to the automated testing platform. When the file comparison fails, that is, when the information of the use case-level files of the automated test execution result and the expected execution result are inconsistent, or when the content summary of the automated test execution result and the expected execution result are inconsistent, or when the content of the automated test execution result and the expected execution result are inconsistent, it is determined that the automated test execution result does not meet the expected execution result.
[0130] When file comparison fails, first check if the automated test result exceeds a set size, such as 30MB. If it does, the file is abnormal, and an error message is output. If it's less than 30MB but greater than 5MB, generate a specific formatted error message file, such as an HTML file, showing only the differences. If it's less than 5MB, the generated error message file includes all parts containing all differences and is added as an attachment to the error report.
[0131] The batch processing automated testing platform executes shell scripts and calls the front-end page. It sets the maximum execution time for a single command and the interval for receiving command response data. It also supports setting waiting time and retrying on failure, ensuring the diversity of batch processing cases and the stability of operation as much as possible.
[0132] This batch processing automated testing method allows testers to execute batch test cases with a single click by simply filling in the batch test case information on the front end, and then verify and return the execution results without writing any code, achieving low-code and low-cost maintenance. The batch test case information includes dependency settings, initialization operations, source files, target files, and ignored fields. Batch execution supports shell commands and front-end API calls, and downloading data files supports verifying database data and downloading target files from the server, covering most batch processing execution and verification methods. Therefore, it can significantly improve the efficiency of batch processing automated testing.
[0133] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0134] Based on the same inventive concept, this application also provides a batch processing automated testing apparatus for implementing the batch processing automated testing method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more batch processing automated testing apparatus embodiments provided below can be found in the limitations of the batch processing automated testing method described above, and will not be repeated here.
[0135] In one embodiment, such as Figure 5 As shown, a batch automated testing device is provided, comprising:
[0136] Configuration module 502 is used to obtain test cases and test configuration parameters for business logic batch processing.
[0137] Test module 504 is used to execute batch test cases of business logic according to test configuration parameters and obtain automated test execution results.
[0138] The expected result is obtained in module 506.
[0139] The information comparison module 508 is used to compare the information in the test case-level files that represent the results of automated test execution with the expected results.
[0140] The summary comparison module 510 is used to compare the content summaries of the automated test execution results and the expected execution results if the information in the test case-level files of the automated test execution results and the expected execution results are consistent.
[0141] The content comparison module 512 is used to compare the content of the automated test execution result and the expected execution result if the content summary of the automated test execution result is consistent.
[0142] The output module 514 is used to determine that the automated test execution result meets the expected execution result if the content of the automated test execution result is consistent with the expected execution result.
[0143] In another embodiment, the information in the use case-level files includes the number of files and the file names.
[0144] The information comparison module is used to sort the test case-level files in the automated test execution results according to the order of the test case-level files in the expected execution results if the number of test case-level files in the automated test execution results is the same. Then, according to the sorting, it compares the filenames of each test case-level file in the automated test execution results with the filenames of the same sorted test case-level files in the expected execution results. If the filenames of all test case-level files in the automated test execution results are the same as those in the expected execution results, then the information of the test case-level files in the automated test execution results and the expected execution results is consistent. If the filenames of any test case-level file in the automated test execution results are different from those in the expected execution results, then the information of the test case-level files in the automated test execution results and the expected execution results is inconsistent.
[0145] In another embodiment, the digest comparison module is also used to calculate the content digest of the automated test execution result and the content digest of the expected execution result using the same information digest algorithm, wherein the information digest algorithm is MD5 or SHA-1.
[0146] In another embodiment, the content comparison module is used to preprocess the automated test execution results and the expected execution results; if the preprocessed automated test execution result file is not empty, the number of lines in the automated test execution result and the expected execution result are compared; if the number of lines in the automated test execution result and the expected execution result are the same, each line in the automated test execution result and the expected execution result are compared in the order of file content; if each line in the automated test result is consistent with the corresponding line in the expected execution result, the content of the automated test execution result and the expected execution result is determined to be consistent; if any line in the automated test execution result and the expected execution result are different, the content of the automated test execution result and the expected execution result is determined to be inconsistent.
[0147] In another embodiment, the content comparison module is further configured to, if the order of the file content is uncertain, sequentially traverse each line of the automated test execution result in the expected execution result; when any line in the automated test result does not have a matching line in the expected execution result, determine that the content of the automated test execution result and the expected execution result are inconsistent; when every line in the automated test result has a matching line in the expected execution result, determine that the content of the automated test execution result and the expected execution result are consistent.
[0148] In another embodiment, the output module is further configured to generate an error report based on the differences if the information in the use case-level file of the automated test execution result and the expected execution result are inconsistent, or if the content summary of the automated test execution result and the expected execution result are inconsistent, or if the content of the automated test execution result and the expected execution result are inconsistent.
[0149] Each module in the aforementioned batch processing automated testing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0150] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 6As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database stores batch-processed automated test data. The network interface communicates with external terminals via a network connection. When the computer program is executed by the processor, it implements a batch-processed automated testing method.
[0151] Those skilled in the art will understand that Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0152] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the batch automated testing methods of the above embodiments.
[0153] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the batch automated testing methods of the above embodiments.
[0154] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of the batch automated testing methods of the above embodiments.
[0155] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile 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. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0156] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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 specification.
[0157] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A batch processing automated testing method, characterized in that, The method includes: Obtain test cases and test configuration parameters for batch processing of business logic; The test cases of the business logic batch processing are executed according to the test configuration parameters to obtain the automated test execution results; Obtain the expected execution result; The information in the test case-level file is compared with the results of the automated test execution and the expected results. If the information in the test case-level file of the automated test execution result is consistent with the expected execution result, then the content summaries of the automated test execution result and the expected execution result are compared. If the content summary of the automated test execution result is consistent with the expected execution result, then the content of the automated test execution result and the expected execution result are compared. If the content of the automated test execution result is consistent with the expected execution result, then it is determined that the automated test execution result conforms to the expected execution result. The comparison between the automated test execution result and the expected execution result includes: The automated test execution results and the expected execution results are preprocessed; If the preprocessed file of the automated test execution result is not empty, then compare the number of rows in the automated test execution result with the expected execution result; If the number of lines in the automated test execution result and the expected execution result are the same, then each line in the automated test execution result and the expected execution result are compared in order of file content. If each row of the automated test execution result is consistent with the row corresponding to the expected execution result, then it is determined that the content of the automated test execution result and the expected execution result are consistent. If the automated test execution result in any row differs from the expected execution result, then it is determined that the content of the automated test execution result and the expected execution result are inconsistent. If the number of rows in the automated test execution result is the same as the number of rows in the expected execution result, the method further includes: If the order of the file content is uncertain, then each line of the automated test execution result will be traversed sequentially in the expected execution result; When any row in the automated test execution result is found to be non-matching in the expected execution result, it is determined that the contents of the automated test execution result and the expected execution result are inconsistent. When every line in the automated test execution result has a matching line in the expected execution result, it is determined that the content of the automated test execution result and the expected execution result are consistent.
2. The method according to claim 1, characterized in that, The information in the use case-level files includes the number of files and file names; The comparison of the automated test execution results with the information in the test case-level file of the expected execution results includes: If the number of test case level files in the automated test execution result is the same as the number of test case level files in the expected execution result, then the test case level files in the automated test execution result will be sorted according to the order of the test case level files in the expected execution result. According to the sorting, the file names of the test case level files in each of the automated test execution results and the test case level files of the expected execution results in the same sorting are compared in turn; If the file names of the test case level files in all the automated test execution results are the same as those of the test case level files in the expected execution results with the same order, then it is determined that the information of the test case level files in the automated test execution results and the expected execution results is consistent. If the file names of any test case-level file in the automated test execution result are different from those of the test case-level files in the expected execution result with the same order, then it is determined that the information in the test case-level files of the automated test execution result and the expected execution result is inconsistent.
3. The method according to claim 1, characterized in that, The method further includes: The same message digest algorithm is used to calculate the content digest of the automated test execution result and the content digest of the expected execution result, respectively. The message digest algorithm is MD5 or SHA-1.
4. The method according to claim 1, characterized in that, The method further includes: If the information in the test case-level file of the automated test execution result is inconsistent with the expected execution result, or if the content summary of the automated test execution result is inconsistent with the expected execution result, or if the content of the automated test execution result is inconsistent with the expected execution result, then an error report is generated based on the differences.
5. A batch processing automated testing device, characterized in that, The device includes: The configuration module is used to obtain test cases and test configuration parameters for batch processing of business logic; The testing module is used to execute test cases of the business logic batch processing according to the test configuration parameters, and obtain automated test execution results; The expected result acquisition module is used to obtain the expected execution result; The information comparison module is used to compare the information in the test case-level file with the expected execution result of the automated test. The summary comparison module is used to compare the content summaries of the automated test execution results and the expected execution results if the information in the test case level files of the automated test execution results and the expected execution results is consistent. The content comparison module is used to compare the content of the automated test execution result and the expected execution result if the content summary of the automated test execution result is consistent. An output module is used to determine that the automated test execution result conforms to the expected execution result if the content of the automated test execution result is consistent with the expected execution result; The content comparison module is further configured to preprocess the automated test execution result and the expected execution result; if the preprocessed automated test execution result file is not empty, then the number of lines in the automated test execution result and the expected execution result are compared; if the number of lines in the automated test execution result and the expected execution result are the same, then each line in the automated test execution result and the expected execution result are compared in file content order; if each line in the automated test execution result is consistent with the corresponding line in the expected execution result, then the content of the automated test execution result and the expected execution result is determined to be consistent; if any line in the automated test execution result and the expected execution result are different, then the content of the automated test execution result and the expected execution result is determined to be inconsistent. The content comparison module is further configured to, if the order of the file content is uncertain, sequentially traverse each line of the automated test execution result in the expected execution result; when any line in the automated test execution result does not have a matching line in the expected execution result, determine that the content of the automated test execution result and the expected execution result are inconsistent; when every line in the automated test execution result has a matching line in the expected execution result, determine that the content of the automated test execution result and the expected execution result are consistent.
6. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 4.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Batch processing automatic verification method and device
CN112948265A
File service test method and device of cross-domain transmission equipment and electronic equipment
CN113704087A