Online interface testing method, electronic equipment, storage medium and device
By setting faster and slower detection cycles in monitoring and screening for error test cases, the problems of low monitoring efficiency and stress on business in the existing technology are solved, and more efficient monitoring and lower false alarm rates are achieved.
Patent Information
- Application Number
- CN202010714798.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-22
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2040-07-22
AI Technical Summary
In the prior art, monitoring efficiency is low and will put pressure on the actual business, affecting the actual business effect.
By setting two detection cycles, one is faster and the other is slower, using slower cycles for routine execution of test cases, and using faster cycles to repeatedly execute wrong test cases to screen wrong test cases, eliminate test case errors caused by business pressure, and prevent false alarms.
Improve monitoring efficiency, reduce false alarm rate, reduce pressure on online interfaces at work, and prevent impact on actual business effects.
Smart Images

Figure CN113971120B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to an online interface testing method, electronic equipment, storage medium and device. Background Art
[0002] For network application interfaces, data correctness is the key to their service quality, and the monitoring program can quickly discover errors in online interfaces, which is of great significance for ensuring service quality. The correctness monitoring of online interface data is mainly carried out by: executing a series of monitoring test cases at fixed time intervals; initiating requests to the interface, and performing data correctness verification after obtaining the data returned by the interface; triggering an alarm mechanism when the verification result of the test case is an error or the error rate of the verification result exceeds the threshold.
[0003] Currently, monitoring efficiency is usually improved through sequential test cases or concurrent test cases, which can monitor the occurrence of errors when problems occur in the interface. However, this method will put pressure on the actual business and affect the actual business results. Summary of the invention
[0004] The main purpose of the present invention is to provide an online interface testing method, electronic equipment, storage medium and device, aiming to solve the technical problems in the prior art that the monitoring efficiency is low and the pressure on actual business is generated.
[0005] To achieve the above object, the present invention provides a method for testing an online interface, the method comprising the following steps:
[0006] Testing the online interface to be monitored using test cases in the first test case set according to a first preset period;
[0007] When the execution result of the test case in the first test case set is a test failure, recording the test case corresponding to the test failure into the second test case set;
[0008] Testing the online interface to be monitored by using the test cases in the second test case set according to a second preset period, wherein the first preset period is greater than the second preset period;
[0009] When the execution result of the test case is a test success, removing the test case corresponding to the test success from the second test case set;
[0010] The test result of the online interface to be monitored is determined according to the second test case set.
[0011] Preferably, the step of determining the test result of the online interface to be monitored according to the second test case set specifically includes:
[0012] querying each test case in the second test case set according to a preset query period to obtain a query result, wherein the preset query period is greater than the second preset period;
[0013] The test result of the online interface to be monitored is determined based on the query result.
[0014] Preferably, the step of determining the test result of the online interface to be monitored based on the query result specifically includes:
[0015] Determine whether there is a test case that meets a preset condition in the second test case set according to the query result;
[0016] When there is a test case that meets the preset condition in the second test case set, the test result of the online interface to be monitored is determined to be an interface failure.
[0017] Preferably, after the step of determining that the test result of the online interface to be monitored is an interface failure when there is a test case that meets the preset condition in the second test case set, the method further includes:
[0018] Fault prompt information is generated based on the test cases in the second test case set that meet the preset conditions, and the fault prompt information is displayed.
[0019] Preferably, the step of querying each test case in the second test case set according to a preset query period to obtain a query result specifically includes:
[0020] Each test case in the second test case set is queried according to a preset query cycle and preset conditions to obtain a query result.
[0021] Preferably, when the execution result of the test case in the first test case set is a test failure, the step of recording the test case corresponding to the test failure into the second test case set specifically includes:
[0022] When the execution result of the test case in the first test case set is a test failure, recording the test case that failed the test and the number of failures of the test case in the second test case set;
[0023] After the step of testing the online interface to be monitored by using the test cases in the second test case set according to the second preset period, the method further includes:
[0024] When the execution result of the test case is a test failure, the number of failures of the corresponding test case in the second test case set is updated.
[0025] Preferably, the preset condition is that the number of test failures of the test case is greater than a preset number threshold.
[0026] Preferably, the step of testing the online interface to be monitored by using the test cases in the first test case set according to the first preset period specifically includes:
[0027] Reading test cases from the first test case set in sequence according to a first preset order according to a first preset period, and using the read test cases as current test cases;
[0028] A test request is sent to the online interface to be monitored according to the current test case, and a first test result fed back by the online interface to be monitored is received, and the first test result is used as the execution result of the test case.
[0029] Preferably, after the step of sending a test request to the online interface to be monitored according to the current test case, receiving a first test result fed back by the online interface to be monitored, and using the first test result as the execution result of the test case, the method further includes:
[0030] Determine whether the first test result is a test failure according to a preset execution result.
[0031] Preferably, it is characterized in that the step of testing the online interface to be monitored by using the test cases in the second test case set according to the second preset period specifically includes:
[0032] Reading test cases from the second test case set in sequence according to a second preset order according to a second preset period, and using the read test cases as current test cases;
[0033] A test request is sent to the online interface to be monitored according to the current test case, and a second test result fed back by the online interface to be monitored is received, and the second test result is used as the execution result of the test case.
[0034] Preferably, after the step of sending a test request to the online interface to be monitored according to the current test case, receiving a second test result fed back by the online interface to be monitored, and using the second test result as the execution result of the test case, the step further includes:
[0035] Determine whether the second test result is a test failure according to a preset execution result.
[0036] Preferably, before the step of testing the online interface to be monitored by using the test cases in the first test case set according to the first preset period, the method further includes:
[0037] A test case table to be tested is obtained, and a first test case set is generated according to the test case table.
[0038] In addition, to achieve the above-mentioned purpose, the present invention also proposes an electronic device, which includes a memory, a processor, and a test program for an online interface stored in the memory and runnable on the processor, wherein the test program for the online interface is configured to implement the steps of the online interface test method as described above.
[0039] In addition, to achieve the above objectives, the present invention also proposes a storage medium, on which a test program for an online interface is stored, and when the test program for the online interface is executed by a processor, the steps of the online interface test method described above are implemented.
[0040] In addition, to achieve the above-mentioned purpose, the present invention further provides a testing device for an online interface, the testing device for an online interface comprising:
[0041] A first execution module is used to test the online interface to be monitored through the test cases in the first test case set according to the first preset period; when the execution result of the test cases in the first test case set is a test failure, the test cases corresponding to the test failure are recorded in the second test case set;
[0042] A second execution module, configured to test the online interface to be monitored through the test cases in the second test case set according to a second preset period, wherein the first preset period is greater than the second preset period; when the execution result of the test case is a test success, remove the test case corresponding to the test success from the second test case set;
[0043] A query module is used to determine the test result of the online interface to be monitored according to the second test case set.
[0044] Preferably, the query module is specifically used to query each test case in the second test case set according to a preset query period to obtain a query result, and the preset query period is greater than the second preset period;
[0045] Determine whether there is a test case that meets a preset condition in the second test case set according to the query result;
[0046] When there is a test case that meets the preset condition in the second test case set, the test result of the online interface to be monitored is determined to be an interface failure.
[0047] Preferably, the device further comprises: a prompt module, configured to generate fault prompt information based on the test cases in the second test case set that meet preset conditions, and to display the fault prompt information.
[0048] Preferably, the first execution module is further specifically configured to record the failed test case and the number of failures of the test case in the second test case set when the execution result of the test case in the first test case set is a test failure;
[0049] The second execution module is further configured to update the number of failures of the corresponding test case in the second test case set when the execution result of the test case is a test failure;
[0050] The preset condition is that the number of test failures of the test case is greater than a preset number threshold.
[0051] Preferably, the first execution module is specifically configured to sequentially read test cases from the first test case set in a first preset order according to a first preset period, and use the read test cases as current test cases;
[0052] Sending a test request to the online interface to be monitored according to the current test case, receiving a first test result fed back by the online interface to be monitored, and using the first test result as the execution result of the test case;
[0053] Determine whether the first test result is a test failure according to a preset execution result;
[0054] The second execution module is specifically configured to sequentially read test cases from a second test case set in a second preset order according to a second preset period, and use the read test cases as current test cases;
[0055] Sending a test request to the online interface to be monitored according to the current test case, receiving a second test result fed back by the online interface to be monitored, and using the second test result as the execution result of the test case;
[0056] Determine whether the second test result is a test failure according to a preset execution result.
[0057] Preferably, the device further comprises a generating module, which is used to obtain a test case table to be tested, and generate a first test case set according to the test case table.
[0058] In the present invention, the online interface to be monitored is tested by using the test cases in the first test case set according to the first preset period; when the execution result of the test cases in the first test case set is a test failure, the test cases corresponding to the test failure are recorded in the second test case set; the online interface to be monitored is tested by using the test cases in the second test case set according to the second preset period, and the first preset period is greater than the second preset period; when the execution result of the test case is a test success, the test case corresponding to the test success is removed from the second test case set; and the test result of the online interface to be monitored is determined according to the second test case set. The present invention sets two detection cycles, one of which is faster and the other is slower, uses the slower cycle to perform regular execution of the test cases, and uses the faster cycle to repeatedly execute the erroneous test cases, so as to screen the erroneous test cases, eliminate the test case errors caused by business pressure, prevent false alarms, improve monitoring efficiency, reduce false alarm rate, reduce pressure on the online interface in work, and prevent impact on actual business effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 It is a schematic diagram of the structure of an electronic device in a hardware operating environment involved in an embodiment of the present invention;
[0060] Figure 2 It is a flowchart of a first embodiment of a method for testing an online interface of the present invention;
[0061] Figure 3 It is a flow chart of a second embodiment of a method for testing an online interface of the present invention;
[0062] Figure 4 It is a flow chart of a third embodiment of a method for testing an online interface of the present invention;
[0063] Figure 5 It is a flowchart of a fourth embodiment of a method for testing an online interface of the present invention;
[0064] Figure 6 It is a structural block diagram of the first embodiment and the second embodiment of the testing device of the online interface of the present invention.
[0065] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0066] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0067] Reference Figure 1 , Figure 1The figure is a schematic diagram of the structure of an electronic device of the hardware operating environment involved in the embodiment of the present invention.
[0068] like Figure 1 As shown, the electronic device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), and the user interface 1003 may also include a standard wired interface and a wireless interface. The wired interface of the user interface 1003 may be a USB interface in the present invention. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (WIreless-FIdelity, WI-FI) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM) memory, or a stable memory (Non-volatile Memory, NVM), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0069] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0070] like Figure 1 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a test program for an online interface.
[0071] exist Figure 1 In the electronic device shown, the network interface 1004 is mainly used to connect to the background server and communicate data with the background server; the user interface 1003 is mainly used to connect the user electronic device; the electronic device calls the online interface test program stored in the memory 1005 through the processor 1001, and executes the online interface test method provided by the embodiment of the present invention.
[0072] Based on the above hardware structure, an embodiment of the testing method of the online interface of the present invention is proposed.
[0073] Reference Figure 2 , Figure 2 The figure is a flow chart of a first embodiment of a method for testing an online interface of the present invention, and provides a first embodiment of a method for testing an online interface of the present invention.
[0074] In a first embodiment, the online interface testing method comprises the following steps:
[0075] Step S10: Testing the online interface to be monitored by using the test cases in the first test case set according to a first preset period.
[0076] It should be noted that the test cases include various test cases for functional testing, performance testing, parameter testing and security testing of online interfaces. Among them, the functional test is used to test the basic functions of the online interface to see whether it can meet the business logic requirements, such as process coverage and exception coverage. The performance test is used to test the tolerance range of various performances of the online interface, such as system throughput, number of concurrent users, response time and server resource utilization. The parameter test is used to test the input parameters of the online interface in various possible scenarios, such as output result test (normal return type coverage, abnormal return type coverage, etc.) and input parameter test (parameter presence or null, required parameters, optional parameters, parameter type, parameter constraint conditions, parameter boundary value, parameter equivalence class and parameter combination, etc.). The security test is used to test the security of the online interface, such as information encryption, parameter verification and prevention of malicious access. The embodiment of the present invention only explains the test cases and does not limit the types and functions of the test cases.
[0077] In a specific implementation, for example, the first test case set includes N test cases, including: a first test case, a second test case, a third test case ... an Nth test case, the first test case is used to detect the response time of the online interface, the second test case is used to detect the security performance of the online interface to prevent malicious access, the third test case is used to detect the process coverage of the online interface, etc. The first test case set may include multiple, various or the same test cases.
[0078] Step S20: When the execution result of the test case in the first test case set is a test failure, the test case corresponding to the test failure is recorded in the second test case set.
[0079] It should be noted that, since the monitoring of the online interface is carried out during the operation of the online interface, the execution results of some test cases will be affected by the actual situation. Therefore, a single execution failure of a test case does not indicate the current failure of the online interface. Executing test cases sequentially or executing all test cases concurrently can improve monitoring efficiency, but it will put pressure on actual business. The test cases with execution results of test failure are stored in the second test case set, and the second test case set is used to store test cases that have failed at least once.
[0080] Step S30: testing the online interface to be monitored using the test cases in the second test case set according to a second preset period, wherein the first preset period is greater than the second preset period.
[0081] It is easy to understand that the test cases in the second test case set have failed at least once, so the test cases in the second test case set are quickly executed, and the first preset period is greater than the second preset period. In a specific implementation, the first preset period is a preset multiple of the second preset period. For example: the first preset period is a slow period of 30s, the second preset period is a fast period of 10s, the first test case is used to detect the response time of the online interface, the first test case fails to execute once, and the response time of the online interface is greater than the preset time, then the first test case is recorded in the second test case set. The test cases in the second test case set that have failed at least once are executed according to the shorter second preset period.
[0082] It should be noted that the slow cycle executes all test cases in the set on the online interface in sequence, and the fast cycle quickly executes the test cases that may have correctness problems on the online interface. Since all test cases are not executed repeatedly, only part of them is executed, which reduces the pressure on the actual business of the online interface.
[0083] Step S40: When the execution result of the test case is a test success, remove the test case corresponding to the test success from the second test case set.
[0084] It is easy to understand that if the test case in the second test case set has a successful test, it is removed from the second test case set, and the test case is no longer executed in a fast cycle until the test case fails again at least once. This is equivalent to clearing its failure count to zero, and when executing the test cases in the second test case set, skipping the test cases with zero failure count can reduce the pressure on the actual business.
[0085] Step S50: Determine the test result of the online interface to be monitored according to the second test case set.
[0086] It is easy to understand that when the number of failures of the test cases in the second test case set reaches a certain threshold, it can be confirmed that there is a problem with the correctness of the data fed back by the online interface, and a monitoring alarm can be issued.
[0087] In this embodiment, the online interface to be monitored is tested by using the test cases in the first test case set according to the first preset period; when the execution result of the test cases in the first test case set is a test failure, the test cases corresponding to the test failure are recorded in the second test case set; the online interface to be monitored is tested by using the test cases in the second test case set according to the second preset period, and the first preset period is greater than the second preset period; when the execution result of the test case is a test success, the test case corresponding to the test success is removed from the second test case set; and the test result of the online interface to be monitored is determined according to the second test case set. The present invention sets two detection cycles, one of which is faster and the other is slower, uses the slower cycle to perform regular execution of the test cases, and uses the faster cycle to repeatedly execute the erroneous test cases, so as to screen the erroneous test cases, eliminate the test case errors caused by business pressure, prevent false alarms, improve monitoring efficiency, reduce false alarm rate, reduce pressure on the online interface in work, and prevent impact on actual business effects.
[0088] Reference Figure 3 , Figure 3 This is a flow chart of a second embodiment of the online interface testing method of the present invention. Figure 2 The first embodiment shown provides a second embodiment of the online interface testing method of the present invention.
[0089] In the second embodiment, the step S50 includes:
[0090] Step S51: query each test case in the second test case set according to a preset query period to obtain a query result, wherein the preset query period is greater than the second preset period.
[0091] It should be noted that the second preset period is a period of a test case with at least one fast execution failure, so the preset query period is greater than the second preset period. In a specific implementation, the preset query period can be 30s, so as to quickly discover the correctness problems of the online interface and issue an alarm or notification. At the same time, the preset query period is relatively long to avoid the impact of frequent queries on actual business.
[0092] Furthermore, the step S51 specifically includes: querying each test case in the second test case set according to a preset query cycle and preset conditions to obtain a query result.
[0093] Step S52: Determine the test result of the online interface to be monitored based on the query result.
[0094] In this embodiment, the step S52 specifically includes:
[0095] Step S521: judging whether the second test case set contains a test case that meets a preset condition according to the query result. The preset condition is that the number of test failures of the test case is greater than a preset number threshold.
[0096] It is easy to understand that the query result is each test case in the second test case set and its corresponding number of failures. In a specific implementation, if the execution method of skipping the test cases with zero failure times is adopted, the query method of skipping the test cases with zero failure times can also be adopted to only query the test cases with at least one failure times.
[0097] It is easy to understand that, in a specific implementation, the preset condition may also be that the failure rate of the test case is lower than the preset failure rate. In this embodiment, the preset number threshold is set to 2, that is, if the number of failures of a test case in the second test case set is greater than or equal to 2, an alarm is issued.
[0098] Step S522: when there is a test case meeting a preset condition in the second test case set, the test result of the online interface to be monitored is determined to be an interface failure.
[0099] It is easy to understand that, for example: the first test case in the first test case set is a response time test. After the first test case fails once, the failure of the first test case and the first test case are recorded in the second test case set. During the execution of the second test case set, the number of failures of the first test case increases by one, the current number of failures is 2, and the number of failures queried is 2, then the test result of the monitored display interface is determined to be an interface failure.
[0100] In this embodiment, after step S522, the following steps are further included:
[0101] Step S523: Generate fault prompt information based on the test cases in the second test case set that meet the preset conditions, and display the fault prompt information.
[0102] It is easy to understand that when there is a problem with the correctness of the online interface, the alarm mechanism is triggered and a reminder can be sent to the developer or tester via email. In a specific implementation, for example, if the current number of failures of the first test case is 2 and the preset condition is not met, a prompt message of a response time failure is generated according to the first test case, and the prompt message includes the time of the failure, the number of failures of the first test case, the time of failure and the content of the first test case, and further includes the preset test result corresponding to the first test case, so that the developer or tester can view it.
[0103] In this embodiment, by querying the test results of the online interface according to the query cycle, the correctness problems of the online interface can be quickly discovered, and the developers or testers can be reminded. The query cycle is set reasonably to prevent the actual business results from being affected.
[0104] Reference Figure 4 , Figure 4 This is a flow chart of a third embodiment of the online interface testing method of the present invention. Figure 2 The first embodiment shown or the above Figure 3 The second embodiment shown here is a third embodiment of the online interface testing method of the present invention. This embodiment is described based on the first embodiment.
[0105] In the third embodiment, the step S20 specifically includes:
[0106] Step S21: when the execution result of the test case in the first test case set is test failure, the test case that failed the test and the number of failures of the test case are recorded in the second test case set.
[0107] It is easy to understand that the test cases in the first test case set and the test cases in the second test case set are executed according to the first preset period and the second preset period respectively, and the two are executed simultaneously, but the execution interval of the test cases in the second test case set is shorter, so as to achieve the re-execution of the test cases that have failed at least once, reduce the false alarm rate, and avoid the pressure of concurrent execution and sequential execution on actual business.
[0108] After step S30, the method further includes:
[0109] Step S31: when the execution result of the test case is a test failure, updating the number of failures of the corresponding test case in the second test case set.
[0110] It is easy to understand that when the test case in the second test case set is executed again, if the test case fails to be executed continuously, the failure count will be increased once. Once the test case is successfully executed, the test case is removed from the second test case set, which is equivalent to clearing the failure count of the test case to zero, and the test case will not be executed again until the failure count of the test case is at least one.
[0111] Reference Figure 5 , Figure 5 This is a flow chart of a fourth embodiment of the online interface testing method of the present invention. Figure 2 The first embodiment shown or the above Figure 3The second embodiment shown here is a fourth embodiment of the online interface testing method of the present invention. This embodiment is described based on the first embodiment.
[0112] In the fourth embodiment, the step S10 specifically includes:
[0113] Step S11: Read test cases from a first test case set in sequence according to a first preset order according to a first preset period, and use the read test cases as current test cases.
[0114] It is easy to understand that the first preset sequence is a sequential loop, which reads each test case in the first test case set in turn and loops, and uses the currently read test case as the current test case.
[0115] Step S12: Send a test request to the online interface to be monitored according to the current test case, receive a first test result fed back by the online interface to be monitored, and use the first test result as the execution result of the test case.
[0116] It is easy to understand that, according to the data of the current test case, an http (HTTP, Hypertext Transfer Protocol) request is sent to the online interface, and after obtaining the interface data, the data result of a single test case is obtained, that is, the first test result, and the data result is used as the execution result of the test case.
[0117] After step S12, the method further includes:
[0118] Step S13: determining whether the first test result is a test failure according to a preset execution result.
[0119] It is easy to understand that for different test cases, there are different test results corresponding to different preset execution results. For example, for test cases used to test response time, there is a preset time as the preset execution result; for test cases for preventing malicious access, there is a preset execution result for intercepting access; for test cases for testing system throughput, there is a preset throughput as the preset execution result.
[0120] The step S30 specifically includes:
[0121] Step S31: Read test cases from a second test case set in sequence according to a second preset order according to a second preset period, and use the read test cases as current test cases.
[0122] It is easy to understand that by removing the test cases whose execution results are successful results, the test cases in the second test case set can be read sequentially; by clearing the test cases whose execution results are successful results, the test cases in the second test case set are executed sequentially, skipping the test cases with zero failure times.
[0123] Step S32: Send a test request to the online interface to be monitored according to the current test case, and receive a second test result fed back by the online interface to be monitored, and use the second test result as the execution result of the test case. After step S32, it also includes: step S33: determine whether the second test result is a test failure according to the preset execution result.
[0124] It is easy to understand that the specific implementation methods are as described above and will not be repeated here.
[0125] Before step S10, the method further includes:
[0126] Step S101: Obtain a test case table to be tested, and generate a first test case set according to the test case table.
[0127] It should be understood that the test case table can be a test case table stored in an Excel file. Testers or developers can add or change the content of the test case table at any time, obtain some or all of the test cases in the test case table to generate a first test case set, and the test cases in the first test case set can be stored in a data table or database, and the second test case set can also be stored in a data table or database.
[0128] In addition, an embodiment of the present invention further provides a storage medium, on which a test program for an online interface is stored. When the test program for the online interface is executed by a processor, the following steps are implemented:
[0129] Testing the online interface to be monitored using test cases in the first test case set according to a first preset period;
[0130] When the execution result of the test case in the first test case set is a test failure, recording the test case corresponding to the test failure into the second test case set;
[0131] Testing the online interface to be monitored by using the test cases in the second test case set according to a second preset period, wherein the first preset period is greater than the second preset period;
[0132] When the execution result of the test case is a test success, removing the test case corresponding to the test success from the second test case set;
[0133] The test result of the online interface to be monitored is determined according to the second test case set.
[0134] Furthermore, when the test program of the online interface is executed by the processor, the following operations are also implemented:
[0135] querying each test case in the second test case set according to a preset query period to obtain a query result, wherein the preset query period is greater than the second preset period;
[0136] The test result of the online interface to be monitored is determined based on the query result.
[0137] Furthermore, when the test program of the online interface is executed by the processor, the following operations are also implemented:
[0138] Determine whether there is a test case that meets a preset condition in the second test case set according to the query result;
[0139] When there is a test case that meets the preset condition in the second test case set, the test result of the online interface to be monitored is determined to be an interface failure.
[0140] Furthermore, when the test program of the online interface is executed by the processor, the following operations are also implemented:
[0141] Fault prompt information is generated based on the test cases in the second test case set that meet the preset conditions, and the fault prompt information is displayed.
[0142] Furthermore, when the test program of the online interface is executed by the processor, the following operations are also implemented:
[0143] Each test case in the second test case set is queried according to a preset query cycle and preset conditions to obtain a query result.
[0144] Furthermore, when the test program of the online interface is executed by the processor, the following operations are also implemented:
[0145] When the execution result of the test case in the first test case set is a test failure, recording the test case that failed the test and the number of failures of the test case in the second test case set;
[0146] When the execution result of the test case is a test failure, the number of failures of the corresponding test case in the second test case set is updated.
[0147] Furthermore, the preset condition is that the number of test failures of the test case is greater than a preset number threshold.
[0148] Furthermore, when the test program of the online interface is executed by the processor, the following operations are also implemented:
[0149] Reading test cases from the first test case set in sequence according to a first preset order according to a first preset period, and using the read test cases as current test cases;
[0150] A test request is sent to the online interface to be monitored according to the current test case, and a first test result fed back by the online interface to be monitored is received, and the first test result is used as the execution result of the test case.
[0151] Furthermore, when the test program of the online interface is executed by the processor, the following operations are also implemented:
[0152] Determine whether the first test result is a test failure according to a preset execution result.
[0153] Furthermore, when the test program of the online interface is executed by the processor, the following operations are also implemented:
[0154] Reading test cases from the second test case set in sequence according to a second preset order according to a second preset period, and using the read test cases as current test cases;
[0155] A test request is sent to the online interface to be monitored according to the current test case, and a second test result fed back by the online interface to be monitored is received, and the second test result is used as the execution result of the test case.
[0156] Furthermore, when the test program of the online interface is executed by the processor, the following operations are also implemented:
[0157] Determine whether the second test result is a test failure according to a preset execution result.
[0158] Furthermore, when the test program of the online interface is executed by the processor, the following operations are also implemented:
[0159] A test case table to be tested is obtained, and a first test case set is generated according to the test case table.
[0160] In this embodiment, the online interface to be monitored is tested by using the test cases in the first test case set according to the first preset period; when the execution result of the test cases in the first test case set is a test failure, the test cases corresponding to the test failure are recorded in the second test case set; the online interface to be monitored is tested by using the test cases in the second test case set according to the second preset period, and the first preset period is greater than the second preset period; when the execution result of the test case is a test success, the test case corresponding to the test success is removed from the second test case set; and the test result of the online interface to be monitored is determined according to the second test case set. The present invention sets two detection cycles, one of which is faster and the other is slower, uses the slower cycle to perform regular execution of the test cases, and uses the faster cycle to repeatedly execute the erroneous test cases, so as to screen the erroneous test cases, eliminate the test case errors caused by business pressure, prevent false alarms, improve monitoring efficiency, reduce false alarm rate, reduce pressure on the online interface in work, and prevent impact on actual business effects.
[0161] In addition, refer to Figure 6 The embodiment of the present invention further provides a testing device for an online interface, the testing device for the online interface comprising:
[0162] The first execution module 10 is used to test the monitored online interface through the test cases in the first test case set according to the first preset period; when the execution result of the test cases in the first test case set is test failure, the test cases corresponding to the test failure are recorded in the second test case set.
[0163] It should be noted that the test cases include various test cases for functional testing, performance testing, parameter testing and security testing of online interfaces. Among them, the functional test is used to test the basic functions of the online interface to see whether it can meet the business logic requirements, such as process coverage and exception coverage. The performance test is used to test the tolerance range of various performances of the online interface, such as system throughput, number of concurrent users, response time and server resource utilization. The parameter test is used to test the input parameters of the online interface in various possible scenarios, such as output result test (normal return type coverage, abnormal return type coverage, etc.) and input parameter test (parameter presence or null, required parameters, optional parameters, parameter type, parameter constraint conditions, parameter boundary value, parameter equivalence class and parameter combination, etc.). The security test is used to test the security of the online interface, such as information encryption, parameter verification and prevention of malicious access. The embodiment of the present invention only explains the test cases and does not limit the types and functions of the test cases.
[0164] In a specific implementation, for example, the first test case set includes N test cases, including: a first test case, a second test case, a third test case ... an Nth test case, the first test case is used to detect the response time of the online interface, the second test case is used to detect the security performance of the online interface to prevent malicious access, the third test case is used to detect the process coverage of the online interface, etc. The first test case set may include multiple, various or the same test cases.
[0165] It should be noted that since the monitoring of the online interface is carried out during the online interface operation, the execution results of some test cases will be affected by the actual situation. Therefore, a single execution failure of a test case does not indicate the current failure of the online interface. Sequential execution of test cases or concurrent execution of all test cases can improve monitoring efficiency, but will put pressure on actual business. The test cases with execution results of test failure are stored in the second test case set, and the second test case set is used to store test cases that have failed at least once.
[0166] The second execution module 20 is used to test the online interface to be monitored through the test cases in the second test case set according to a second preset period, and the first preset period is greater than the second preset period; when the execution result of the test case is a successful test, the test case corresponding to the successful test is removed from the second test case set.
[0167] It is easy to understand that the test cases in the second test case set have failed at least once, so the test cases in the second test case set are quickly executed, and the first preset period is greater than the second preset period. In a specific implementation, the first preset period is a preset multiple of the second preset period. For example: the first preset period is a slow period of 30s, the second preset period is a fast period of 10s, the first test case is used to detect the response time of the online interface, the first test case fails to execute once, and the response time of the online interface is greater than the preset time, then the first test case is recorded in the second test case set. The test cases in the second test case set that have failed at least once are executed according to the shorter second preset period.
[0168] It is easy to understand that if the test case in the second test case set has a successful test, it is removed from the second test case set, and the test case is no longer executed in a fast cycle until the test case fails again at least once. This is equivalent to clearing its failure count to zero, and when executing the test cases in the second test case set, skipping the test cases with zero failure count can reduce the pressure on the actual business.
[0169] It should be noted that the slow cycle executes all test cases in the set on the online interface in sequence, and the fast cycle quickly executes the test cases that may have correctness problems on the online interface. Since all test cases are not executed repeatedly, only part of them is executed, which reduces the pressure on the actual business of the online interface.
[0170] The query module 30 is used to determine the test result of the online interface to be monitored according to the second test case set.
[0171] It is easy to understand that when the number of failures of the test cases in the second test case set reaches a certain threshold, it can be confirmed that there is a problem with the correctness of the data fed back by the online interface, and a monitoring alarm can be issued.
[0172] In this embodiment, the online interface to be monitored is tested by using the test cases in the first test case set according to the first preset period; when the execution result of the test cases in the first test case set is a test failure, the test cases corresponding to the test failure are recorded in the second test case set; the online interface to be monitored is tested by using the test cases in the second test case set according to the second preset period, and the first preset period is greater than the second preset period; when the execution result of the test case is a test success, the test case corresponding to the test success is removed from the second test case set; and the test result of the online interface to be monitored is determined according to the second test case set. The present invention sets two detection cycles, one of which is faster and the other is slower, uses the slower cycle to perform regular execution of the test cases, and uses the faster cycle to repeatedly execute the erroneous test cases, so as to screen the erroneous test cases, eliminate the test case errors caused by business pressure, prevent false alarms, improve monitoring efficiency, reduce false alarm rate, reduce pressure on the online interface in work, and prevent impact on actual business effects.
[0173] Continue to refer to Figure 6 , a second embodiment of the testing device for the online interface of the present invention is proposed.
[0174] The query module 30 is specifically configured to query each test case in the second test case set according to a preset query period to obtain a query result, wherein the preset query period is greater than the second preset period.
[0175] It should be noted that the second preset period is a period of a test case with at least one fast execution failure, so the preset query period is greater than the second preset period. In a specific implementation, the preset query period can be 30s, so as to quickly discover the correctness problems of the online interface and issue an alarm or notification. At the same time, the preset query period is relatively long to avoid the impact of frequent queries on actual business.
[0176] Determine whether the second test case set contains a test case that meets a preset condition according to the query result. If the second test case set contains a test case that meets the preset condition, determine that the test result of the online interface to be monitored is an interface fault.
[0177] It is easy to understand that the query result is each test case in the second test case set and its corresponding number of failures. In a specific implementation, if the execution method of skipping the test cases with zero failure times is adopted, the query method of skipping the test cases with zero failure times can also be adopted to only query the test cases with at least one failure times.
[0178] It is easy to understand that, in a specific implementation, the preset condition may also be that the failure rate of the test case is lower than the preset failure rate. In this embodiment, the preset number threshold is set to 2, that is, if the number of failures of a test case in the second test case set is greater than or equal to 2, an alarm is issued.
[0179] It is easy to understand that, for example: the first test case in the first test case set is a response time test. After the first test case fails once, the failure of the first test case and the first test case are recorded in the second test case set. During the execution of the second test case set, the number of failures of the first test case increases by one, the current number of failures is 2, and the number of failures queried is 2, then the test result of the monitored display interface is determined to be an interface failure.
[0180] The prompt module 40 is used to generate fault prompt information based on the test cases in the second test case set that meet the preset conditions, and display the fault prompt information.
[0181] It is easy to understand that when there is a problem with the correctness of the online interface, the alarm mechanism is triggered and a reminder can be sent to the developer or tester via email. In a specific implementation, for example, if the current number of failures of the first test case is 2 and the preset condition is not met, a prompt message of a response time failure is generated according to the first test case, and the prompt message includes the time of the failure, the number of failures of the first test case, the time of failure and the content of the first test case, and further includes the preset test result corresponding to the first test case, so that the developer or tester can view it.
[0182] In this embodiment, by querying the test results of the online interface according to the query cycle, the correctness problems of the online interface can be quickly discovered, and the developers or testers can be reminded. The query cycle is set reasonably to prevent the actual business results from being affected.
[0183] The first execution module 10 is further specifically configured to record the failed test case and the number of failures of the test case into the second test case set when the execution result of the test case in the first test case set is a test failure.
[0184] It is easy to understand that the test cases in the first test case set and the test cases in the second test case set are executed according to the first preset period and the second preset period respectively, and the two are executed simultaneously, but the execution interval of the test cases in the second test case set is shorter, so as to achieve the re-execution of the test cases that have failed at least once, reduce the false alarm rate, and avoid the pressure of concurrent execution and sequential execution on actual business.
[0185] The second execution module 20 is further configured to update the number of failures of the corresponding test case in the second test case set when the execution result of the test case is a test failure.
[0186] It is easy to understand that when the test case in the second test case set is executed again, if the test case fails to be executed continuously, the failure count will be increased once. Once the test case is successfully executed, the test case is removed from the second test case set, which is equivalent to clearing the failure count of the test case to zero, and the test case will not be executed again until the failure count of the test case is at least one.
[0187] The first execution module 10 is specifically configured to sequentially read test cases from a first test case set in a first preset order according to a first preset period, and use the read test cases as current test cases.
[0188] It is easy to understand that the first preset sequence is a sequential loop, which reads each test case in the first test case set in turn and loops, and uses the currently read test case as the current test case.
[0189] A test request is sent to the online interface to be monitored according to the current test case, and a first test result fed back by the online interface to be monitored is received, and the first test result is used as the execution result of the test case.
[0190] It is easy to understand that, according to the data of the current test case, an http (HTTP, Hypertext Transfer Protocol) request is sent to the online interface, and after obtaining the interface data, the data result of a single test case is obtained, that is, the first test result, and the data result is used as the execution result of the test case.
[0191] Determine whether the first test result is a test failure according to a preset execution result.
[0192] It is easy to understand that for different test cases, there are different test results corresponding to different preset execution results. For example, for test cases used to test response time, there is a preset time as the preset execution result; for test cases for preventing malicious access, there is a preset execution result for intercepting access; for test cases for testing system throughput, there is a preset throughput as the preset execution result.
[0193] The second execution module 20 is specifically configured to sequentially read test cases from the second test case set in a second preset order according to a second preset period, and use the read test cases as current test cases.
[0194] It is easy to understand that by removing the test cases whose execution results are successful results, the test cases in the second test case set can be read sequentially; by clearing the test cases whose execution results are successful results, the test cases in the second test case set are executed sequentially, skipping the test cases with zero failure times.
[0195] Send a test request to the online interface to be monitored according to the current test case, receive a second test result fed back by the online interface to be monitored, and use the second test result as the execution result of the test case; and determine whether the second test result is a test failure according to a preset execution result. The specific execution method is as described above and will not be repeated here.
[0196] The generating module 50 is used to obtain a test case table to be tested, and generate a first test case set according to the test case table.
[0197] It should be understood that the test case table can be a test case table stored in an Excel file. Testers or developers can add or change the content of the test case table at any time, obtain some or all of the test cases in the test case table to generate a first test case set, and the test cases in the first test case set can be stored in a data table or database, and the second test case set can also be stored in a data table or database.
[0198] Other embodiments or specific implementations of the online interface testing device of the present invention may refer to the above-mentioned method embodiments, which will not be described in detail here.
[0199] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or system including the element.
[0200] The serial numbers of the embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments. In a unit claim that lists several means, several of these means may be embodied by the same hardware item. The use of the words first, second, and third, etc. does not indicate any order and these words may be interpreted as identifiers.
[0201] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory image (ROM) / random access memory (RAM), a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal electronic device (which can be a mobile phone, a computer, a server, an air conditioner, or a network electronic device, etc.) to execute the methods described in each embodiment of the present invention.
[0202] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for testing an online interface, characterized in that: The online interface testing method comprises the following steps: Testing the online interface to be monitored using test cases in the first test case set according to a first preset period; When the execution result of the test case in the first test case set is a test failure, recording the test case corresponding to the test failure and the number of failures of the test case in the second test case set; Testing the online interface to be monitored by using the test cases in the second test case set according to a second preset period, wherein the first preset period is greater than the second preset period; When the execution result of the test case is a test failure, updating the number of failures of the corresponding test case in the second test case set; When the execution result of the test case is a test success, removing the test case corresponding to the test success from the second test case set; querying each test case in the second test case set according to a preset query period to obtain a query result, wherein the preset query period is greater than the second preset period; Determine whether there is a test case that meets a preset condition in the second test case set according to the query result; When there is a test case that meets a preset condition in the second test case set, the test result of the online interface to be monitored is determined to be an interface failure, and the preset condition is that the number of test failures of the test case is greater than a preset number threshold.
2. The online interface testing method according to claim 1, characterized in that: After the step of determining that the test result of the online interface to be monitored is an interface failure when there is a test case that meets the preset condition in the second test case set, the method further includes: Fault prompt information is generated based on the test cases in the second test case set that meet the preset conditions, and the fault prompt information is displayed.
3. The online interface testing method according to claim 1, characterized in that: The step of querying each test case in the second test case set according to a preset query period to obtain a query result specifically includes: Each test case in the second test case set is queried according to a preset query cycle and preset conditions to obtain a query result.
4. The online interface testing method according to any one of claims 1 to 3, characterized in that: The step of testing the online interface to be monitored by using the test cases in the first test case set according to the first preset period specifically includes: Reading test cases from the first test case set in sequence according to a first preset order according to a first preset period, and using the read test cases as current test cases; A test request is sent to the online interface to be monitored according to the current test case, and a first test result fed back by the online interface to be monitored is received, and the first test result is used as the execution result of the test case.
5. The online interface testing method according to claim 4, characterized in that: After the step of sending a test request to the online interface to be monitored according to the current test case, receiving a first test result fed back by the online interface to be monitored, and using the first test result as the execution result of the test case, the method further includes: Determine whether the first test result is a test failure according to a preset execution result.
6. The online interface testing method according to any one of claims 1 to 3, characterized in that: The step of testing the online interface to be monitored by using the test cases in the second test case set according to the second preset period specifically includes: Reading test cases from the second test case set in sequence according to a second preset order according to a second preset period, and using the read test cases as current test cases; A test request is sent to the online interface to be monitored according to the current test case, and a second test result fed back by the online interface to be monitored is received, and the second test result is used as the execution result of the test case.
7. The online interface testing method according to claim 6, characterized in that: After the step of sending a test request to the online interface to be monitored according to the current test case, receiving a second test result fed back by the online interface to be monitored, and using the second test result as the execution result of the test case, the method further includes: Determine whether the second test result is a test failure according to a preset execution result.
8. The online interface testing method according to any one of claims 1 to 3, characterized in that: Before the step of testing the online interface to be monitored by using the test cases in the first test case set according to the first preset period, the method further includes: A test case table to be tested is obtained, and a first test case set is generated according to the test case table.
9. An electronic device, characterized in that: The electronic device comprises: a memory, a processor, and an online interface test program stored in the memory and executable on the processor. When the online interface test program is executed by the processor, the steps of the online interface test method as described in any one of claims 1 to 8 are implemented.
10. A storage medium, characterized in that: The storage medium stores a test program for an online interface, and when the test program for the online interface is executed by a processor, the steps of the test method for an online interface as described in any one of claims 1 to 8 are implemented.
11. A testing device for an online interface, characterized in that: The testing device of the online interface comprises: A first execution module is used to test the online interface to be monitored through the test cases in the first test case set according to the first preset period; when the execution result of the test cases in the first test case set is a test failure, the test cases corresponding to the test failure and the number of failures of the test cases are recorded in the second test case set; A second execution module, configured to test the online interface to be monitored through the test cases in the second test case set according to a second preset period, wherein the first preset period is greater than the second preset period; when the execution result of the test case is a test failure, update the number of failures of the corresponding test case in the second test case set; when the execution result of the test case is a test success, remove the test case corresponding to the test success from the second test case set; A query module is used to query each test case in the second test case set according to a preset query period to obtain a query result, wherein the preset query period is greater than the second preset period; determine whether there is a test case that meets a preset condition in the second test case set according to the query result; when there is a test case that meets the preset condition in the second test case set, determine that the test result of the online interface to be monitored is an interface failure, and the preset condition is that the number of test failures of the test case is greater than a preset number threshold.
12. The online interface testing device according to claim 11, characterized in that: The device also includes: a prompt module, which is used to generate fault prompt information based on the test cases in the second test case set that meet the preset conditions, and display the fault prompt information.
13. The online interface testing device according to claim 11, characterized in that: The first execution module is specifically configured to read test cases from the first test case set in sequence according to a first preset order according to a first preset period, and use the read test cases as current test cases; Sending a test request to the online interface to be monitored according to the current test case, receiving a first test result fed back by the online interface to be monitored, and using the first test result as the execution result of the test case; Determine whether the first test result is a test failure according to a preset execution result; The second execution module is specifically configured to sequentially read test cases from a second test case set in a second preset order according to a second preset period, and use the read test cases as current test cases; Sending a test request to the online interface to be monitored according to the current test case, receiving a second test result fed back by the online interface to be monitored, and using the second test result as the execution result of the test case; Determine whether the second test result is a test failure according to a preset execution result.
14. The online interface testing device according to claim 13, characterized in that: The device also includes a generating module, which is used to obtain a test case table to be tested and generate a first test case set according to the test case table.
Citation Information
Patent Citations
Test system, test method, management device, test device and computing device
CN109726124A
Software testing method and system, electronic equipment and computer readable storage medium
CN110069394A