Automated testing method, device, electronic device and readable storage medium
Patent Information
- Application Number
- CN202011584561.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-28
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2040-12-28
AI Technical Summary
[0003]当有一个用例因为测试环境、被测系统ui改动或测试数据异常等原因导致执行失败时,那么拥有同样的代码能力或者拥有同样调用链路径的用例仍会被执行,并且会因为同样的异常原因导致执行失败,从而造成测试资源的浪费,降低测试效率
[0034]本发明实施例提供的一种自动化测试方法,在执行当前用例之前,先判断当前用例调用的类及调用方法是否和特征数据库中调用异常的类及调用方法存在相同的调用链路径,若是,则不执行当前用例,从而减少测试资源的浪费,提高自动化测试效率。
Smart Images

Figure CN112650681B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer technology, and in particular relates to an automated testing method, device, electronic equipment and a readable storage medium. Background Art
[0002] Automated testing includes UI automation, monkey automation, and performance automation. During automated testing, if a test case fails to execute, the current test case is usually exited and the next test case is executed. When the next test case has the same exception error as the previous test case, the execution of the next test case also fails, and then the next test case is executed until all the test cases in the test plan are executed. The test plan is then stopped. The automated testing process has the following technical problems:
[0003] When a use case fails to execute due to reasons such as the test environment, changes in the UI of the system under test, or abnormal test data, use cases with the same code capabilities or the same call chain path will still be executed and will fail due to the same abnormal reason, resulting in a waste of test resources and reduced test efficiency. Summary of the invention
[0004] The present invention provides an automated testing method, device, electronic device and readable storage medium, which can solve or at least partially solve the above technical problems.
[0005] The present invention adopts the following technical solutions:
[0006] In a first aspect, an automated testing method is provided, comprising:
[0007] Before executing the current use case, obtain the class and calling method called by the current use case;
[0008] Compare the class and calling method called by the current use case with a feature database; wherein the feature database includes the class and calling method of the calling exception;
[0009] If the class and calling method called by the current use case have the same calling chain path as the class and calling method that call the exception in the feature database, the current use case will be exited and not executed.
[0010] Optionally, after comparing the class and calling method called by the current use case with the feature database, the method further includes:
[0011] If the class and calling method called by the current use case and the class and calling method calling the exception in the feature database do not have the same call chain path, the current use case is executed.
[0012] Optionally, after executing the current use case, the method further includes:
[0013] Record the execution process and result data of the current use case;
[0014] Identify the class and calling method of calling exceptions in the execution process and result data;
[0015] The identified call exception class and call method are stored in the feature database.
[0016] Optionally, after the step of exiting and not executing the current use case, the method further includes:
[0017] The failure reasons corresponding to the call exception classes and call methods with the same call chain path are marked as the reasons for the predicted execution failure of the current use case.
[0018] In a second aspect, an automated testing device is provided, comprising:
[0019] An acquisition module, used to acquire the class and calling method called by the current use case before executing the current use case;
[0020] A comparison module, used to compare the class and calling method called by the current use case with a feature database; wherein the feature database includes the class and calling method of calling exceptions;
[0021] The execution module is used to jump out of executing the current use case if the class and calling method called by the current use case have the same call chain path as the class and calling method that call an exception in the feature database.
[0022] Optionally, the execution module is further used to execute the current use case if the class and calling method called by the current use case and the class and calling method that call the exception in the feature database do not have the same call chain path.
[0023] Optionally, it also includes:
[0024] A recording module, used to record the execution process and result data of the current use case;
[0025] An identification module, used to identify the class and calling method of calling exceptions in the execution process and result data;
[0026] The storage module is used to store the identified call exception class and call method in the feature database.
[0027] Optionally, it also includes:
[0028] The marking module is used to mark the failure reasons corresponding to the call exception classes and call methods with the same call chain path as the reasons for the predicted execution failure of the current use case.
[0029] In a third aspect, an electronic device is provided, including:
[0030] A memory for storing program instructions;
[0031] The processor is used to call and execute the program instructions in the memory to perform the automated testing method as described above.
[0032] In a fourth aspect, a readable storage medium is provided, wherein a computer program is stored in the readable storage medium, and the computer program is used to execute the automated testing method as described above.
[0033] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0034] An automated testing method provided by an embodiment of the present invention, before executing the current use case, first determines whether the class and calling method called by the current use case have the same call chain path as the class and calling method called exception in the feature database. If so, the current use case is not executed, thereby reducing the waste of testing resources and improving the efficiency of automated testing.
[0035] The embodiment of the present invention also provides an automated testing device, an electronic device and a readable storage medium, which also have the above-mentioned beneficial effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0037] The structures, proportions, sizes, etc. illustrated in this specification are only used to match the contents disclosed in the specification so as to facilitate understanding and reading by persons familiar with the technology. They are not used to limit the conditions under which the present invention can be implemented, and therefore have no substantial technical significance. Any structural modification, change in proportion or adjustment of size shall still fall within the scope of the technical contents disclosed in the present invention without affecting the effects and purposes that can be achieved by the present invention.
[0038] Figure 1 A flowchart of an automated testing method provided by an embodiment of the present invention;
[0039] Figure 2A flowchart of an automated testing method provided by an embodiment of the present invention;
[0040] Figure 3 A flowchart of an automated testing method provided by an embodiment of the present invention;
[0041] Figure 4 A module diagram of an automated testing device provided by an embodiment of the present invention;
[0042] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0043] In order to make the purpose, features and advantages of the present invention more obvious and easy to understand, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described below are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0044] See also Figure 1 As shown, this embodiment provides an automated testing method, including:
[0045] Step S201: before executing the current use case, obtain the class and calling method called by the current use case;
[0046] Step S202: Compare the class and calling method called by the current use case with the feature database; wherein the feature database includes the class and calling method of the calling exception;
[0047] Step S203: Do the class and calling method called by the current use case and the class and calling method called by the exception in the feature database have the same calling chain path?
[0048] Step S204, exit without executing the current use case;
[0049] Step S205: Execute the current use case.
[0050] The automated testing method provided in this embodiment predicts the execution result of the use case before executing the use case. If the execution result of the use case is predicted to be a failure, the use case will not be executed; otherwise, the use case will be executed, thereby reducing the waste of testing resources.
[0051] Specifically, the data in the feature database may be preset or gradually formed during the testing process.
[0052] For example, see Figure 2As shown in the figure, a monitor can be used to monitor the use cases in each test server. The monitor can scan and collect logs of the use cases being executed to obtain the health of the use cases during and after the execution of the use cases, and record the exceptions and failure logs thrown by the use cases.
[0053] Then, the exception stack and log information are analyzed to identify the class and calling method that generated the call exception. Through exception analysis and clustering, the method is saved in the feature database db.
[0054] Therefore, please refer to Figure 3 As shown, before executing the current use case, the call chain of the use case code to be executed is scanned first, and the class and calling method in the data are taken out by obtaining data from the feature database db, and then compared with the calling method list in the call chain of the current use case. If the use case code to be executed contains the same call chain path as that in the feature database, the use case is predicted to fail, and the failure reason is the corresponding failure reason in the feature database, and the use case is skipped so that the next use case can be executed.
[0055] It should be noted that, regardless of whether the use case is executed or not, the corresponding test results need to be collected. If the use case is judged to have failed execution, the failure cause is classified as the corresponding failure cause in the feature database.
[0056] Repeat the above logic until all test cases in the plan are executed and the scheduler exits.
[0057] The automated testing method provided in this embodiment, before executing the current use case, first determines whether the class and calling method called by the current use case have the same call chain path as the class and calling method that call the exception in the feature database. If so, the current use case is not executed, thereby reducing the waste of testing resources and improving the efficiency of automated testing.
[0058] See also Figure 4 As shown, this embodiment provides an automated testing device, which can be used to implement the above automated testing method, specifically including:
[0059] The acquisition module 201 is used to acquire the class and calling method called by the current use case before executing the current use case;
[0060] Comparison module 202, used to compare the class and calling method called by the current use case with the feature database; wherein the feature database includes the class and calling method of the calling exception;
[0061] Execution module 203 is used to exit and not execute the current use case if the class and calling method called by the current use case have the same call chain path as the class and calling method that calls an exception in the feature database; it is also used to execute the current use case if the class and calling method called by the current use case do not have the same call chain path as the class and calling method that calls an exception in the feature database.
[0062] Furthermore, the automated testing device also includes:
[0063] The recording module is used to record the execution process and result data of the current use case;
[0064] Identification module, used to identify the classes and calling methods with abnormal calls in the execution process and result data;
[0065] A storage module, used to store the identified abnormal call classes and call methods into a feature database;
[0066] The marking module is used to mark the failure reasons corresponding to the call exception classes and call methods with the same call chain path as the reasons for the predicted execution failure of the current use case.
[0067] Since the specific working process and principle of the automated testing device have been explained in the above embodiments, they will not be described in detail here.
[0068] By applying the automated testing device provided in this embodiment, exceptions in the execution of use cases are collected in real time, and the execution result of the current use case is predicted by analysis, thereby adjusting the execution scheduling of the use case, greatly shortening the execution time of the test plan use case; by analyzing the exception stack data and associating the test cases, the design of the existing test cases and the deficiencies of the test framework are well reflected and evaluated, which is helpful for subsequent optimization work.
[0069] It should be noted that it should be understood that the division of the various modules and units of the above devices is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software called by processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software called by processing elements, and some modules can be implemented in the form of hardware. In addition, it can also be stored in the memory of the above device in the form of program code, and called and executed by a processing element of the above device. The implementation of other modules is similar. In addition, all or part of these modules can be integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
[0070] For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASIC), or one or more microprocessors (digital signal processors, DSP), or one or more field programmable gate arrays (FPGA), etc. For another example, when a module above is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0071] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.
[0072] See also Figure 5 As shown, in another embodiment of the present application, an electronic device 100 is also provided.
[0073] The electronic device 100 may be the above-mentioned automated testing device. The electronic device may include: a processor 101, a memory 102, a communication interface 103 and a system bus 104. The memory 102 and the communication interface 103 are connected to the processor 101 through the system bus 104 and communicate with each other. The memory 102 is used to store computer execution instructions, and the communication interface 103 is used to communicate with other devices. When the processor 101 executes the computer program, the above-mentioned Figures 1 to 3 A scheme of the illustrated embodiment.
[0074] Should Figure 5 The system bus mentioned in the specification may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The system bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface is used to realize the communication between the database access device and other devices (such as clients, read-write libraries, and read-only libraries). The memory may include random access memory (RAM), and may also include non-volatile memory (non-volatile memory), such as at least one disk storage.
[0075] The above-mentioned processor can be a general-purpose processor, including a central processing unit CPU, a network processor (NP), etc.; it can also be a digital signal processor DSP, an application-specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0076] In another embodiment of the present application, a storage medium is further provided, wherein instructions are stored in the storage medium, and when the instructions are executed on a computer, the computer is caused to execute the above-mentioned Figures 1 to 3 The method of the illustrated embodiment.
[0077] In another embodiment of the present application, a chip for executing instructions is also provided, wherein the chip is used to execute the above Figures 1 to 3 The method of the illustrated embodiment.
[0078] In another embodiment of the present application, a program product is further provided, the program product comprising a computer program, the computer program being stored in a storage medium, at least one processor being able to read the computer program from the storage medium, and the at least one processor being able to implement the above-mentioned Figures 1 to 3 The method of the illustrated embodiment.
[0079] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. An automated testing method, characterized in that: include: Before executing the current use case, obtain the class and calling method called by the current use case; Compare the class and calling method called by the current use case with a feature database; wherein the feature database includes the class and calling method of the calling exception; If the class and calling method called by the current use case have the same calling chain path as the class and calling method that call the exception in the feature database, then the current use case is not executed; After comparing the class and calling method called by the current use case with the feature database, the method further includes: If the class and calling method called by the current use case do not have the same calling chain path as the class and calling method that call the exception in the feature database, then execute the current use case; After executing the current use case, the method further includes: Record the execution process and result data of the current use case; Identify the class and calling method of calling exceptions in the execution process and result data; Storing the identified abnormal calling class and calling method in the feature database; After the step of jumping out of executing the current use case, the method further includes: Mark the failure reasons corresponding to the call exception classes and call methods with the same call chain path as the reasons for the predicted execution failure of the current use case; Regardless of whether the use case is executed or not, the corresponding test results are collected; if it is a use case that is judged to have failed, the cause of failure is classified as the corresponding failure cause in the feature database; the above logic is repeated until all test cases in the plan are executed.
2. An automated testing device, characterized in that: include: An acquisition module, used to acquire the class and calling method called by the current use case before executing the current use case; A comparison module, used to compare the class and calling method called by the current use case with a feature database; wherein the feature database includes the class and calling method of the calling exception; An execution module, configured to exit and not execute the current use case if the class and calling method called by the current use case and the class and calling method called by the exception in the feature database have the same call chain path; The execution module is further used to execute the current use case if the class and calling method called by the current use case and the class and calling method called by the exception in the feature database do not have the same call chain path; The execution module also includes collecting corresponding test results regardless of whether the use case is executed; if it is a use case that is judged to have failed execution, classifying the failure cause as the corresponding failure cause in the feature database; repeating the above logic until all test cases in the plan are executed; A recording module, used to record the execution process and result data of the current use case; An identification module, used to identify the class and calling method of calling exceptions in the execution process and result data; A storage module, used to store the identified call exception class and call method in the feature database; The marking module is used to mark the failure reasons corresponding to the call exception classes and call methods with the same call chain path as the reasons for the predicted execution failure of the current use case.
3. An electronic device, characterized in that: include: A memory for storing program instructions; A processor is used to call and execute program instructions in the memory to perform the automated testing method according to claim 1.
4. A readable storage medium, characterized in that: The readable storage medium stores a computer program, and the computer program is used to execute the automated testing method according to claim 1.
Citation Information
Patent Citations
Method and device for calculating coverage rate of abnormal test
CN103365780A
Computer software test abnormity processing system and test method
CN105718369A
A test case execution method and system
CN109359049A
Buffer overflow vulnerability automatic detection method based on symbol execution path pruning
CN110287693A
Test case verification method and device, computer equipment and storage medium
CN110471838A
