Software Application Testing Method, Device, Equipment and Storage Medium
By executing test scripts in breakpoint testing mode and comparing the execution results with the prediction results, using code coverage to locate the abnormal code location, the difficulty of developers when locating abnormal codes is solved and positioning efficiency is improved.
Patent Information
- Application Number
- CN202111546060.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-16
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2041-12-16
AI Technical Summary
Developers face difficulties in locating exception code in software applications, and need to gradually troubleshoot breakpoints by entering parameters and fault descriptions, resulting in a long and time-consuming process.
Provides a software application testing method, by obtaining the code to be tested and test cases, executing the test script in the breakpoint test mode, obtaining the script execution results and effectively executing the code, comparing the effective execution of the code with the test code segment to obtain code coverage, and positioning the abnormal code location according to the coverage.
This method can accurately obtain effective code execution, and quickly locate the abnormal code location when the script execution results are inconsistent with the prediction results, reducing the difficulty of positioning for developers.
Smart Images

Figure CN114238110B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a software application testing method, device, equipment and storage medium. Background Art
[0002] Currently, when testers discover a fault (bug), it is difficult to obtain the location of the abnormal code due to professional reasons. They can only submit the input parameters and bug description to the developer. The developer will need to gradually perform breakpoint troubleshooting on this part of the code based on the input parameters and bug description to locate the location of the abnormal code and then adjust the abnormal code, which makes the overall process long and time-consuming.
[0003] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention
[0004] The main purpose of the present invention is to provide a software application testing method, device, equipment and storage medium, aiming to solve the technical problem that it is difficult for developers to locate abnormal codes based on test data.
[0005] To achieve the above object, the present invention provides a software application testing method, the method comprising the following steps:
[0006] Obtain the code to be tested and test cases corresponding to the target software application;
[0007] Execute the test script corresponding to the test case in the breakpoint test mode, and obtain the script execution result and the effective execution code after the test script is executed;
[0008] If the script execution result is inconsistent with the prediction result corresponding to the test case, obtaining the test code section corresponding to the test case in the code to be tested;
[0009] The effective execution code is compared with the test code section to obtain code coverage, and the abnormal code position is located according to the code coverage.
[0010] Optionally, the step of obtaining the code to be tested and the test case corresponding to the target software application includes:
[0011] Parse the received test instructions to obtain the identification of the application to be tested and the code access path;
[0012] Acquire the code to be tested corresponding to the target software application according to the code access path;
[0013] According to the identification of the application to be tested, a corresponding code test case is searched in a preset test case library to obtain a test case set;
[0014] Select the test cases corresponding to the target software application from the set of test cases.
[0015] Optionally, the step of selecting the test cases corresponding to the target software application from the set of test cases includes:
[0016] Detect whether there is a data dependency relationship among the code test cases in the set of test cases;
[0017] If there is a data dependency relationship, obtain the execution order corresponding to each code test case in the set of test cases;
[0018] Sort the code test cases in the set of test cases according to the execution order to obtain a sorted set of test cases;
[0019] Traverse the sorted set of test cases and use the traversed code test cases as test cases.
[0020] Optionally, after the step of executing the test script corresponding to the test case in the breakpoint test mode and obtaining the script execution result and the effective execution code after the test script is executed, it further includes:
[0021] If the script execution result is consistent with the predicted result corresponding to the test case, detect whether there are un-traversed code test cases in the sorted set of test cases;
[0022] If there are un-traversed code test cases, return to the step of traversing the sorted set of test cases and using the traversed code test cases as test cases.
[0023] Optionally, after the step of if the script execution result is consistent with the predicted result corresponding to the test case, detect whether there are un-traversed code test cases in the sorted set of test cases, it further includes:
[0024] If there are no un-traversed code test cases, obtain the effective execution code corresponding to each code test case in the sorted set of test cases;
[0025] Mark the code to be tested according to the effective execution code corresponding to each code test case;
[0026] Generate a test quality report based on the marked code to be tested and display the test quality report.
[0027] Optionally, the step of marking the code to be tested according to the effective execution code corresponding to each code test case includes:
[0028] Construct the tested code according to the valid execution code corresponding to each code test case;
[0029] Compare the tested code with the code to be tested to obtain the uncovered code;
[0030] Mark the code to be tested according to the uncovered code and the tested code.
[0031] Optionally, the step of comparing the tested code with the code to be tested to obtain the uncovered code includes:
[0032] Obtain the abnormal code positions corresponding to each code test case in the sorting case set;
[0033] Determine the suspicious code according to the abnormal code positions;
[0034] Compare the suspicious code and the tested code with the code to be tested to obtain the uncovered code;
[0035] Correspondingly, the step of marking the code to be tested according to the uncovered code and the tested code includes:
[0036] Mark the code to be tested according to the suspicious code, the uncovered code and the tested code.
[0037] In addition, to achieve the above object, the present invention also provides a software application testing device, and the software application testing device includes the following modules:
[0038] A data acquisition module, configured to acquire the code to be tested and test cases corresponding to a target software application;
[0039] A script execution module, configured to execute a test script corresponding to the test case in a breakpoint test mode, and obtain a script execution result and valid execution code after the test script is executed;
[0040] A result comparison module, configured to, if the script execution result is inconsistent with a predicted result corresponding to the test case, acquire a test code segment corresponding to the test case in the code to be tested;
[0041] An abnormal location module, configured to compare the valid execution code with the test code segment to obtain a code coverage rate, and locate an abnormal code position according to the code coverage rate.
[0042] In addition, to achieve the above object, the present invention also provides a software application testing device, which includes: a processor, a memory, and a software application testing program stored on the memory and executable on the processor. When the software application testing program is executed by the processor, the steps of the software application testing method described above are implemented.
[0043] In addition, to achieve the above object, the present invention also provides a computer-readable storage medium, on which a software application testing program is stored. When the software application testing program is executed, the steps of the software application testing method described above are implemented.
[0044] The present invention obtains the code to be tested and test cases corresponding to the target software application; executes the test script corresponding to the test case in the breakpoint testing mode, and obtains the script execution result and the effective execution code after the execution of the test script is completed; if the script execution result is inconsistent with the predicted result corresponding to the test case, obtains the test code segment corresponding to the test case in the code to be tested; determines the code coverage rate according to the effective execution code and the test code segment, and determines the position of the abnormal code according to the code coverage rate. Since the test script is executed in the breakpoint testing mode, the effective execution code can be accurately obtained, and when the script execution result is inconsistent with the predicted result, the position of the abnormal code can be quickly located according to the obtained code coverage rate, reducing the difficulty for developers to locate the position of the abnormal code. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 is a schematic structural diagram of an electronic device in the hardware operating environment related to the solution of the embodiment of the present invention;
[0046] Figure 2 is a schematic flowchart of the first embodiment of the software application testing method of the present invention;
[0047] Figure 3 is a schematic flowchart of the second embodiment of the software application testing method of the present invention;
[0048] Figure 4 is a schematic flowchart of the third embodiment of the software application testing method of the present invention;
[0049] Figure 5 is a schematic block diagram of the first embodiment of the software application testing device of the present invention.
[0050] The realization, functional features, and advantages of the object of the present invention will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0051] 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.
[0052] Reference Figure 1 , Figure 1 is a schematic structural diagram of a software application testing device for the hardware operating environment involved in the solution of the embodiment of the present invention.
[0053] As Figure 1 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 an input unit such as a keyboard (Keyboard). Optionally, the user interface 1003 may further include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a Wireless-Fidelity (WI-FI) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM) or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk memory. Optionally, the memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0054] Those skilled in the art can understand that Figure 1 the structure shown in
[0055] does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements. Figure 1 As
[0056] shown, in the memory 1005 as a storage medium, there may be included an operating system, a network communication module, a user interface module, and a software application testing program. Figure 1 In the electronic device shown in
[0057] Figure 2 Figure 2 , Figure 2 the network interface 1004 is mainly used for data communication with a network server; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the memory 1005 in the electronic device of the present invention may be provided in the software application testing device. The electronic device calls the software application testing program stored in the memory 1005 through the processor 1001 and executes the software application testing method provided by the embodiment of the present invention.
[0058] In this embodiment, the software application testing method includes the following steps:
[0059] Step S10: Obtain the code to be tested and test cases corresponding to the target software application.
[0060] It should be noted that the execution subject of this embodiment may be the software application testing device. The software application testing device may be an electronic device such as a personal computer or a server, or may also be a device that can implement the same or similar functions. This embodiment does not limit this. In this embodiment and the following embodiments, the software application testing method of the present invention is described by taking the software application testing device as an example.
[0061] It should be noted that the target software application may be a software application that needs to be tested. The code to be tested may be all or part of the source code of the target software application, and the test case may be a code test case pre-set by a tester.
[0062] In actual use, the user can operate on the user terminal to select the code to be tested and the test cases. Then, the user terminal will send an instruction to the software application testing device according to the selected code to be tested and test cases. The software application testing device can determine the target software application according to the parameters in the received instruction, and obtain the code to be tested and the test cases corresponding to the target software application.
[0063] Step S20: Execute the test script corresponding to the test case in the breakpoint testing mode, and obtain the script execution result and the effective execution code after the test script is executed.
[0064] It should be noted that the test case may include contents such as a predicted result and a test script. The predicted result may be the result that should theoretically be returned when the test script is executed without exceptions for the code to be tested. The test script may include data such as the access path to the function to be tested, input data, and access method. Obtaining the test script corresponding to the test case may be to extract the test script corresponding to the test case from the test case. Of course, in actual use, the test script may be relatively large. The test case may only save the script access path of the test script. In this case, obtaining the test script corresponding to the test case may be to read the script access path in the test case and obtain the test script corresponding to the test case according to the script access path. The breakpoint testing mode is a code execution mode. When the breakpoint testing mode is enabled and the code is run, the code will pause when it reaches a certain breakpoint until a control instruction is obtained and then continue to execute. The script execution result may be the execution result obtained after the test script is executed. The effective execution code is the code that can be normally executed in the code to be tested when the test script corresponding to the test case is executed.
[0065] In actual use, in order to accurately determine the effectively executed code, a breakpoint can be set for each line in the code to be tested, and the next line is executed only after a line of code has been successfully executed, so as to ensure that when an exception occurs in any line of code and it cannot be executed normally, the execution can be quickly stopped, thereby quickly determining the effectively executed code.
[0066] It can be understood that when it is determined that any line of code cannot be executed smoothly, the breakpoint debugging of the subsequent code can be directly released, and no further breakpoints are set, so as to quickly obtain the execution result of the script, which can improve the execution efficiency of the test script and reduce unnecessary time consumption.
[0067] Step S30: If the execution result of the script is inconsistent with the predicted result corresponding to the test case, obtain the test code segment corresponding to the test case in the code to be tested.
[0068] It should be noted that a test case generally performs a functional test on a single function or multiple functions. Obtaining the test code segment corresponding to the test case in the code to be tested can be to obtain the code segment corresponding to the single or multiple functions for which the test case performs a functional test in the code to be tested, so as to obtain the test code segment corresponding to the test case in the code to be tested.
[0069] It can be understood that if the execution result of the script is inconsistent with the predicted result corresponding to the test case, it means that an exception has occurred in the code to be tested. Therefore, the test code segment corresponding to the test case in the code to be tested can be obtained to facilitate the location of the abnormal code.
[0070] Step S40: Compare the effectively executed code with the test code segment to obtain the code coverage rate, and locate the position of the abnormal code according to the code coverage rate.
[0071] It should be noted that the test code segment is the code segment corresponding to the single or multiple functions for which the test case performs a test in the code to be tested. By comparing the effectively executed code with the test code segment, the proportion of the effectively executed code in the test code segment can be determined, thereby obtaining the code coverage rate.
[0072] It can be understood that the code coverage rate is the proportion of the effectively executed code in the test code segment, and the code has an execution order. Therefore, according to the code coverage rate and the execution order of the code, the position of the abnormal code can be quickly located.
[0073] In actual use, a fault (bug) report can also be generated based on the abnormal code position, the execution result of the script, the case identifier corresponding to the test case, the test script, and the predicted result. The bug report is pushed to the developer to facilitate the developer to troubleshoot the cause of the bug. Of course, the fault report can also be stored. Among them, the case identifier corresponding to the test case can be the unique identifier of the test case.
[0074] Of course, in the actual use process, due to network fluctuations or other factors, it may also cause the test result to be inconsistent with the predicted result. At this time, there may not really be a bug. If a bug report is directly generated and pushed to the developer without verification, the developer may waste a lot of time troubleshooting, wasting a lot of manpower and material resources. To avoid this phenomenon, if the test script corresponding to the test case supports repeated execution, when the test result is inconsistent with the predicted result, the test script can be repeatedly tried to run multiple times. If the test results obtained from multiple runs are all inconsistent with the predicted result, then a bug report is generated and the bug report is pushed to the developer.
[0075] In this embodiment, the to-be-tested code and test cases corresponding to the target software application are obtained; the test script corresponding to the test case is executed in the breakpoint test mode, and the script execution result and the effective execution code are obtained after the test script is executed; if the script execution result is inconsistent with the predicted result corresponding to the test case, the test code segment corresponding to the test case in the to-be-tested code is obtained; the code coverage rate is determined according to the effective execution code and the test code segment, and the abnormal code position is determined according to the code coverage rate. Since the test script is executed in the breakpoint test mode, the effective execution code can be accurately obtained. When the script execution result is inconsistent with the predicted result, the abnormal code position can be quickly located according to the obtained code coverage rate, reducing the difficulty for the developer to locate the abnormal code position.
[0076] Reference Figure 3 , Figure 3 is a schematic flowchart of the second embodiment of a software application testing method of the present invention.
[0077] Based on the above first embodiment, step S10 of the software application testing method in this embodiment includes:
[0078] Step S101: Parse the received test instruction to obtain the to-be-tested application identifier and the code access path.
[0079] It should be noted that the test instruction can be sent by the user operating the user terminal to the software application testing device. The test instruction can include the to-be-tested application identifier and the code access path. Among them, the to-be-tested application identifier can be the application unique identifier of the target software application, and the code access path can be the access path of the source code in the target software application.
[0080] Step S102: Obtain the code to be tested corresponding to the target software application according to the code access path.
[0081] It should be noted that obtaining the code to be tested corresponding to the target software application according to the code access path can be to read the code to be tested corresponding to the target software application in the code repository. Among them, the code repository can be a pre-set repository for storing the source code of each software application, such as code repositories like svn or git.
[0082] In actual use, when testing a certain application, it may not test the entire application, but rather test some functional modules in the application. To ensure the accuracy of the subsequent un-covered code calibration, the test instruction can also include a code access directory to further specify the source code of the application under test, and specify a certain part of the code corresponding to the application under test as the code to be tested. Then, at this time, it can be to read the code to be tested corresponding to the target software application in the code repository according to the code access path and the code access directory.
[0083] Step S103: Search for the corresponding code test cases in the preset use case library according to the application identifier to be tested, and obtain a set of test cases.
[0084] It should be noted that the preset use case library can be a pre-set database for storing code test cases. The code test cases in the preset use case library can be pre-set by testers. The code test cases can be pre-set with a test target identifier for specifying the software application corresponding to the code test case. Searching for the corresponding code test cases in the preset use case library according to the application identifier to be tested and obtaining a set of test cases can be to search for the code test cases in the predicted use case library whose corresponding test target identifier is the same as the application identifier to be tested, and aggregate the found code test cases to obtain a set of test cases.
[0085] Step S104: Select the test cases corresponding to the target software application from the set of test cases.
[0086] It should be noted that selecting the test cases corresponding to the target software application from the set of test cases can be to traverse the set of test cases and use the obtained code test cases as the test cases corresponding to the target software application. Among them, the set of test cases can be an ordered set, and traversing the set of test cases can be to traverse the set of test cases according to the set index order.
[0087] It is understandable that after selecting the test case corresponding to the target software application in the test case set, the subsequent steps can be continued. After a test case is run, the test case set can be traversed, that is, after step S40, the step S104 can be returned to continue traversing the test case set. Of course, according to actual needs, if the script execution result corresponding to the test script of a test case is inconsistent with the prediction result corresponding to the test case, the traversal of the test case set can also be stopped.
[0088] This embodiment parses the received test instructions to obtain the identification of the application to be tested and the code access path; obtains the code to be tested corresponding to the target software application according to the code access path; searches for the corresponding code test case in the preset case library according to the identification of the application to be tested to obtain a test case set; and selects the test case corresponding to the target software application from the test case set. Since the corresponding code test case is searched in the preset case library according to the identification of the application to be tested, a test case set is constructed, and then the test case set is traversed, the tester can set multiple different test cases to be executed in sequence at the same time, which reduces the workload of the tester and simplifies the operation difficulty of the tester.
[0089] refer to Figure 4 , Figure 4 The figure is a flowchart of a third embodiment of a software application testing method according to the present invention.
[0090] Based on the above second embodiment, step S104 of the software application testing method of this embodiment includes:
[0091] Step S1041: Detect whether there is a data dependency relationship between the code test cases in the test case set.
[0092] It should be noted that detecting whether there is data dependency among the code test cases in the test case set can be detecting whether there are code test cases in the test case set that can only be executed if they depend on the data generated after the normal execution of other code test cases. If such code test cases exist, it is determined that there is a data dependency; if such code test cases do not exist, it is determined that there is no data dependency.
[0093] Step S1042: If there is a data dependency, the execution order corresponding to each code test case in the test case set is obtained.
[0094] It should be noted that the test case set is aggregated from the code test cases corresponding to the identified application to be tested. When constructing, the data dependency relationship is not considered. If there is no data dependency relationship among the code test cases in the test case set, it means that the code test cases are independent of each other and do not affect each other. Therefore, the test case set can be directly used as the sorted case set for traversal. However, if there is a data dependency relationship among the code test cases in the test case set, directly traversing the test case set at this time may cause some test cases to not be able to execute normally due to the lack of dependent data. In order to avoid this phenomenon, the execution order corresponding to each code test case can be obtained first. Among them, the execution order corresponding to the code test case can be set in advance by the tester according to the data dependency relationship.
[0095] Step S1043: Sort the code test cases in the test case set according to the execution order to obtain a sorted case set.
[0096] It should be noted that sorting the code test cases in the test case set according to the execution order to obtain a sorted case set can be to sort the code test cases in the test case set according to the execution order to obtain a sorting result, and then sequentially add the code test cases in the test case set to a blank ordered set according to the sorting result, so as to obtain a sorted case set.
[0097] Step S1044: Traverse the sorted case set and use the traversed code test case as a test case.
[0098] It can be understood that after sorting according to the execution order corresponding to the code test case, and then traversing the sorted case set, the test cases can run sequentially according to the execution order, so as to ensure that the test cases can run smoothly when there is no abnormality in the code to be tested.
[0099] After step S20 described in this embodiment, the following is further included:
[0100] Step S30': If the script execution result is consistent with the predicted result corresponding to the test case, detect whether there are code test cases in the sorted case set that have not been traversed.
[0101] It should be noted that if the script execution result is consistent with the predicted result corresponding to the test case, it means that the result returned after the test script corresponding to the test case runs is consistent with the predicted result, and it can be determined that there is no abnormality in the function tested by this test case, and the subsequent test process can be continued. Then, at this time, it can be detected whether there are code test cases in the sorted case set that have not been traversed.
[0102] In actual use, detecting whether there are unvisited code test cases in the sorted test case set can be to compare the set index obtained during the current traversal with the maximum value of the set indexes in the sorted test case set. If the set index obtained during traversal is less than the maximum value of the set indexes, it is determined that there are unvisited code test cases in the sorted test case set. If the set index obtained during traversal is equal to the maximum value of the set indexes, it is determined that there are no unvisited code test cases in the sorted test case set.
[0103] Of course, when traversing to obtain code test cases, if the traversed code test cases are marked, then detecting whether there are unvisited code test cases in the sorted test case set can be to detect whether there are unmarked code test cases in the sorted test case set. If there are unmarked code test cases, it is determined that there are unvisited code test cases. If there are no unmarked code test cases, it is determined that there are no unvisited code test cases.
[0104] It can be understood that if there are unvisited code test cases in the sorted test case set, it means that not all of the test cases specified by the user have been executed. Therefore, the step S1044 can be returned to continue traversing the sorted test case set. If there are no unvisited code test cases in the sorted test case set, it means that all of the test cases specified by the user have been executed. Then the following steps can be performed:
[0105] Step S40': Obtain the effective execution codes corresponding to each code test case in the sorted test case set.
[0106] It should be noted that the effective execution code corresponding to a code test case can be the effective execution code corresponding to the test script corresponding to the code test case.
[0107] It can be understood that if there are no unvisited code test cases in the sorted test case set, it means that all of the test cases specified by the user have been executed. Therefore, the effective execution codes corresponding to each code test case in the sorted test case set can be obtained for subsequent statistics.
[0108] Step S50': Mark the code to be tested according to the effective execution codes corresponding to each code test case.
[0109] It should be noted that marking the code to be tested according to the effective execution codes corresponding to each code test case can be to compare the effective execution codes corresponding to each code test case in the sorted test case set with the code to be tested, and mark the part of the code to be tested corresponding to the effective execution code as executed. For example: change the background color of the part of the code to be tested corresponding to the effective execution code to green.
[0110] In actual use, in order to speed up the marking speed and improve the execution efficiency, step S50 described in this embodiment may include:
[0111] Construct tested code based on the valid execution codes corresponding to the respective code test cases;
[0112] Compare the tested code with the code to be tested to obtain un-covered code;
[0113] Mark the code to be tested according to the un-covered code and the tested code.
[0114] It should be noted that constructing the tested code based on the valid execution codes corresponding to the respective code test cases may be to aggregate the valid execution codes corresponding to the respective code test cases in the sorting case set, so as to obtain the tested code.
[0115] It can be understood that first aggregating the valid execution codes corresponding to the respective code test cases in each sorting case set into the tested code, then comparing the tested code with the code to be tested to obtain the un-covered code, and then marking the code to be tested according to the un-covered code and the tested code can avoid circularly obtaining the valid execution codes corresponding to the respective code test cases during the comparison, can reduce data processing during the loop, can speed up the execution speed of the overall marking process, and improve the execution efficiency.
[0116] In actual use, marking the code to be tested according to the un-covered code and the tested code may be to modify the background color of the part of the code to be tested corresponding to the un-covered code to the marking color corresponding to the un-covered code, and modify the background color of the part of the code to be tested corresponding to the tested code to the marking color corresponding to the covered code. Among them, the marking color can be set according to actual needs. For example, the marking color of the tested code is set to green, and the marking color corresponding to the un-covered code is set to red.
[0117] Furthermore, in an actual scenario, the non-execution of some code may be due to a process interruption caused by a code exception, so that this part of the code is not executed. In order to avoid the interference of such code on the code coverage judgment, the step of comparing the tested code with the code to be tested to obtain the un-covered code described in this embodiment may include:
[0118] Obtain the positions of the exception codes corresponding to the respective code test cases in the sorting case set;
[0119] Determine the questionable code according to the positions of the exception codes;
[0120] Compare the questionable code and the tested code with the code to be tested to obtain the un-covered code;
[0121] Correspondingly, the step of marking the code to be tested according to the uncovered code and the tested code includes:
[0122] Mark the code to be tested according to the questionable code, the uncovered code, and the tested code.
[0123] It should be noted that the position of the abnormal code can be position information such as the line number of the abnormal code. Obtaining the position of the abnormal code corresponding to the code test case can be to find the bug report corresponding to the code test case according to the case identifier of the code test case, and read the position of the abnormal code from the bug report. The questionable code can be the code that has not been executed due to code anomalies. Determining the questionable code according to the position of the abnormal code can be to obtain the code test paragraph corresponding to the code test case in the code to be tested, and determine the questionable code according to the position of the abnormal code and the code test paragraph. For example: Suppose the line numbers of the code test paragraph corresponding to the code test case in the code to be tested are 30 - 60, and the position of the abnormal code is the 44th line. Then, it can be determined that the lines 44 - 60 are the questionable code.
[0124] In actual use, comparing the questionable code and the tested code with the code to be tested to obtain the uncovered code can be to compare the questionable code and the tested code with the code to be tested, and take the part of the code to be tested that does not correspond to both the questionable code and the tested code as the uncovered code. Marking the code to be tested according to the questionable code, the uncovered code, and the tested code can be to modify the background color of the part of the code to be tested corresponding to the uncovered code to the marking color corresponding to the uncovered code, modify the background color of the part of the code to be tested corresponding to the tested code to the marking color corresponding to the tested code, and modify the background color of the part of the code to be tested corresponding to the questionable code to the marking color corresponding to the questionable code. Among them, the marking color can be set according to actual needs. For example: Set the marking color of the tested code to green, the marking color corresponding to the uncovered code to red, and the marking color corresponding to the questionable code to gray.
[0125] Step S60': Generate a test quality report according to the marked code to be tested, and display the test quality report.
[0126] It can be understood that by generating a test quality report according to the marked code to be tested and displaying the test quality report, testers can determine the overall coverage rate of the code to be tested when the test script corresponding to the currently set test case is executed, determine whether there is any code to be tested that has not been covered, and thus determine whether additional test cases are needed.
[0127] It can be understood that if the tester determines that there is no need to supplement test cases, the code in the code to be tested that has not been covered may be obsolete code or useless code. Therefore, after the tester has determined, the test quality report can also be shown to the developer so that the developer can determine whether code adjustment is needed.
[0128] In this embodiment, by detecting whether there is a data dependency relationship among the code test cases in the test case set, when there is a data dependency relationship, the execution order corresponding to each code test case in the test case set is also obtained, and the code test cases in the test case set are sorted according to the execution order to obtain a sorted use case set, and then the sorted use case set is traversed, thus avoiding the phenomenon that some test cases cannot be executed normally due to missing dependent data. And when there is no un-traversed code test case in the sorted use case set, the effective execution code corresponding to each code test case in the sorted use case set is also obtained, the code to be tested is marked according to the effective execution code corresponding to each code test case in the sorted use case set, a test quality report is generated according to the marked code to be tested, and the test quality report is shown, so that the tester can determine whether to supplement test cases according to the test quality report, and the developer can determine whether code adjustment is needed according to the test quality report, further reducing the work difficulty of the tester and the developer.
[0129] In addition, an embodiment of the present invention further provides a storage medium, on which a software application test program is stored, and when the software application test program is executed by a processor, the steps of the software application test method described above are implemented.
[0130] Referring to Figure 5 , Figure 5 is the structural block diagram of the first embodiment of the software application test device of the present invention.
[0131] As Figure 5 shown, the software application test device proposed by the embodiment of the present invention includes:
[0132] A data acquisition module 10, configured to acquire the code to be tested and test cases corresponding to a target software application;
[0133] A script execution module 20, configured to execute a test script corresponding to the test case in a breakpoint test mode, and acquire a script execution result and effective execution code after the test script is executed;
[0134] A result comparison module 30, configured to, if the script execution result is inconsistent with the predicted result corresponding to the test case, acquire a test code segment corresponding to the test case in the code to be tested;
[0135] The exception location module 40 is used to compare the valid execution code with the test code segment, obtain the code coverage rate, and locate the position of the exception code according to the code coverage rate.
[0136] In this embodiment, the to-be-tested code and test cases corresponding to the target software application are obtained; the test script corresponding to the test case is executed in the breakpoint test mode, and after the execution of the test script is completed, the script execution result and the valid execution code are obtained; if the script execution result is inconsistent with the predicted result corresponding to the test case, the test code segment corresponding to the test case in the to-be-tested code is obtained; the code coverage rate is determined according to the valid execution code and the test code segment, and the position of the exception code is determined according to the code coverage rate. Since the test script is executed in the breakpoint test mode, the valid execution code can be accurately obtained, and when the script execution result is inconsistent with the predicted result, the position of the exception code can be quickly located according to the obtained code coverage rate, reducing the difficulty for developers to locate the position of the exception code.
[0137] Further, the data acquisition module 10 is further used to parse the received test instruction to obtain the to-be-tested application identifier and the code access path; obtain the to-be-tested code corresponding to the target software application according to the code access path; search for the corresponding code test cases in the preset use case library according to the to-be-tested application identifier to obtain a test case set; and select the test case corresponding to the target software application from the test case set.
[0138] Further, the data acquisition module 10 is further used to detect whether there is a data dependency relationship among the code test cases in the test case set; if there is a data dependency relationship, obtain the execution order corresponding to each code test case in the test case set; sort the code test cases in the test case set according to the execution order to obtain a sorted use case set; and traverse the sorted use case set, and use the traversed code test case as the test case.
[0139] Further, the result comparison module 30 is further used to, if the script execution result is consistent with the predicted result corresponding to the test case, detect whether there is an un-traversed code test case in the sorted use case set; if there is an un-traversed code test case, return to the step of traversing the sorted use case set and using the traversed code test case as the test case.
[0140] Further, the result comparison module 30 is further configured to, if there is no un-traversed code test case, obtain the effective execution codes corresponding to the code test cases in the sorted case set; mark the code to be tested according to the effective execution codes corresponding to the code test cases; generate a test quality report based on the marked code to be tested, and display the test quality report.
[0141] Further, the result comparison module 30 is further configured to construct the tested code according to the effective execution codes corresponding to the code test cases; compare the tested code with the code to be tested to obtain the uncovered code; mark the code to be tested according to the uncovered code and the tested code.
[0142] Further, the result comparison module 30 is further configured to obtain the abnormal code positions corresponding to the code test cases in the sorted case set; determine the suspicious code according to the abnormal code positions; compare the suspicious code and the tested code with the code to be tested to obtain the uncovered code;
[0143] The result comparison module 30 is further configured to mark the code to be tested according to the suspicious code, the uncovered code and the tested code.
[0144] It should be understood that the above is only an example for illustration, and does not constitute any limitation to the technical solution of the present invention. In specific applications, those skilled in the art can set according to needs, and the present invention does not limit this.
[0145] It should be noted that the above-described work process is only illustrative and does not limit the protection scope of the present invention. In actual applications, those skilled in the art can select some or all of them according to actual needs to achieve the purpose of the solution of this embodiment, and there is no limitation here.
[0146] In addition, for the technical details not described in detail in this embodiment, reference can be made to the software application test method provided in any embodiment of the present invention, which will not be elaborated here.
[0147] In addition, it should be noted that in this article, the terms "including", "comprising" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or further includes elements inherent to such process, method, article or system. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of another identical element in the process, method, article or system including the element.
[0148] The serial numbers of the embodiments of the present invention above are only for description and do not represent the superiority or inferiority of the embodiments.
[0149] Through the description of the above embodiments, those skilled in the art can clearly understand that the above embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they 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, in essence, or the part that makes a contribution to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium (such as Read Only Memory (ROM) / RAM, magnetic disk, optical disk), and includes several instructions for causing a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in various embodiments of the present invention.
[0150] The above are only the preferred embodiments of the present invention, and do not limit the patent scope of the present invention accordingly. Any equivalent structure or equivalent process transformation made by using the content of the specification and drawings of the present invention, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present invention.
Claims
1. A software application testing method, It is characterized in that The software application testing method comprises the following steps: Obtain the code to be tested and test cases corresponding to the target software application; Execute the test script corresponding to the test case in the breakpoint test mode, and obtain the script execution result and the effective execution code after the test script is executed; If the script execution result is inconsistent with the prediction result corresponding to the test case, obtaining the test code section corresponding to the test case in the code to be tested; Compare the valid execution code with the test code segment to obtain code coverage, and locate the abnormal code position according to the code coverage; Wherein, after the step of executing the test script corresponding to the test case in the breakpoint test mode and obtaining the script execution result and the effective execution code after the test script is executed, it also includes: If the script execution result is consistent with the prediction result corresponding to the test case, then checking whether there is a code test case that has not been traversed in the sorted case set; If there is no code test case that has not been traversed, obtaining the valid execution code corresponding to each code test case in the sorted case set; Constructing the tested code according to the valid execution code corresponding to each code test case; Obtaining the abnormal code position corresponding to each code test case in the sorted test case set; Determine the question code according to the abnormal code position; Compare the question code and the tested code with the code to be tested to obtain uncovered code; Marking the code to be tested according to the question code, the uncovered code and the tested code; A test quality report is generated based on the marked code to be tested, and the test quality report is displayed.
2. The software application testing method according to claim 1, It is characterized in that The step of obtaining the code to be tested and the test case corresponding to the target software application includes: Parse the received test instructions to obtain the identification of the application to be tested and the code access path; Acquire the code to be tested corresponding to the target software application according to the code access path; According to the identification of the application to be tested, a corresponding code test case is searched in a preset test case library to obtain a test case set; A test case corresponding to the target software application is selected from the test case set.
3. The software application testing method according to claim 2, It is characterized in that The step of selecting a test case corresponding to the target software application from the test case set includes: Detecting whether there is a data dependency relationship between each code test case in the test case set; If there is a data dependency, then obtaining the execution order corresponding to each code test case in the test case set; Sorting the code test cases in the test case set according to the execution order to obtain a sorted test case set; The sorted test case set is traversed, and the traversed code test cases are used as test cases.
4. The software application testing method according to claim 3, It is characterized in that If the script execution result is consistent with the prediction result corresponding to the test case, after the step of detecting whether there is a code test case that has not been traversed in the sorted case set, the method further includes: If there are code test cases that have not been traversed, then return to the step of traversing the sorted case set and using the traversed code test cases as test cases.
5. A software application testing device, It is characterized in that The software application testing device comprises the following modules: A data acquisition module is used to obtain the code to be tested and the test cases corresponding to the target software application; A script execution module, used to execute the test script corresponding to the test case in the breakpoint test mode, and obtain the script execution result and the effective execution code after the test script is executed; A result comparison module, for obtaining the test code section corresponding to the test case in the code to be tested if the script execution result is inconsistent with the prediction result corresponding to the test case; An exception locating module, used for comparing the valid execution code with the test code segment, obtaining code coverage, and locating the abnormal code position according to the code coverage; Among them, the result comparison module is also used to detect whether there is a code test case that has not been traversed in the sorted case set if the script execution result is consistent with the predicted result corresponding to the test case; if there is no code test case that has not been traversed, obtain the valid execution code corresponding to each code test case in the sorted case set; construct the tested code according to the valid execution code corresponding to each code test case; obtain the abnormal code position corresponding to each code test case in the sorted case set; determine the question code according to the abnormal code position; compare the question code and the tested code with the code to be tested to obtain the uncovered code; mark the code to be tested according to the question code, the uncovered code and the tested code; generate a test quality report based on the marked code to be tested, and display the test quality report.
6. A software application testing device, It is characterized in that The software application testing device comprises: a processor, a memory, and a software application testing program stored in the memory and executable on the processor, wherein the software application testing program implements the steps of the software application testing method according to any one of claims 1 to 4 when executed by the processor.
7. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a software application testing program, which, when executed, implements the steps of the software application testing method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Software defect location method and software defect location system
CN103106133A