Interface automation testing method, testing device and testing system
By using the transaction serial number in the interface automation test to obtain log data from the error log file and generate test cases, the problem of the inability to automatically generate test cases in the existing technology is solved, and the automatic verification and repair of interface problems are achieved.
Patent Information
- Application Number
- CN202211564858.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-07
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2042-12-07
AI Technical Summary
In existing automated testing methods, test cases cannot be automatically generated, especially in the case design and data preparation process, which relies on a large amount of manual analysis and design, resulting in some problems being missed.
By receiving the error information from the error reporting interface, the target log data is obtained from the error log file using the transaction serial number, and the target test case is generated, including the target input data, judgment data and environment configuration data. The test case is automatically generated to verify whether there is a problem with the interface and whether it is successfully repaired.
It realizes the automatic generation of test cases when the interface returns error information, enriches the test coverage, reduces manual intervention, and improves test efficiency and accuracy.
Smart Images

Figure CN115712578B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of interface testing, and in particular to an interface automation testing method, a testing device, a computer-readable storage medium, and a testing system. Background Art
[0002] During the testing process, it's impossible for test cases to fully cover all test scenarios, especially for complex functions. This is because the many factors involved make exhaustive coverage impossible. Therefore, we can only consider as many possible scenarios as possible based on key, typical test scenarios. This process is mostly done manually. However, during actual testing, you may inadvertently trigger a scenario that actually occurs but is not covered by the test cases, and where the application has problems (errors occur / exceptions are returned). In this case, manual analysis of the scenario and supplementary corresponding test cases are required. Sometimes, even occasional issues are overlooked, resulting in problems that should have been discovered being missed.
[0003] Existing automated testing methods primarily focus on graphical operations and automated execution, but are largely absent in areas that rely heavily on human input, such as case design and data preparation. This is primarily due to the fact that the design and data preparation processes, depending on different industry contexts and business scenarios, require significant human analysis and design work. This is also the core of the testing process, whether manual or automated, as it is essentially a creative process, not a repetitive one. This is also the most challenging aspect of existing AI technology. Therefore, addressing this issue through proactive thinking is currently extremely challenging. Summary of the Invention
[0004] The main purpose of this application is to provide an interface automation testing method, a testing device, a computer-readable storage medium and a testing system to solve the problem in the prior art that test cases cannot be automatically generated.
[0005] According to one aspect of an embodiment of the present application, a method for automated interface testing is provided, which is applied to a backend, which is communicatively connected to an interface, and which includes: upon receiving an error message from an error reporting interface, obtaining target log data from an error log file according to target identification information, wherein the error reporting interface is an interface in which an error occurs during a transaction, the target log data is log data carrying the target identification information, the target identification information is a transaction serial number corresponding to the error reporting interface, and the error log file includes the log data of all the error reporting interfaces; generating a target test case according to target key data in the target log data, the target key data being data constituting the target test case, the target test case at least including data for testing whether the error reporting interface has a target test problem, one error message corresponding to one test problem, and the target test problem being the test problem corresponding to the error message of the error reporting interface; and upon completion of repair of the error reporting interface, testing the corresponding error reporting interface using the target test case to verify whether the error reporting interface has been successfully repaired.
[0006] Optionally, after generating a target test case based on the target key data in the target log data, the method further includes: using the target test case to test the interface to be tested to verify whether the interface to be tested has the target test problem, and the interface to be tested and the error reporting interface are the same type of interface.
[0007] Optionally, the target test case is used to test the corresponding error reporting interface to verify whether the error reporting interface is successfully repaired, including: generating a test script according to the target test case; and using the test script to test the error reporting interface to verify whether the error reporting interface is successfully repaired.
[0008] Optionally, generating a target test case based on the target key data in the target log data includes: extracting the target key data from the target log data; filling the target key data into a preset test case template to obtain the target test case, and the preset test case template is in the form of a two-dimensional table.
[0009] Optionally, the target key data includes target input data, target judgment data and target environment configuration data, and extracting the target key data from the target log data includes: extracting the target input data and the target judgment data from the target log data, the target input data being the input data of the error reporting interface during the transaction, and the target judgment data being the data used to determine whether the output data of the error reporting interface is correct; extracting the target environment configuration data from the data table corresponding to the error reporting interface based on the target input data and the data mapping relationship, the data mapping relationship being the mapping relationship between the interface and the data table, and the data table being at least used to store the target environment configuration data, and the target environment configuration data being the data called by the error reporting interface during the transaction.
[0010] Optionally, before obtaining target log data from the error log file according to the target identification information, the method includes: receiving the error information returned by the error reporting interface; and generating the error log file according to the error information.
[0011] Optionally, the number of error messages contained in one error log file is less than or equal to a preset number.
[0012] According to another aspect of an embodiment of the present application, an interface automation testing device is also provided, which is applied to a back-end, and the back-end is communicatively connected to the interface. The device includes: an acquisition unit, which is used to obtain target log data from the error log file according to target identification information when receiving an error message from an error reporting interface, the error reporting interface is an interface where an error occurs during a transaction, the target log data is log data carrying the target identification information, the target identification information is a transaction serial number corresponding to the error reporting interface, and the error log file includes the log data of all the error reporting interfaces; a generation unit, which is used to generate a target test case based on target key data in the target log data, the target key data is data constituting the target test case, the target test case at least includes data for testing whether the error reporting interface has a target test problem, one error message corresponds to a test problem, and the target test problem is the test problem corresponding to the error message of the error reporting interface; a testing unit, which is used to test the corresponding error reporting interface using the target test case when the error reporting interface is repaired to verify whether the error reporting interface is successfully repaired.
[0013] According to another aspect of the embodiments of the present application, a computer-readable storage medium is further provided, wherein the computer-readable storage medium includes a stored program, wherein when the program is executed by a processor, the processor executes any one of the interface automation testing methods described.
[0014] According to another aspect of an embodiment of the present application, an interface automation testing system is also provided, comprising: a backend, an interface, one or more processors, a memory, and one or more programs, wherein the backend is communicatively connected to the interface, the one or more programs are stored in the memory, and are configured to be executed by the one or more processors, and the one or more programs include methods for executing any one of the methods described.
[0015] In the above-mentioned interface automation testing method, first, when an error message is received from an error reporting interface, target log data is obtained from the error log file according to the target identification information. The above-mentioned error reporting interface is an interface where an error occurs during a transaction. The above-mentioned target log data is log data carrying the above-mentioned target identification information. The above-mentioned target identification information is the transaction serial number corresponding to the above-mentioned error reporting interface. The above-mentioned error log file includes the above-mentioned log data of all the above-mentioned error reporting interfaces; then, a target test case is generated according to the target key data in the above-mentioned target log data. The above-mentioned target key data is data constituting the above-mentioned target test case. The above-mentioned target test case at least includes data for testing whether the above-mentioned error reporting interface has a target test problem. One of the above-mentioned error messages corresponds to one test problem. The above-mentioned target test problem is the above-mentioned test problem corresponding to the above-mentioned error message of the above-mentioned error reporting interface; finally, when the above-mentioned error reporting interface is repaired, the corresponding above-mentioned error reporting interface is tested using the above-mentioned target test case to verify whether the above-mentioned error reporting interface is repaired successfully. When the interface returns an error message during an actual transaction, this method obtains the log data of the error interface, and automatically generates a test case based on the log data of the error interface to test whether the error interface has a test problem corresponding to the error message. That is, the corresponding test case is automatically generated for the actual problem scenario of the interface, thereby enriching the existing test cases. This method solves the problem in the existing technology that test cases cannot be automatically generated. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings that constitute part of this application are used to provide a further understanding of this application. The illustrative embodiments of this application and their descriptions are used to explain this application and do not constitute an improper limitation on this application. In the drawings:
[0017] Figure 1 A flowchart of an interface automation testing method according to an embodiment of the present application is shown;
[0018] Figure 2 A schematic diagram of an interface automation testing device according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0019] It should be noted that the following detailed descriptions are illustrative and intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which the present application belongs.
[0020] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, they indicate the presence of features, steps, operations, devices, components and / or combinations thereof.
[0021] It should be understood that when an element (such as a layer, film, region, or substrate) is described as being "on" another element, the element may be directly on the other element or intervening elements may be present. Moreover, in the specification and claims, when it is described that an element is "connected to" another element, the element may be "directly connected to" the other element or "connected to" the other element through a third element.
[0022] As mentioned in the background technology, test cases cannot be automatically generated in the prior art. In order to solve the above problem, in a typical embodiment of the present application, an interface automation testing method, a testing device, a computer-readable storage medium and a testing system are provided.
[0023] According to an embodiment of the present application, a method for automated interface testing is provided.
[0024] Figure 1 This is a flow chart of the interface automation testing method according to an embodiment of the present application. Figure 1 As shown, the method includes the following steps:
[0025] Step S101: Upon receiving an error message from an error reporting interface, target log data is obtained from an error log file based on target identification information. The error reporting interface is the interface where the error occurred during the transaction process, and the target log data is log data carrying the target identification information. The target identification information is the transaction serial number corresponding to the error reporting interface. The error log file includes the log data of all the error reporting interfaces.
[0026] It should be noted that the transaction serial number is a retrieval element for extracting target log data from the error log file. Through the transaction serial number, all log data of the error interface during this transaction can be extracted from the error log file.
[0027] In order to quickly search for log data of the error reporting interface, in an optional embodiment, before the above step S101, the above method further includes:
[0028] Step S201, receiving the error information returned by the error reporting interface;
[0029] Step S202: Generate the error log file according to the error message.
[0030] In the above implementation, the backend will analyze the return message of the transaction processing, mainly based on log analysis, and output the error information of all interfaces, that is, the content with the log level of error, to the error log file app_error.log.[x]. Afterwards, when searching for the log data of the error interface, you can search in the error log file, thereby achieving the purpose of quickly finding the log data of the error interface.
[0031] In order to further quickly search the log data of the error reporting interface, in another optional implementation manner, the number of the error reporting information included in the error log file is less than or equal to a preset number.
[0032] In the above implementation, the x in the error log file app_error.log.[x] is the identifier of the log rolling record, which can be a number representing the order. That is, after the number of error messages meets a certain log size, a separate error log file is recorded, which shortens the time of traversing a single error log file, thereby achieving the purpose of further quickly finding the log data of the error interface.
[0033] It should be noted that x can also be a time, that is, error information for a period of time is recorded in a separate error log file.
[0034] Step S102: Generate a target test case based on the target key data in the target log data. The target key data is data constituting the target test case. The target test case includes at least data for testing whether the error reporting interface has a target test problem. Each error message corresponds to a test problem. The target test problem is the test problem corresponding to the error message of the error reporting interface.
[0035] Optionally, the present application does not limit the specific process of generating target test cases based on the target key data in the target log data, and any feasible method falls within the scope of protection of the present application.
[0036] In an optional implementation, the above step S102 includes:
[0037] Step S1021, extracting the target key data from the target log data;
[0038] Step S1022: Fill the target key data into a preset test case template to obtain the target test case. The preset test case template is in a two-dimensional table format.
[0039] In the above implementation, as shown in Table 1, the preset test case template is in the form of a two-dimensional table. According to the header of the preset test case template, target key data including "2022033111101201", "S1B1001", "error01", "Input1:Value1", "Output1:value1", "Table1-set1:value1", and "Success:00; Failed:01" are extracted from the target log data, i.e., the target log data of the error reporting interface during this transaction, and "2022033111101201" is converted into "2022033111101201". "01201" is filled in with the case number, "S1B1001" is filled in with the transaction number, "error01" is filled in with the error message, "Input1:Value1" is filled in with the target input data, "Output1:value1" is filled in with the target output data, "Table1-set1:value1" is filled in with the target environment configuration data, and "Success:00; Failed:01" is filled in with the target judgment data, thereby forming a target test case in the form of a two-dimensional table. That is, only the data that needs to be filled in the preset test case template needs to be extracted, thereby improving the test case generation speed.
[0040] Table 1
[0041]
[0042] It should be noted that this application uses Python code:
[0043] #Create a new test case
[0044] wb=Workbook()
[0045] #First sheet
[0046] ws = wb.worksheets[0]
[0047] #Set the name of the sheet
[0048] ws.title=u"Error Playback Case"
[0049] #Assign a value to table header A1
[0050] ws.cell('A1').value='%s'%("Case Number")
[0051] #Assign value to A2
[0052] ws.cell('A2').value='%s'%("Transaction Number")
[0053] ws.cell('A2').style.font.bold=True
[0054] ##Save generated files
[0055] file_name = 'test.xlsx'
[0056] file_dir = ' / home / x / '
[0057] dest_filename='%s%s'%(file_dir,file_name)
[0058] ew=ExcelWriter(workbook=wb)
[0059] ew=ExcelWriter(workbook=wb)
[0060] Fill the target key data including case number and transaction number into the preset test case template in two-dimensional table form, i.e. Excel format.
[0061] Optionally, the above-mentioned target key data includes target input data, target judgment data and target environment configuration data. This application does not limit the specific process of extracting the above-mentioned target key data from the above-mentioned target log data, and any feasible method falls within the scope of protection of this application.
[0062] In an optional implementation, the above step S1021 includes:
[0063] Step S10211: extracting the target input data and the target determination data from the target log data, wherein the target input data is input data of the error reporting interface during the transaction, and the target determination data is data used to determine whether the output data of the error reporting interface is correct.
[0064] Step S10212, based on the above-mentioned target input data and data mapping relationship, extract the above-mentioned target environment configuration data from the data table corresponding to the above-mentioned error reporting interface. The above-mentioned data mapping relationship is the mapping relationship between the above-mentioned interface and the above-mentioned data table. The above-mentioned data table is at least used to store the above-mentioned target environment configuration data. The above-mentioned target environment configuration data is the data called by the above-mentioned error reporting interface during the above-mentioned transaction process.
[0065] In the above implementation, the three core elements of a target test case are target input data, target judgment data and target environment configuration data, among which the target input data and target judgment data can be directly extracted from the target log data, while the target environment configuration data needs to determine the data table called by the error reporting interface during the transaction process based on the mapping relationship between the interface and the data table sorted out in the early stage, and determine the data actually called by the error reporting interface in the data table called by the error reporting interface during the transaction process based on the target input data, that is, the input parameter data items of the interface, that is, only the data called by the error reporting interface during the transaction process is extracted, thereby ensuring that the generated test case conforms to the actual situation.
[0066] It should be noted that the extracted target environment configuration data is in the form of a SQL script.
[0067] It should also be noted that the target judgment data determines whether the interface is wrong through the interface output data. For example, the target judgment data 00 represents that the interface has no errors, and 01 represents that the interface has errors. When the interface is automatically tested according to the target test case, when the output data of the interface is 00, the interface is judged to be error-free according to the judgment data; when the output data of the interface is 01, the interface is judged to be error-free according to the judgment data.
[0068] In order to increase the versatility of the test cases, in an optional implementation, after step S102, the method further includes:
[0069] Step S301 : Testing the interface to be tested using the target test case to check whether the interface to be tested has the target test problem. The interface to be tested and the error reporting interface are of the same type.
[0070] In the above implementation manner, the target test case can be used to test whether the interface to be tested of the same type as the error reporting interface has the target test problem, and has strong versatility.
[0071] Step S103: When the above-mentioned error reporting interface is repaired, the above-mentioned target test case is used to test the corresponding above-mentioned error reporting interface to verify whether the above-mentioned error reporting interface is repaired successfully.
[0072] Optionally, this application does not limit the specific process of using the above-mentioned target test case to test the corresponding above-mentioned error reporting interface to verify whether the above-mentioned error reporting interface is successfully repaired. Any feasible method falls within the scope of protection of this application.
[0073] In an optional implementation, the above step S103 includes:
[0074] Step S1031, generating a test script according to the target test case;
[0075] Step S1032: Use the test script to test the error reporting interface to verify whether the error reporting interface is repaired successfully.
[0076] In the above implementation, a test script is generated based on the generated target test case. Since different automated testing tools have different grammatical specifications for executing test scripts, it is necessary to first determine the automated testing tool (such as JMeter) and then convert the test case to the test script. After the test script is generated, after the error interface problem is fixed (it may be code repair, configuration repair, data repair, etc.), the test script is used to test the error interface to verify whether the target test problem still exists in the error interface, thereby automatically verifying whether the error interface is successfully repaired.
[0077] It should be noted that the test script can also be used to replay the error of the error reporting interface in the automated test environment to reproduce the problem in order to discover the errors that occurred in the error reporting interface.
[0078] In the above-mentioned interface automation testing method, first, when an error message is received from an error reporting interface, target log data is obtained from the error log file according to the target identification information. The above-mentioned error reporting interface is an interface where an error occurs during a transaction. The above-mentioned target log data is log data carrying the above-mentioned target identification information. The above-mentioned target identification information is the transaction serial number corresponding to the above-mentioned error reporting interface. The above-mentioned error log file includes the above-mentioned log data of all the above-mentioned error reporting interfaces; then, a target test case is generated according to the target key data in the above-mentioned target log data. The above-mentioned target key data is data constituting the above-mentioned target test case. The above-mentioned target test case at least includes data for testing whether the above-mentioned error reporting interface has a target test problem. One of the above-mentioned error messages corresponds to one test problem. The above-mentioned target test problem is the above-mentioned test problem corresponding to the above-mentioned error message of the above-mentioned error reporting interface; finally, when the above-mentioned error reporting interface is repaired, the corresponding above-mentioned error reporting interface is tested using the above-mentioned target test case to verify whether the above-mentioned error reporting interface is repaired successfully. When the interface returns an error message during an actual transaction, this method obtains the log data of the error interface, and automatically generates a test case based on the log data of the error interface to test whether the error interface has a test problem corresponding to the error message. That is, the corresponding test case is automatically generated for the actual problem scenario of the interface, thereby enriching the existing test cases. This method solves the problem in the existing technology that test cases cannot be automatically generated.
[0079] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0080] The embodiment of the present application also provides an interface automation testing device. It should be noted that the interface automation testing device of the embodiment of the present application can be used to execute the interface automation testing method provided in the embodiment of the present application. The interface automation testing device provided in the embodiment of the present application is introduced below.
[0081] Figure 2 Schematic diagram of an interface automation test device according to an embodiment of the present application. Figure 2 As shown, the device includes:
[0082] The acquisition unit 10 is configured to, upon receiving an error message from an error reporting interface, acquire target log data from an error log file based on the target identification information, wherein the error reporting interface is the interface where the error occurs during a transaction, the target log data is log data carrying the target identification information, and the target identification information is the transaction serial number corresponding to the error reporting interface. The error log file includes the log data of all the error reporting interfaces;
[0083] It should be noted that the transaction serial number is a retrieval element for extracting target log data from the error log file. Through the transaction serial number, all log data of the error interface during this transaction can be extracted from the error log file.
[0084] In order to quickly search for log data of the error reporting interface, in an optional embodiment, the above-mentioned device further includes:
[0085] A receiving unit, configured to receive the error message returned by the error reporting interface;
[0086] The processing unit is used to generate the above-mentioned error log file according to the above-mentioned error information.
[0087] In the above implementation, the backend will analyze the return message of the transaction processing, mainly based on log analysis, and output the error information of all interfaces, that is, the content with the log level of error, to the error log file app_error.log.[x]. Afterwards, when searching for the log data of the error interface, you can search in the error log file, thereby achieving the purpose of quickly finding the log data of the error interface.
[0088] In order to further quickly search the log data of the error reporting interface, in another optional implementation manner, the number of the error reporting information included in the error log file is less than or equal to a preset number.
[0089] In the above implementation, the x in the error log file app_error.log.[x] is the identifier of the log rolling record, which can be a number representing the order. That is, after the number of error messages meets a certain log size, a separate error log file is recorded, which shortens the time of traversing a single error log file, thereby achieving the purpose of further quickly finding the log data of the error interface.
[0090] It should be noted that x can also be a time, that is, error information for a period of time is recorded in a separate error log file.
[0091] A generating unit 20 is configured to generate a target test case based on the target key data in the target log data, wherein the target key data is data constituting the target test case, and the target test case includes at least data for testing whether the error reporting interface has a target test problem, each error message corresponds to a test problem, and the target test problem is the test problem corresponding to the error message of the error reporting interface;
[0092] Optionally, the present application does not limit the specific process of generating target test cases based on the target key data in the target log data, and any feasible method falls within the scope of protection of the present application.
[0093] In an optional embodiment, the generating unit includes:
[0094] An extraction module, used to extract the above-mentioned target key data from the above-mentioned target log data;
[0095] The filling module is used to fill the above-mentioned target key data into the preset test case template to obtain the above-mentioned target test case. The above-mentioned preset test case template is in the form of a two-dimensional table.
[0096] In the above implementation, as shown in Table 1, the preset test case template is in the form of a two-dimensional table. According to the header of the preset test case template, target key data including "2022033111101201", "S1B1001", "error01", "Input1:Value1", "Output1:value1", "Table1-set1:value1", and "Success:00; Failed:01" are extracted from the target log data, i.e., the target log data of the error reporting interface during this transaction, and "2022033111101201" is converted into "2022033111101201". "01201" is filled in with the case number, "S1B1001" is filled in with the transaction number, "error01" is filled in with the error message, "Input1:Value1" is filled in with the target input data, "Output1:value1" is filled in with the target output data, "Table1-set1:value1" is filled in with the target environment configuration data, and "Success:00; Failed:01" is filled in with the target judgment data, thereby forming a target test case in the form of a two-dimensional table. That is, only the data that needs to be filled in the preset test case template needs to be extracted, thereby improving the test case generation speed.
[0097] Table 1
[0098]
[0099] It should be noted that this application uses Python code:
[0100] #Create a new test case
[0101] wb=Workbook()
[0102] #First sheet
[0103] ws = wb.worksheets[0]
[0104] #Set the name of the sheet
[0105] ws.title=u"Error Playback Case"
[0106] #Assign a value to table header A1
[0107] ws.cell('A1').value='%s'%("Case Number")
[0108] #Assign value to A2
[0109] ws.cell('A2').value='%s'%("Transaction Number")
[0110] ws.cell('A2').style.font.bold=True
[0111] ##Save generated files
[0112] file_name = 'test.xlsx'
[0113] file_dir = ' / home / x / '
[0114] dest_filename='%s%s'%(file_dir,file_name)
[0115] ew=ExcelWriter(workbook=wb)
[0116] ew=ExcelWriter(workbook=wb)
[0117] Fill the target key data including case number and transaction number into the preset test case template in two-dimensional table form, i.e. Excel format.
[0118] Optionally, the above-mentioned target key data includes target input data, target judgment data and target environment configuration data. This application does not limit the specific process of extracting the above-mentioned target key data from the above-mentioned target log data, and any feasible method falls within the scope of protection of this application.
[0119] In an optional embodiment, the extraction module includes:
[0120] a first extraction submodule, configured to extract the target input data and the target determination data from the target log data, wherein the target input data is input data of the error reporting interface during the transaction, and the target determination data is data used to determine whether output data of the error reporting interface is correct;
[0121] The second extraction sub-module is used to extract the above-mentioned target environment configuration data from the data table corresponding to the above-mentioned error reporting interface based on the above-mentioned target input data and the data mapping relationship. The above-mentioned data mapping relationship is the mapping relationship between the above-mentioned interface and the above-mentioned data table. The above-mentioned data table is at least used to store the above-mentioned target environment configuration data. The above-mentioned target environment configuration data is the data called by the above-mentioned error reporting interface during the above-mentioned transaction process.
[0122] In the above implementation, the three core elements of a target test case are target input data, target judgment data and target environment configuration data, among which the target input data and target judgment data can be directly extracted from the target log data, while the target environment configuration data needs to determine the data table called by the error reporting interface during the transaction process based on the mapping relationship between the interface and the data table sorted out in the early stage, and determine the data actually called by the error reporting interface in the data table called by the error reporting interface during the transaction process based on the target input data, that is, the input parameter data items of the interface, that is, only the data called by the error reporting interface during the transaction process is extracted, thereby ensuring that the generated test case conforms to the actual situation.
[0123] It should be noted that the extracted target environment configuration data is in the form of a SQL script.
[0124] It should also be noted that the target judgment data determines whether the interface is wrong through the interface output data. For example, the target judgment data 00 represents that the interface has no errors, and 01 represents that the interface has errors. When the interface is automatically tested according to the target test case, when the output data of the interface is 00, the interface is judged to be error-free according to the judgment data; when the output data of the interface is 01, the interface is judged to be error-free according to the judgment data.
[0125] In order to increase the versatility of the test cases, in an optional embodiment, the above-mentioned apparatus further includes:
[0126] The testing unit is used to test the interface to be tested using the above target test case to test whether the interface to be tested has the above target test problem, and the interface to be tested and the error reporting interface are of the same type of interface.
[0127] In the above implementation manner, the target test case can be used to test whether the interface to be tested of the same type as the error reporting interface has the target test problem, and has strong versatility.
[0128] The testing unit 30 is used to test the corresponding error reporting interface using the target test case when the error reporting interface is repaired, so as to verify whether the error reporting interface is repaired successfully.
[0129] Optionally, this application does not limit the specific process of using the above-mentioned target test case to test the corresponding above-mentioned error reporting interface to verify whether the above-mentioned error reporting interface is successfully repaired. Any feasible method falls within the scope of protection of this application.
[0130] In an optional embodiment, the test unit includes:
[0131] A generation module, used to generate a test script according to the above target test case;
[0132] The test module is used to test the error reporting interface using the test script to verify whether the error reporting interface is repaired successfully.
[0133] In the above implementation, a test script is generated based on the generated target test case. Since different automated testing tools have different grammatical specifications for executing test scripts, it is necessary to first determine the automated testing tool (such as JMeter) and then convert the test case to the test script. After the test script is generated, after the error interface problem is fixed (it may be code repair, configuration repair, data repair, etc.), the test script is used to test the error interface to verify whether the target test problem still exists in the error interface, thereby automatically verifying whether the error interface is successfully repaired.
[0134] It should be noted that the test script can also be used to replay the error of the error reporting interface in the automated test environment to reproduce the problem in order to discover the errors that occurred in the error reporting interface.
[0135] In the above-mentioned interface automation testing device, the acquisition unit is used to obtain target log data from the error log file according to the target identification information when receiving the error information from the error reporting interface. The above-mentioned error reporting interface is the interface where an error occurs during the transaction process. The above-mentioned target log data is the log data carrying the above-mentioned target identification information. The above-mentioned target identification information is the transaction serial number corresponding to the above-mentioned error reporting interface. The above-mentioned error log file includes the above-mentioned log data of all the above-mentioned error reporting interfaces; the generation unit is used to generate a target test case according to the target key data in the above-mentioned target log data. The above-mentioned target key data is the data constituting the above-mentioned target test case. The above-mentioned target test case at least includes data for testing whether the above-mentioned error reporting interface has a target test problem. One of the above-mentioned error information corresponds to a test problem. The above-mentioned target test problem is the above-mentioned test problem corresponding to the above-mentioned error information of the above-mentioned error reporting interface; the testing unit is used to test the corresponding above-mentioned error reporting interface using the above-mentioned target test case when the above-mentioned error reporting interface is repaired to verify whether the above-mentioned error reporting interface is successfully repaired. When the interface returns an error message during an actual transaction, the device obtains the log data of the error interface, and automatically generates a test case based on the log data of the error interface to test whether the error interface has a test problem corresponding to the error message. That is, the device automatically generates corresponding test cases for the actual problem scenario of the interface, thereby enriching the existing test cases. The device solves the problem in the prior art that test cases cannot be automatically generated.
[0136] The above-mentioned interface automatic testing device includes a processor and a memory. The above-mentioned acquisition unit, generation unit and test unit are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize corresponding functions.
[0137] The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set, and the problem of the inability to automatically generate test cases in the existing technology can be solved by adjusting the kernel parameters.
[0138] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0139] An embodiment of the present application provides a computer-readable storage medium, which includes a stored program. When the program is executed by a processor, the processor executes the interface automation testing method.
[0140] An embodiment of the present application provides an interface automation testing system, comprising: a backend, an interface, one or more processors, a memory, and one or more programs, wherein the backend is communicatively connected to the interface, the one or more programs are stored in the memory, and are configured to be executed by the one or more processors, and the one or more programs include methods for executing any one of the above methods.
[0141] The above-mentioned interface automation testing system includes a backend and an interface. When the interface returns an error message to the backend during an actual transaction, the backend obtains the log data of the error interface and automatically generates a test case based on the log data of the error interface to test whether the error interface has a test problem corresponding to the error message. That is, the corresponding test case is automatically generated for the actual problem scenario of the interface, thereby enriching the existing test cases. The device solves the problem in the prior art that test cases cannot be automatically generated.
[0142] An embodiment of the present application provides a device, comprising a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, at least the following steps are performed:
[0143] Step S101: Upon receiving an error message from an error reporting interface, target log data is obtained from an error log file based on target identification information. The error reporting interface is the interface where the error occurred during the transaction process, and the target log data is log data carrying the target identification information. The target identification information is the transaction serial number corresponding to the error reporting interface. The error log file includes the log data of all the error reporting interfaces.
[0144] Step S102: Generate a target test case based on the target key data in the target log data. The target key data is data constituting the target test case. The target test case includes at least data for testing whether the error reporting interface has a target test problem. Each error message corresponds to a test problem. The target test problem is the test problem corresponding to the error message of the error reporting interface.
[0145] Step S103: When the above-mentioned error reporting interface is repaired, the above-mentioned target test case is used to test the corresponding above-mentioned error reporting interface to verify whether the above-mentioned error reporting interface is repaired successfully.
[0146] The devices in this article can be servers, PCs, PADs, mobile phones, etc.
[0147] The present application also provides a computer program product, which, when executed on a data processing device, is adapted to execute a program for initializing at least the following method steps:
[0148] Step S101: Upon receiving an error message from an error reporting interface, target log data is obtained from an error log file based on target identification information. The error reporting interface is the interface where the error occurred during the transaction process, and the target log data is log data carrying the target identification information. The target identification information is the transaction serial number corresponding to the error reporting interface. The error log file includes the log data of all the error reporting interfaces.
[0149] Step S102: Generate a target test case based on the target key data in the target log data. The target key data is data constituting the target test case. The target test case includes at least data for testing whether the error reporting interface has a target test problem. Each error message corresponds to a test problem. The target test problem is the test problem corresponding to the error message of the error reporting interface.
[0150] Step S103: When the above-mentioned error reporting interface is repaired, the above-mentioned target test case is used to test the corresponding above-mentioned error reporting interface to verify whether the above-mentioned error reporting interface is repaired successfully.
[0151] In the above embodiments of the present application, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0152] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only exemplary. For example, the division of the above-mentioned units can be a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0153] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0154] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0155] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a computer-readable storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the above-mentioned methods of each embodiment of the present application. The aforementioned computer-readable storage medium includes: various media that can store program codes, such as a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0156] From the above description, it can be seen that the above embodiments of the present application achieve the following technical effects:
[0157] 1) In the interface automation testing method of the present application, first, when an error message is received from an error reporting interface, target log data is obtained from the error log file according to the target identification information. The above-mentioned error reporting interface is an interface where an error occurs during a transaction. The above-mentioned target log data is log data carrying the above-mentioned target identification information. The above-mentioned target identification information is the transaction serial number corresponding to the above-mentioned error reporting interface. The above-mentioned error log file includes the above-mentioned log data of all the above-mentioned error reporting interfaces; then, a target test case is generated according to the target key data in the above-mentioned target log data. The above-mentioned target key data is data constituting the above-mentioned target test case. The above-mentioned target test case at least includes data for testing whether the above-mentioned error reporting interface has a target test problem. One of the above-mentioned error messages corresponds to one test problem. The above-mentioned target test problem is the above-mentioned test problem corresponding to the above-mentioned error message of the above-mentioned error reporting interface; finally, when the above-mentioned error reporting interface is repaired, the corresponding above-mentioned error reporting interface is tested using the above-mentioned target test case to verify whether the above-mentioned error reporting interface is successfully repaired. When the interface returns an error message during an actual transaction, this method obtains the log data of the error interface, and automatically generates a test case based on the log data of the error interface to test whether the error interface has a test problem corresponding to the error message. That is, the corresponding test case is automatically generated for the actual problem scenario of the interface, thereby enriching the existing test cases. This method solves the problem in the existing technology that test cases cannot be automatically generated.
[0158] 2) In the interface automation testing device of the present application, the acquisition unit is used to obtain target log data from the error log file according to the target identification information when receiving the error information from the error reporting interface. The above-mentioned error reporting interface is the interface where the error occurs during the transaction process. The above-mentioned target log data is the log data carrying the above-mentioned target identification information. The above-mentioned target identification information is the transaction serial number corresponding to the above-mentioned error reporting interface. The above-mentioned error log file includes the above-mentioned log data of all the above-mentioned error reporting interfaces; the generation unit is used to generate a target test case according to the target key data in the above-mentioned target log data. The above-mentioned target key data is the data constituting the above-mentioned target test case. The above-mentioned target test case at least includes data for testing whether the above-mentioned error reporting interface has a target test problem. One of the above-mentioned error information corresponds to one test problem. The above-mentioned target test problem is the above-mentioned test problem corresponding to the above-mentioned error information of the above-mentioned error reporting interface; the testing unit is used to test the corresponding above-mentioned error reporting interface using the above-mentioned target test case when the above-mentioned error reporting interface is repaired to verify whether the above-mentioned error reporting interface is successfully repaired. When the interface returns an error message during an actual transaction, the device obtains the log data of the error interface, and automatically generates a test case based on the log data of the error interface to test whether the error interface has a test problem corresponding to the error message. That is, the device automatically generates corresponding test cases for the actual problem scenario of the interface, thereby enriching the existing test cases. The device solves the problem in the prior art that test cases cannot be automatically generated.
[0159] 3) The interface automation testing system of the present application includes a backend and an interface. When the interface returns an error message to the backend during an actual transaction, the backend obtains the log data of the error interface and automatically generates a test case based on the log data of the error interface to test whether the error interface has a test problem corresponding to the error message. That is, the corresponding test case is automatically generated for the actual problem scenario of the interface, thereby enriching the existing test cases. The device solves the problem in the prior art that test cases cannot be automatically generated.
[0160] The foregoing description is merely a preferred embodiment of the present application and is not intended to limit the present application. Persons skilled in the art will readily appreciate that various modifications and variations are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present application shall be included within the scope of protection of the present application.
Claims
1. An interface automation testing method, characterized in that: The method is applied to a backend, the backend being communicatively connected to an interface, and the method comprises: Upon receiving an error message from an error reporting interface, obtaining target log data from an error log file according to the target identification information, wherein the error reporting interface is the interface where the error occurs during the transaction process, the target log data is log data carrying the target identification information, and the target identification information is the transaction serial number corresponding to the error reporting interface, and the error log file includes the log data of all the error reporting interfaces; Generate a target test case according to the target key data in the target log data, wherein the target key data is data constituting the target test case, and the target test case includes at least data for testing whether the error reporting interface has a target test problem, each error message corresponds to a test problem, and the target test problem is the test problem corresponding to the error message of the error reporting interface; When the error reporting interface is repaired, the target test case is used to test the corresponding error reporting interface to verify whether the error reporting interface is repaired successfully; Generating a target test case according to the target key data in the target log data, comprising: extracting the target key data from the target log data; filling the target key data into a preset test case template to obtain the target test case, wherein the preset test case template is in a two-dimensional table format; The target key data includes target input data, target judgment data and target environment configuration data. Extracting the target key data from the target log data includes: extracting the target input data and the target judgment data from the target log data, the target input data being the input data of the error reporting interface during the transaction, and the target judgment data being the data used to determine whether the output data of the error reporting interface is correct; extracting the target environment configuration data from the data table corresponding to the error reporting interface based on the target input data and the data mapping relationship, the data mapping relationship being the mapping relationship between the interface and the data table, the data table being at least used to store the target environment configuration data, and the target environment configuration data being the data called by the error reporting interface during the transaction.
2. The method according to claim 1, characterized in that After generating a target test case according to the target key data in the target log data, the method further includes: The target test case is used to test the interface to be tested to check whether the interface to be tested has the target test problem, and the interface to be tested and the error reporting interface are of the same type of interface.
3. The method according to claim 1, characterized in that The target test case is used to test the corresponding error reporting interface to verify whether the error reporting interface is repaired successfully, including: Generate a test script according to the target test case; The test script is used to test the error reporting interface to verify whether the error reporting interface is repaired successfully.
4. The method according to any one of claims 1 to 3, characterized in that Before obtaining target log data from the error log file according to the target identification information, the method includes: Receive the error information returned by the error reporting interface; Generate the error log file according to the error reporting information.
5. The method according to claim 4, characterized in that The number of error messages contained in one error log file is less than or equal to a preset number.
6. An interface automation testing device, characterized in that: The device is applied to a backend, the backend is communicatively connected to an interface, and the device includes: an acquiring unit configured to acquire target log data from an error log file based on target identification information upon receiving an error message from an error reporting interface, wherein the error reporting interface is an interface where an error occurs during a transaction, the target log data is log data carrying the target identification information, the target identification information being a transaction serial number corresponding to the error reporting interface, and the error log file including the log data of all the error reporting interfaces; A generating unit, configured to generate a target test case based on target key data in the target log data, wherein the target key data is data constituting the target test case, the target test case at least including data for testing whether the error reporting interface has a target test problem, each error message corresponds to a test problem, and the target test problem is the test problem corresponding to the error message of the error reporting interface; A testing unit, configured to test the corresponding error reporting interface using the target test case when the error reporting interface is repaired, so as to verify whether the error reporting interface is repaired successfully; The generating unit includes: an extraction module for extracting the target key data from the target log data; a filling module for filling the target key data into a preset test case template to obtain the target test case, wherein the preset test case template is in the form of a two-dimensional table; The target key data includes target input data, target judgment data and target environment configuration data. The extraction module includes: a first extraction sub-module, used to extract the target input data and the target judgment data from the target log data, the target input data is the input data of the error reporting interface during the transaction process, and the target judgment data is the data used to determine whether the output data of the error reporting interface is correct; a second extraction sub-module, used to extract the target environment configuration data from the data table corresponding to the error reporting interface according to the target input data and the data mapping relationship, the data mapping relationship is the mapping relationship between the interface and the data table, and the data table is at least used to store the target environment configuration data, and the target environment configuration data is the data called by the error reporting interface during the transaction process.
7. A computer-readable storage medium, characterized in that The computer-readable storage medium includes a stored program, wherein when the program is executed by a processor, the processor executes the interface automation testing method according to any one of claims 1 to 5.
8. An interface automation testing system, characterized in that: include: A backend, an interface, one or more processors, a memory, and one or more programs, wherein the backend is communicatively connected to the interface, the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include a method for executing any one of claims 1 to 5.
Citation Information
Patent Citations
Interface testing method, electronic equipment and computer readable storage medium
CN114153747A
Automatic test case generation method, electronic equipment and storage medium
CN115080417A