Method and apparatus for testing applications
By configuring log burying points and comparing test cases in the application, real-world online testing is achieved, which solves the problems of unrealistic test environments and garbage data generation in existing technologies, and improves test coverage and accuracy.
Patent Information
- Application Number
- CN201910825794.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-09-03
- Publication Date
- 2024-08-16
- Estimated Expiration
- 2039-09-03
AI Technical Summary
Existing automated testing relies on test environments and pre-release environments, which cannot truly reflect the online environment, making it difficult to predict untested functions, and simulated data testing may generate junk data.
By configuring log burying points in the application, burying point logs corresponding to user operations are generated, and compared with predetermined test cases, the test results are generated, and online real-environment testing is implemented to avoid the generation of garbage data.
It improves the coverage of automated testing, ensures the accuracy of test results, avoids the generation of junk data, and enhances the stability of functions that are frequently used by users.
Smart Images

Figure CN112445697B
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the field of computer technology, and more particularly to a method and apparatus for testing an application. Background Art
[0002] Most of the existing automated tests are automation of actual operations, which need to rely on test environments and pre-release environments. Usually, the test environments and pre-production environments involved in automated testing are not the real environments after the application is launched. After the application is launched, there may still be many untested functions, and it is often difficult to predict in advance whether these untested functions have abnormalities.
[0003] If the real online environment is used as the test environment and testers use simulated data for testing, garbage data will be generated during the testing process. Summary of the invention
[0004] The present disclosure proposes methods and apparatus for testing applications.
[0005] In a first aspect, an embodiment of the present disclosure provides a method for testing an application, the method comprising: in response to detecting a user operation on an application, generating a tracking log corresponding to the user operation through log tracking points pre-configured in the application, wherein the tracking log includes actual result data corresponding to the user operation; determining a test case that matches the tracking log from a predetermined test case set, wherein the test case in the test case set includes expected result data; based on the tracking log and the test case that matches the tracking log, comparing the actual result data corresponding to the user operation with the expected result data to generate a test result.
[0006] In some embodiments, user operations are used to operate on data in a target database; and based on the tracking log and the test case matching the tracking log, the actual result data corresponding to the user operation and the expected result data are compared to generate a test result, including: comparing the actual result data corresponding to the user operation and the expected result data to generate a comparison result; in response to the comparison result indicating that the actual result data corresponding to the user operation and the expected result data are inconsistent, determining whether abnormal log information for the user operation is captured; in response to the capture of abnormal log information, generating a test result characterizing the failure of the test case; in response to the comparison result indicating that the actual result data corresponding to the user operation and the expected result data are consistent, determining whether the data corresponding to the user operation stored in the target database is correct; in response to the data corresponding to the user operation stored in the target database being correct, generating a test result characterizing the success of the test case; in response to the data corresponding to the user operation stored in the target database being incorrect, generating a test result characterizing the failure of the test case.
[0007] In some embodiments, the method further includes: storing the tracking point log in a log file; and cleaning the tracking point log stored in the log file according to a preset log cleaning time.
[0008] In some embodiments, determining a test case that matches the burial point log from a predetermined set of test cases includes: determining a test case that includes the same key characters as the burial point log from a predetermined set of test cases as a test case that matches the burial point log.
[0009] In some embodiments, the method further includes: running the test cases in the test case set that do not generate matching tracking logs within the first time period, and obtaining test results of the test cases that do not generate matching tracking logs.
[0010] In some embodiments, the method further includes: generating a test coverage rate corresponding to a preset second time period based on a test case set and a test point log generated within a preset second time period.
[0011] In a second aspect, an embodiment of the present disclosure provides a device for testing an application, the device comprising: a first generating unit, configured to, in response to detecting a user operation on an application, generate a tracking log corresponding to the user operation through log tracking points pre-configured in the application, wherein the tracking log includes actual result data corresponding to the user operation; a determining unit, configured to determine a test case that matches the tracking log from a predetermined test case set, wherein the test case in the test case set includes expected result data; a comparing unit, configured to compare the actual result data corresponding to the user operation with the expected result data based on the tracking log and the test case that matches the tracking log, to generate a test result.
[0012] In some embodiments, the user operation is used to operate on the data in the target database; and the comparison unit is further configured to: compare the actual result data corresponding to the user operation with the expected result data to generate a comparison result; in response to the comparison result indicating that the actual result data corresponding to the user operation and the expected result data are inconsistent, determine whether abnormal log information for the user operation is captured; in response to the capture of abnormal log information, generate a test result characterizing the failure of the test case; in response to the comparison result indicating that the actual result data corresponding to the user operation and the expected result data are consistent, determine whether the data corresponding to the user operation stored in the target database is correct; in response to the data corresponding to the user operation stored in the target database being correct, generate a test result characterizing the success of the test case; in response to the data corresponding to the user operation stored in the target database being incorrect, generate a test result characterizing the failure of the test case.
[0013] In some embodiments, the device also includes: a storage unit configured to store the burial point log in a log file; and a cleaning unit configured to clean the burial point log stored in the log file according to a preset log cleaning time.
[0014] In some embodiments, the determination unit is further configured to: determine, from a predetermined set of test cases, a test case including the same key characters as the tracking log as a test case that matches the tracking log.
[0015] In some embodiments, the device also includes: a running unit, configured to run the test cases in the test case set that do not generate matching tracing logs within the first time period, and obtain test results of the test cases that do not generate matching tracing logs.
[0016] In some embodiments, the device also includes: a second generating unit configured to generate a test coverage corresponding to a preset second time period based on a set of test cases and a test point log generated within a preset second time period.
[0017] In a third aspect, an embodiment of the present disclosure provides an electronic device for testing applications, comprising: one or more processors; a storage device on which one or more programs are stored, and when the one or more programs are executed by the one or more processors, the one or more processors implement a method as in any embodiment of the above-mentioned method for testing applications.
[0018] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable medium for testing an application, on which a computer program is stored, and when the program is executed by a processor, a method as in any embodiment of the above-mentioned method for testing an application is implemented.
[0019] The method and apparatus for testing an application provided by the embodiments of the present disclosure generate a tracking log corresponding to the user operation through log tracking points pre-configured in the application when a user operation on the application is detected, wherein the tracking log includes actual result data corresponding to the user operation, and then determine a test case matching the tracking log from a predetermined test case set, wherein the test case in the test case set includes expected result data, and finally, based on the tracking log and the test case matching the tracking log, compare the actual result data corresponding to the user operation with the expected result data to generate a test result, thereby realizing testing in a real online environment without generating junk data, which helps to improve the coverage of automated testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Other features, objects and advantages of the present disclosure will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0021] Figure 1 is an exemplary system architecture diagram in which an embodiment of the present disclosure may be applied;
[0022] Figure 2 is a flow chart of one embodiment of a method for testing an application according to the present disclosure;
[0023] Figure 3 is a schematic diagram of an application scenario of the method for testing an application according to the present disclosure;
[0024] Figure 4 is a flow chart of yet another embodiment of a method for testing an application according to the present disclosure;
[0025] Figure 5 is a structural schematic diagram of an embodiment of a device for testing an application according to the present disclosure;
[0026] Figure 6 It is a schematic diagram of the structure of a computer system of a server suitable for implementing an embodiment of the present disclosure. DETAILED DESCRIPTION
[0027] The present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It is also necessary to explain that, for ease of description, only the parts related to the relevant invention are shown in the accompanying drawings.
[0028] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0029] Figure 1 An exemplary system architecture 100 is shown to which an embodiment of a method for testing an application or an apparatus for testing an application according to an embodiment of the present disclosure can be applied.
[0030] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0031] The user can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send data, etc. For example, after the user operates the client application installed on the terminal devices 101, 102, 103, the terminal devices 101, 102, 103 can send an HTTP (HyperText Transfer Protocol) request corresponding to the operation to the server 105, so that the server 105 can detect the user's operation on the application. Various client applications can be installed on the terminal devices 101, 102, 103, such as video playback software, news and information applications, image processing applications, web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0032] Terminal devices 101, 102, 103 can be hardware or software. When terminal devices 101, 102, 103 are hardware, they can be various electronic devices with display screens and supporting page browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, Moving Picture Experts Compression Standard Audio Layer 3), MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Compression Standard Audio Layer 4) players, laptop computers and desktop computers, etc. When terminal devices 101, 102, 103 are software, they can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (for example, software or software modules used to provide distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.
[0033] Server 105 can be a server that provides various services, such as a background server that provides support for pages displayed on terminal devices 101, 102, and 103. The background server can analyze and process the received HTTP request and other data, thereby providing support for running applications installed on terminal devices 101, 102, and 103, and then generate point-of-use logs corresponding to user operations through log points pre-configured in the application, and generate test results based on the point-of-use logs and test cases matching the point-of-use logs. As an example, server 105 can be a cloud server or a physical server.
[0034] It should be noted that the server can be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When the server is software, it can be implemented as multiple software or software modules (for example, software or software modules used to provide distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.
[0035] It should also be noted that the method for testing an application provided in the embodiments of the present disclosure is usually executed by a server. Accordingly, the various parts (such as various units, sub-units, modules, and sub-modules) included in the apparatus for testing an application are usually arranged in a server.
[0036] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0037] Continue to refer Figure 2 , shows a process 200 of an embodiment of a method for testing an application according to the present disclosure. The method for testing an application comprises the following steps:
[0038] Step 201, in response to detecting a user operation on an application, generating a tracking point log corresponding to the user operation through a log tracking point pre-configured in the application.
[0039] In this embodiment, when a user operation on an application is detected, an execution subject (eg, Figure 1 The server shown in the figure can generate a point-of-use log corresponding to the user operation through the log point-of-use configured in advance in the application. The point-of-use log includes the actual result data corresponding to the user operation.
[0040] The above application may be a collection of computer data and instructions organized in a specific order. For example, the above application may be system software, application software (such as shopping software), website application, etc. User operation may be an operation performed on the application by a user of the above application through a terminal device installed with the above application. For example, user operation may include but is not limited to: adding a product to favorites, purchasing a product, etc.
[0041] It is understandable that the above-mentioned log embedding points can be configured by technical personnel in the program code of the above-mentioned application during the development stage. After the development is completed, when the above-mentioned application is deployed online, the user can download the above-mentioned application through the user terminal, and then interact with the above-mentioned execution subject through the user terminal installed with the above-mentioned application. During the interaction process, the user operation can run the program code of the application. When the log embedding points are configured in the program code being run, the above-mentioned execution subject can generate the embedding point log corresponding to the user operation through the log embedding points pre-configured in the application.
[0042] As an example, if the user operation indicates payment of an order, then, if the user payment is successful, the log tracking point may be "log.info("autotest: Order xxxx payment successful!")"; if the user payment fails, the log tracking point may be "log.info("autotest: Order xxxx payment failed!")". Thus, the above-mentioned execution entity may generate a tracking log "Order xxxx payment successful!" when the user payment is successful; and generate a tracking log "Order xxxx payment failed!" when the user payment fails. Among them, the actual result data corresponding to the user operation included in the tracking log "Order xxxx payment successful!" may be "Payment successful"; the actual result data corresponding to the user operation included in the tracking log "Order xxxx payment failed!" may be "Payment failed".
[0043] As an example, the above-mentioned log tracking points may include but are not limited to at least one of the following: log tracking points of the front-end (Web) functional interface, log tracking points of the interface and message queue (MQ) code, exception log tracking points, etc. Among them, the log tracking points of the front-end functional interface can be used to count but not limited to the following information: the reach rate of each screen, the flip rate of each screen, the dwell time of each screen, etc. The log tracking points of the interface and message queue code can be implemented by configuring the .properties file, configuring the destination and format of the log, etc. through the log4j (an open source log operation package) method. In addition, the tracking point logs corresponding to the log tracking points of the interface and message queue code can be set to print by date. When there is an exception in the log within the set test case tracking point range, the exception log information can be captured.
[0044] In practice, multiple log tracking points can be set for each function of the above application. Generally, the more log tracking points there are, the more tracking logs can be obtained, which will help to conduct more comprehensive testing of the above application in subsequent steps.
[0045] Step 202, determine the test case that matches the tracking log from a predetermined set of test cases.
[0046] In this embodiment, the above-mentioned execution subject can determine the test case that matches the tracking log from a predetermined test case set. Among them, the test case in the test case set includes expected result data. The expected result data can represent the expected result generated by the user operation that is predetermined by the technician. As an example, when the user operation indicates a payment order, the expected result data included in the test case corresponding to the user operation can be data for indicating a successful payment.
[0047] Here, the above test case set can be set for multiple processes. Each process can correspond to multiple test cases. As an example, if the above application is a shopping software, then the above test case set can be set for the following processes: return process, repair and replacement process, pickup process, payment process, purchase process, etc. Among them, each process can implement one or more functions. Each function can be set with one or more test cases accordingly.
[0048] As an example, a technician may set a test case for each program statement, or may set a test case for each program branch in the application program, thereby achieving more comprehensive testing and improving test coverage.
[0049] Exemplarily, the above-mentioned predetermined test case set can be stored in a file, and the file can be stored in a pre-specified location. Therefore, after importing the development packages "java.io.IOException" and "java.io.RandomAccessFile", the seek method in the RandomAccessFile class can be used to realize real-time file reading according to the location of the storage file. Parse the key characters of the test case: For example, the key characters: "autotest: Sales outbound order xxxx operation outbound successful!" is a test case for the outbound operation. Therefore, the above-mentioned execution subject can compare the actual result data with the expected result data by intercepting the key characters.
[0050] In some optional implementations of this embodiment, the execution subject may perform step 202 in the following manner:
[0051] From a predetermined test case set, a test case including the same key characters as the burying point log is determined, so that the test case including the same key characters as the burying point log is used as a test case that matches the burying point log.
[0052] Optionally, the execution subject may also perform step 202 in the following manner:
[0053] When configuring log tracking points, technical personnel can set the identifier of the test case that matches the log tracking point in each log tracking point, and then determine the test case indicated by the identifier included in the tracking point log from a predetermined set of test cases, and then use the test case indicated by the identifier included in the tracking point log as the test case that matches the tracking point log.
[0054] Step 203, based on the tracking log and the test case matching the tracking log, the actual result data corresponding to the user operation and the expected result data are compared to generate a test result.
[0055] In this embodiment, the execution subject can compare the actual result data corresponding to the user operation with the expected result data based on the embedded point log and the test case matching the embedded point log to generate a test result. The test result can be used to indicate whether the actual result data corresponding to the user operation is consistent with the expected result data.
[0056] Here, when the actual result data corresponding to the user operation and the expected result data indicate the same result, the actual result data corresponding to the user operation and the expected result data are consistent.
[0057] It should be noted that when the actual result data and the expected result data are not completely the same, the actual result data and the expected result data may also be consistent. For example, if the actual result data is "Order XXX is shipped successfully" and the expected result data is "shipped successfully", it can be represented that the actual result data and the expected result data are consistent.
[0058] Specifically, the execution entity may compare the actual result data included in the generated tracking log with the expected result data included in the test case matching the tracking log, thereby generating a test result.
[0059] Continue to see Figure 3 , Figure 3 FIG. 1 is a schematic diagram of an application scenario of the method for testing an application according to this embodiment. Figure 3 In the application scenario, the user performs a user operation 303 ( Figure 3In the example, the server 302 detects the user operation 303 on the above application, and then generates a tracking log 306 corresponding to the user operation 303 through the log tracking point 304 pre-configured in the application, wherein the tracking log 306 includes the actual result data 308 corresponding to the user operation 303. After that, the server 302 determines the test case 307 that matches the tracking log 306 from the predetermined test case set 305. Among them, the test cases in the test case set 305 include expected result data. Finally, based on the tracking log 306 and the test case 307 that matches the tracking log 306, the server 302 compares the actual result data 308 and the expected result data 309 corresponding to the user operation 303, and generates a test result 310.
[0060] Most of the existing automated tests are automation of actual operations, which need to rely on test environments and pre-release environments. Usually, the test environments and pre-production environments involved in the existing automated tests are not the real environments after the application is launched. Therefore, after the application is launched, there may still be many untested functions. It is often difficult to predict in advance whether the above untested functions have abnormalities. If the real online environment is used as the test environment, testers use simulated data for testing, which will generate garbage data during the test process.
[0061] The method for testing an application provided by the above embodiment of the present disclosure, when detecting a user operation on an application, generates a point-of-use log corresponding to the user operation through the log point-of-use configured in advance in the application, and then, based on the generated point-of-use log and the test case matching the point-of-use log, compares the actual result data and the expected result data corresponding to the user operation to generate a test result, thereby realizing the testing of the application in an online real environment, which helps to improve the coverage of automated testing. In addition, the data used in the prior art is often simulated data, while the data used in the above embodiment of the present disclosure is data generated by the actual operation of the user, which restores the user's usage scenario, so that the test result can be made more accurate, and the more functions the user uses, the more tests are performed, thereby helping to ensure the stability of functions with higher user frequency. Furthermore, when the prior art uses the online real environment as the test environment, the tester often uses simulated data for testing, and data that needs to be stored in the database may be generated during the test process. However, the database is usually used to store real data generated during the user operation process. Therefore, the data stored in the database during the test by the tester using simulated data is usually regarded as garbage data. However, the embodiments of the present disclosure can test the application only through the user operations during the use process. Since the data generated during the use process is real data, the embodiments of the present disclosure can avoid the generation of junk data during the testing process.
[0062] In some optional implementations of this embodiment, the above execution subject may further perform the following steps:
[0063] First, the tracking point log is stored in a log file, which can be a pre-created file with a .log suffix, a file with a .txt suffix, or a file with other suffixes.
[0064] Then, according to the preset log cleaning time, clean the tracking logs stored in the log file. Among them, the preset log cleaning time can be a predetermined time for cleaning logs. Thus, the above-mentioned execution subject can clean the tracking logs stored in the log file at the predetermined time for cleaning logs. For example, the preset log cleaning time can be "0 o'clock every night", so that the above-mentioned execution subject can clean the tracking logs stored in the log file at 0 o'clock every night. In addition, the above-mentioned preset log cleaning time can also indicate the time period for cleaning logs. In this way, the above-mentioned execution subject can periodically clean the tracking logs stored in the log file.
[0065] In some optional implementations of this embodiment, the above execution subject may further perform the following steps:
[0066] Run the test cases in the test case set that do not generate matching tracking logs within the first time period, and obtain the test results of the test cases that do not generate matching tracking logs. The first time period may be a predetermined time period. The first time period may be a time period starting at any time and ending at any time after the starting point. In some cases, the end point of the first time period may be the current time. As an example, the first time period may be the time period from 0:00 to 24:00 of the day.
[0067] It can be understood that, when it is necessary to obtain the test results of the above application within the first time period, the test cases in the test case set that do not generate matching tracking logs within the first time period can be determined, and the above application can be tested using the determined test cases, thereby obtaining the test results of the test cases that are not matched by user operations within the first time period. In this way, compared with the solution of obtaining test results only through user operations, this optional implementation solution can further improve the test coverage.
[0068] In some optional implementations of this embodiment, the above execution subject may further perform the following steps:
[0069] Based on the test case set and the tracking logs generated in the preset second time period, the test coverage corresponding to the preset second time period is generated.
[0070] As an example, the execution subject may generate the test coverage corresponding to the preset second time period in the following manner:
[0071] First, determine the number of test cases in the test case set that match each tracking log generated within a preset second time period.
[0072] Then, the ratio of the number of matched test cases to the total number of test cases in the test case set is determined as the test coverage rate corresponding to the preset second time period.
[0073] As another example, the execution subject may also generate the test coverage corresponding to the preset second time period in the following manner:
[0074] First, the number of tracking logs in the test case set and each tracking log generated within a preset second time period that represents the success of the test case is determined.
[0075] Then, the ratio of the number of determined tracking logs to the total number of test cases in the test case set is determined as the test coverage rate corresponding to the preset second time period.
[0076] It can be understood that by calculating the test coverage, the test completeness and effectiveness can be measured, and the reliability and stability of the launched application can be obtained.
[0077] Further references Figure 4 , which shows a process 400 of another embodiment of a method for testing an application. The process 400 of the method for testing an application includes the following steps:
[0078] Step 401, in response to detecting a user operation on an application, generating a point-of-use log corresponding to the user operation through a log point-of-use pre-configured in the application. Thereafter, step 402 is executed.
[0079] In this embodiment, when a user operation on an application is detected, an execution subject (eg, Figure 1 The server shown in the figure can generate a point-of-use log corresponding to the user operation through the log point-of-use configured in advance in the application. The point-of-use log includes the actual result data corresponding to the user operation. The user operation is used to operate the data in the target database.
[0080] In this embodiment, step 401 and Figure 2 Step 201 in the corresponding embodiment is basically the same and will not be described again here.
[0081] Step 402: determine the test case that matches the tracking log from the predetermined test case set. Then, execute step 403.
[0082] In this embodiment, step 402 and Figure 2 Step 202 in the corresponding embodiment is basically the same and will not be described again here.
[0083] Step 403 : compare the actual result data corresponding to the user operation with the expected result data to generate a comparison result. Then, step 404 is executed.
[0084] In this embodiment, the execution subject (eg, Figure 1 The server shown in the figure can compare the actual result data corresponding to the user operation with the expected result data to generate a comparison result. The comparison result can be used to indicate whether the actual result data corresponding to the user operation is consistent with the expected result data.
[0085] It should be noted that when the actual result data and the expected result data are not completely the same, the actual result data and the expected result data may also be consistent. For example, if the actual result data is "Order XXX is shipped successfully" and the expected result data is "shipped successfully", it can be represented that the actual result data and the expected result data are consistent.
[0086] Step 404, determining whether the comparison result indicates that the actual result data corresponding to the user operation is consistent with the expected result data. If so, then executing step 406; if not, then executing step 405.
[0087] In this embodiment, the execution entity may determine whether the comparison result indicates that the actual result data corresponding to the user operation is consistent with the expected result data.
[0088] Step 405 , determining whether abnormal log information for user operations is captured. If abnormal log information for user operations is captured, then executing step 407 .
[0089] In this embodiment, when the comparison result indicates that the actual result data corresponding to the user operation is inconsistent with the expected result data, the execution subject may also determine whether abnormal log information for the user operation is captured.
[0090] Here, the above-mentioned abnormal log information may be information used to indicate that an abnormal log occurs during the test process.
[0091] It can be understood that, usually when an exception occurs during a user operation, the above-mentioned execution subject can capture the exception log information for the user operation.
[0092] As an example, when the comparison result indicates that the actual result data corresponding to the user operation and the expected result data are inconsistent, the above-mentioned execution entity can determine that an exception occurs during the user operation, thereby capturing abnormal log information indicating that the actual result data corresponding to the user operation and the expected result data are inconsistent.
[0093] As another example, the above-mentioned execution entity can also determine that an exception occurs during the user operation process in other application scenarios other than the above-mentioned examples. For example, if a program statement ends with a Chinese semicolon “;” instead of an English semicolon “;”, the above-mentioned execution entity can determine that an exception occurs during the user operation process, thereby capturing exception log information indicating that the program statement ends with a Chinese semicolon instead of an English semicolon.
[0094] In practice, technicians can determine what kind of abnormal log information to generate in what scenario according to actual needs, and the embodiments of the present disclosure will not be described in detail here.
[0095] Step 406, determining whether the data corresponding to the user operation stored in the target database is correct. If the data corresponding to the user operation stored in the target database is correct, then executing step 408; if the data corresponding to the user operation stored in the target database is incorrect, then executing step 407.
[0096] In this embodiment, when the comparison result indicates that the actual result data corresponding to the user operation is consistent with the expected result data, the execution subject can determine whether the data corresponding to the user operation stored in the target database is correct. The target database can be used to store data operated by the user operation.
[0097] Specifically, the above-mentioned execution entity may compare the data corresponding to the user operation actually stored in the target database with the data expected to be stored in the above-mentioned target database corresponding to the user operation. If the comparison result indicates that the two are consistent, then the above-mentioned execution entity can determine that the data corresponding to the user operation stored in the target database is correct; if the comparison result indicates that the two are inconsistent, then the above-mentioned execution entity can determine that the data corresponding to the user operation stored in the target database is incorrect.
[0098] As an example, if the user operation is an operation for indicating the collection of products, the target database is used to store the product information of the products collected by the user corresponding to the user operation. Then, after the user performs the user operation, relative to before the user performs the user operation, the above-mentioned target database should have added the product information of the products collected by the user operation. In this application scenario, the data expected to be stored in the above-mentioned target database corresponding to the user operation may be the product information of the products collected by the user performing the user operation. Then, after the user performs the user operation, relative to before the user performs the user operation, if the above-mentioned target database actually has added the product information of the products collected by the user performing the user operation, then the above-mentioned execution subject can determine that the data corresponding to the user operation stored in the target database is correct; otherwise, the above-mentioned execution subject can determine that the data corresponding to the user operation stored in the target database is incorrect.
[0099] Step 407: Generate a test result indicating that the test case has failed.
[0100] In this embodiment, when the data corresponding to the user operation stored in the target database is incorrect, the execution subject may generate a test result indicating that the test case has failed.
[0101] Step 408: Generate a test result indicating the success of the test case.
[0102] In this embodiment, when the data corresponding to the user operation stored in the target database is correct, the execution subject can generate a test result indicating the success of the test case.
[0103] Optionally, after the execution entity generates a test result indicating a test case failure, or a test result indicating a test case success, a test report may be generated so that developers can understand the operation of the application and promptly repair the current application or develop new functions for the application.
[0104] It should be noted that, in addition to the above contents, this embodiment may also include Figure 2 The same or similar features and effects as those in the corresponding embodiments will not be described in detail here.
[0105] from Figure 4 It can be seen that process 400 of the method for testing an application in this embodiment can test the application based on the comparison results obtained by comparing the actual result data corresponding to the user operation with the expected result data, as well as the correctness of the data corresponding to the user operation stored in the database, thereby further improving the accuracy of the test results.
[0106] Further references Figure 5 , as a response to the above Figure 2 The present disclosure provides an embodiment of a device for testing an application. Figure 2 Corresponding to the method embodiment shown in FIG. 1 , in addition to the features described below, the device embodiment may also include Figure 2 The same or corresponding features of the method embodiment shown, and the generation of Figure 2 The method embodiment shown has the same or corresponding effects. The device can be specifically applied to various electronic devices.
[0107] like Figure 5 As shown, the apparatus 500 for testing an application in this embodiment includes: a first generating unit 501, a determining unit 502 and a comparing unit 503. The first generating unit 501 is configured to generate a tracking point log corresponding to the user operation through a log tracking point pre-configured in the application in response to detecting a user operation on the application, wherein the tracking point log includes actual result data corresponding to the user operation; the determining unit 502 is configured to determine a test case matching the tracking point log from a pre-determined test case set, wherein the test case in the test case set includes expected result data; the comparing unit 503 is configured to compare the actual result data corresponding to the user operation with the expected result data based on the tracking point log and the test case matching the tracking point log, and generate a test result. .
[0108] In this embodiment, the first generating unit 501 of the apparatus 500 for testing an application can generate a tracking point log corresponding to the user operation through the log tracking point pre-configured in the application, wherein the tracking point log includes the actual result data corresponding to the user operation.
[0109] In this embodiment, the determination unit 502 may determine the test case that matches the tracking log from a predetermined test case set, wherein the test case in the test case set includes expected result data, which may represent the result generated by the user operation that is predetermined by the technician.
[0110] In this embodiment, the comparison unit 503 can compare the actual result data corresponding to the user operation with the expected result data based on the embedded point log and the test case matching the embedded point log to generate a test result. The test result can be used to indicate whether the actual result data corresponding to the user operation and the expected result data indicate the same result.
[0111] In some optional implementations of this embodiment, the user operation is used to operate on the data in the target database; and the comparison unit 503 can be further configured to: compare the actual result data corresponding to the user operation with the expected result data to generate a comparison result; in response to the comparison result indicating that the actual result data corresponding to the user operation and the expected result data are inconsistent, determine whether abnormal log information for the user operation is captured; in response to the capture of abnormal log information, generate a test result characterizing the failure of the test case; in response to the comparison result indicating that the actual result data corresponding to the user operation and the expected result data are consistent, determine whether the data corresponding to the user operation stored in the target database is correct; in response to the data corresponding to the user operation stored in the target database being correct, generate a test result characterizing the success of the test case; in response to the data corresponding to the user operation stored in the target database being incorrect, generate a test result characterizing the failure of the test case.
[0112] In some optional implementations of this embodiment, the device 500 also includes: a storage unit (not shown in the figure), configured to store the burial point log in a log file; a cleaning unit (not shown in the figure), configured to clean the burial point log stored in the log file according to a preset log cleaning time.
[0113] In some optional implementations of this embodiment, the determination unit is further configured to: determine, from a predetermined set of test cases, a test case that includes the same key characters as the burrowing log as a test case that matches the burrowing log.
[0114] In some optional implementations of this embodiment, the device 500 also includes: an operating unit (not shown in the figure), which is configured to run the test cases in the test case set that do not generate matching tracing logs within the first time period, and obtain test results of the test cases that do not generate matching tracing logs.
[0115] In some optional implementations of this embodiment, the device 500 also includes: a second generation unit (not shown in the figure), which is configured to generate test coverage corresponding to a preset second time period based on a set of test cases and a test point log generated within a preset second time period.
[0116] The device for testing an application provided by the above-mentioned embodiment of the present disclosure, in response to detecting a user operation on the application, the first generation unit 501 generates a point-of-use log corresponding to the user operation through the log point-of-use configured in advance in the application, wherein the point-of-use log includes the actual result data corresponding to the user operation, and then the determination unit 502 determines the test case matching the point-of-use log from the predetermined test case set, wherein the test case in the test case set includes the expected result data, and then the comparison unit 503 compares the actual result data corresponding to the user operation with the expected result data based on the point-of-use log and the test case matching the point-of-use log, generates a test result, and realizes testing the application in a real online environment, which helps to improve the coverage of automated testing. In addition, the data used in the prior art is often simulated data, while the data used in the above-mentioned embodiment of the present disclosure is data generated by the actual operation of the user, which restores the user's usage scenario, so that the test result can be made more accurate, and more tests can be performed on the functions that the user uses more, thereby helping to ensure the stability of the functions that the user uses more frequently. Furthermore, when the prior art uses the online real environment as the test environment, the tester often uses simulated data for testing, and data that needs to be stored in the database may be generated during the test. However, the database is usually used to store real data generated during user operations. Therefore, the data stored in the database during the test by the tester using simulated data is usually regarded as garbage data. However, the embodiments of the present disclosure can test the application only through the user operation during the user's use. Since the data generated during the use is real data, the embodiments of the present disclosure can avoid the generation of garbage data during the test process.
[0117] Reference below Figure 6 , which shows an electronic device (eg, Figure 1 A schematic diagram of the structure of the server in (a) 600. Figure 6 The server shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0118] like Figure 6As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0119] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead. Figure 6 Each block shown in the figure may represent one device, or may represent multiple devices as required.
[0120] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0121] It should be noted that the computer-readable medium described in the embodiments of the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the embodiments of the present disclosure, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device. In the embodiments of the present disclosure, the computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0122] The computer-readable medium may be included in the electronic device; or it may exist independently without being installed in the electronic device. The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: in response to detecting a user operation on an application, generates a point-of-use log corresponding to the user operation through a log point-of-use pre-configured in the application, wherein the point-of-use log includes actual result data corresponding to the user operation; determines a test case that matches the point-of-use log from a predetermined set of test cases, wherein the test case in the test case set includes expected result data; based on the point-of-use log and the test case that matches the point-of-use log, compares the actual result data corresponding to the user operation with the expected result data to generate a test result.
[0123] Computer program code for performing the operations of embodiments of the present disclosure may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on a user's computer, partially on a user's computer, as a separate software package, partially on a user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0124] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0125] The units involved in the embodiments described in the present disclosure may be implemented by software or by hardware. The described units may also be provided in a processor, for example, may be described as: a processor comprising a first generation unit, a determination unit, and a comparison unit. Among them, the names of these units do not constitute a limitation on the unit itself under certain circumstances. For example, the first generation unit may also be described as "a unit that generates a point-of-entry log corresponding to a user operation through a log point-of-entry pre-configured in the application."
[0126] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the present disclosure is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above invention concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other.
Claims
1. A method for testing an application, include: In response to detecting a user operation of a user during use of the application, generating a tracking point log corresponding to the user operation through a log tracking point pre-configured in the application, wherein the tracking point log includes actual result data corresponding to the user operation, the user operation is used to operate data in a target database, and the target database is used to store the data operated by the user operation; Determine a test case that matches the tracking log from a predetermined test case set, wherein the test case in the test case set includes expected result data; Based on the tracking log and the test case matching the tracking log, the actual result data corresponding to the user operation and the expected result data are compared to generate a test result, including: comparing the actual result data corresponding to the user operation and the expected result data to generate a comparison result; in response to the comparison result indicating that the actual result data corresponding to the user operation and the expected result data are consistent, comparing the actual stored data corresponding to the user operation in the target database with the expected stored data corresponding to the user operation; in response to determining that the actual stored data corresponding to the user operation in the target database and the expected stored data corresponding to the user operation are consistent, generating a test result representing the success of the test case; in response to determining that the actual stored data corresponding to the user operation in the target database and the expected stored data corresponding to the user operation are inconsistent, generating a test result representing the failure of the test case.
2. The method according to claim 1, in, The comparing the actual result data corresponding to the user operation with the expected result data based on the embedding log and the test case matching the embedding log to generate the test result also includes: In response to the comparison result indicating that the actual result data corresponding to the user operation is inconsistent with the expected result data, determining whether abnormal log information for the user operation is captured; In response to capturing the abnormal log information, a test result indicating a test case failure is generated.
3. The method according to claim 1, in, The method further comprises: Storing the tracking log in a log file; According to the preset log cleaning time, clean up the tracking logs stored in the log file.
4. The method according to claim 1, in, The step of determining a test case that matches the tracking log from a predetermined test case set includes: From a predetermined set of test cases, a test case including the same key characters as the embedding log is determined as a test case that matches the embedding log.
5. The method according to any one of claims 1 to 4, in, The method further comprises: Run the test cases in the test case set that do not generate matching tracking logs within the first time period to obtain test results of the test cases that do not generate matching tracking logs.
6. The method according to any one of claims 1 to 4, in, The method further comprises: Based on the test case set and the tracking logs generated within the preset second time period, the test coverage corresponding to the preset second time period is generated.
7. A device for testing an application, include: A first generating unit is configured to, in response to detecting a user operation of a user during use of the application, generate a tracking point log corresponding to the user operation through a log tracking point pre-configured in the application, wherein the tracking point log includes actual result data corresponding to the user operation, the user operation is used to operate data in a target database, and the target database is used to store the data operated by the user operation; A determination unit is configured to determine a test case that matches the tracking log from a predetermined test case set, wherein the test case in the test case set includes expected result data; A comparison unit is configured to compare the actual result data corresponding to the user operation with the expected result data based on the tracking log and the test case matching the tracking log, and generate a test result; The comparison unit is further configured to: compare the actual result data corresponding to the user operation with the expected result data to generate a comparison result; in response to the comparison result indicating that the actual result data corresponding to the user operation is consistent with the expected result data, compare the actual stored data corresponding to the user operation in the target database with the expected stored data corresponding to the user operation; in response to determining that the actual stored data corresponding to the user operation in the target database is consistent with the expected stored data corresponding to the user operation, generate a test result representing the success of the test case; in response to determining that the actual stored data corresponding to the user operation in the target database is inconsistent with the expected stored data corresponding to the user operation, generate a test result representing the failure of the test case.
8. The device according to claim 7, in, The comparison unit is further configured to: In response to the comparison result indicating that the actual result data corresponding to the user operation is inconsistent with the expected result data, determining whether abnormal log information for the user operation is captured; In response to capturing the abnormal log information, a test result indicating a test case failure is generated.
9. An electronic device, include: one or more processors; a storage device having one or more programs stored thereon, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
10. A computer readable medium having a computer program stored thereon, in, When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
