A test scene identification method, test system, device and storage medium

By judging the running status of the target test program in the Monkey test and providing application programming interfaces to relevant objects, the problem of test result deviation caused by abnormal exit of the Monkey test is solved, and the efficiency and reliability of the test are improved.

CN111897720BActive Publication Date: 2024-09-27FUJIAN YUANBAO TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010664217.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-10
Publication Date
2024-09-27
Estimated Expiration
2040-07-10

AI Technical Summary

Technical Problem

When the Monkey test exits abnormally, the APP, some modules or some subsystems cannot know in time that the test program has exited, resulting in deviations in the test results.

Method used

By determining whether the target test program starts running and providing application programming interfaces to at least two preset objects, it ensures that these objects are notified in time when the test program starts or exits, and corresponding measures are taken to ensure the smooth progress of the test.

Benefits of technology

The startup and exit status of the target test program is notified through the application programming interface, so that the relevant objects can take corresponding operations to improve test efficiency and reliability and avoid test result deviations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111897720B
    Figure CN111897720B
Patent Text Reader

Abstract

The embodiment of the present invention discloses a method for identifying a test scenario, including: determining whether a target test program is started; if the target test program is started, providing an application programming interface to at least two preset objects so that the at least two preset objects can call the application programming interface; determining whether the target test program exits; if the target test program exits, notifying the at least two preset objects through the application programming interface that the target test program exits. The present invention also discloses a test system, a device, and a storage medium. The present invention can ensure the smooth progress of the test and improve the test efficiency and reliability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software testing, and in particular to a test scenario recognition method, a test system, a device and a storage medium. Background Art

[0002] Monkey testing generally refers to such testing activities, which use irregular instructions or operations to use the system under test to observe the stability and fault tolerance of the system. Since Monkey testing has non-real usage scenarios such as disorder and randomness, when the Monkey test starts or exits, the APP, some modules or some subsystems need to take corresponding actions based on whether the Monkey is running or not. However, in addition to normal exit after the test is completed, the Monkey test may also exit abnormally, and the APP, some modules or some subsystems may not be able to know that the Monkey test has exited, and fail to take corresponding measures, resulting in deviations in the test results. Summary of the invention

[0003] Based on this, it is necessary to propose a test scenario identification method, test system, device and storage medium to address the above problems.

[0004] A method for identifying a test scenario, comprising: determining whether a target test program has been started; if the target test program has been started, providing an application programming interface to at least two preset objects so that the at least two preset objects can call the application programming interface; determining whether the target test program has been exited; if the target test program has been exited, notifying the at least two preset objects through the application programming interface that the target test program has been exited.

[0005] Among them, after the step of providing the application programming interface to at least two preset objects, it includes: after the at least two preset objects call the application programming interface, notifying the at least two preset objects through the application programming interface that the target test program has started running.

[0006] Among them, after the step of providing an application programming interface to at least two preset objects, it includes: after the at least two preset objects call the application programming interface, recording the at least two preset objects that call the application programming interface; the step of notifying the at least two preset objects through the application programming interface that the target test program exits operation includes: notifying the recorded at least two preset objects through the application programming interface that the target test program exits operation.

[0007] The step of determining whether the target test program is started and running includes: obtaining first logic information of a function entry set in the target test program, and determining whether the target test program is started and running according to the first logic information.

[0008] The step of determining whether the target test program has exited operation includes: obtaining second logic information set in the exit process of the target test program, and determining whether the target test program has exited operation according to the second logic information.

[0009] The step of determining whether the target test program has exited operation includes: obtaining third logic information set in a signal processing flow of the target test program, and determining whether the target test program has exited operation according to the third logic information.

[0010] Among them, the target test program is a Monkey test program; the at least two preset objects include an APP layer and a Native layer.

[0011] A testing system comprises: a first judgment module, used to judge whether a target test program is started and run; an interface providing module, used to provide an application programming interface to at least two preset objects if the target test program is started and run, so that the at least two preset objects can call the application programming interface; a second judgment module, used to judge whether the target test program is exited and run; an exit notification module, used to notify the at least two preset objects through the application programming interface that the target test program is exited if the target test program is exited and run.

[0012] A testing device comprises: a processor and a memory, wherein the processor is coupled to the memory, a computer program is stored in the memory, and the processor executes the computer program to implement the method as described above.

[0013] A storage medium stores a computer program, wherein the computer program can be executed by a processor to implement the method as described above.

[0014] The embodiments of the present invention have the following beneficial effects:

[0015] When the target test program starts running, an application programming interface is provided to at least two preset objects, and the at least two preset objects are notified of the start-up and exit of the target test program through the application programming interface, so that the at least two preset objects can take corresponding operations according to the start-up and exit of the target test program, thereby ensuring the smooth progress of the test and improving the test efficiency and reliability. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] 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.

[0017] in:

[0018] Figure 1 is a flow chart of a first embodiment of a method for identifying a test scenario provided by the present invention;

[0019] Figure 2 is a flow chart of a second embodiment of the method for identifying a test scenario provided by the present invention;

[0020] Figure 3 is a structural schematic diagram of an embodiment of a test system provided by the present invention;

[0021] Figure 4 It is a structural schematic diagram of an embodiment of the testing device provided by the present invention;

[0022] Figure 5 It is a structural schematic diagram of an embodiment of the storage medium provided by the present invention. DETAILED DESCRIPTION

[0023] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments 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.

[0024] When the Monkey test starts or exits, the APP, some modules or some subsystems need to take corresponding actions based on whether the Monkey is running or not. The APP, some modules or some subsystems may not be aware that the Monkey test has exited and fail to take corresponding measures, which may lead to deviations in the test results.

[0025] Please refer to Figure 1 , Figure 1 1 is a flow chart of a first embodiment of a method for identifying a test scenario provided by the present invention. The method for identifying a test scenario provided by the present invention comprises the following steps:

[0026] S101: Determine whether the target test program is started and if so, execute step S102.

[0027] In a specific implementation scenario, the target test program is a Monkey test program. Since Monkey testing has situations such as disorder and randomness that are not real usage scenarios, the detection needs to detect whether the Monkey test program is in a running state. For example, a monitoring logic or monitoring attribute can be set. When the Monkey function starts running, the monitoring logic or monitoring attribute will return a monitoring information, and the Monkey test program is judged to be started based on the monitoring information. For example, if the monitoring information is received or the monitoring information includes preset data, it is determined that the Monkey test program is started.

[0028] S102: providing an application programming interface to at least two preset objects, so that the at least two preset objects can call the application programming interface.

[0029] In a specific implementation scenario, at least two preset objects include an APP layer and a Native layer. In other implementation scenarios, at least two preset objects also include some modules and / or some subsystems. An API (Application Programming Interface) is provided to at least two preset objects so that the at least two preset objects can call the API, so that the at least two preset objects can obtain information about whether the Monkey test program is running through the API. In this implementation scenario, two APIs are provided to the APP layer and the Native layer respectively.

[0030] Since Monkey testing involves disordered and random non-realistic usage scenarios, for example, opening the camera program 100 times in 1 second will exceed the load of the camera program. If the Monkey test instructions are followed, the system under test may freeze or crash, making the test impossible and affecting the test effect. After notifying the APP layer and the Native layer, some programs corresponding to the APP layer and the Native layer can refuse to execute similar test instructions that may cause the system under test to freeze or crash, ensuring the smooth progress of the test and improving the test efficiency.

[0031] S103: Determine whether the target test program has exited. If so, execute step S104.

[0032] In a specific implementation scenario, when it is determined that the Monkey test has been started, it is monitored whether the Monkey test has exited, so as to notify the relevant objects to take corresponding actions in time. Specifically, a monitoring logic can be embedded in the Monkey's exit process or signal processing process. When the Monkey function exits, the monitoring logic or monitoring attribute will return a monitoring information, and the Monkey test program is judged to be started based on the monitoring information. For example, if the monitoring information is received or the monitoring information includes preset data, it is determined that the Monkey test program has exited.

[0033] S104: Notify at least two preset target test programs to exit through an application programming interface.

[0034] In a specific implementation scenario, when it is determined that the Monkey test program has exited, at least two preset objects are notified through the API interface, and the Monkey test program is determined to exit, so that at least two preset objects, such as the APP layer and the Native layer, can take corresponding measures.

[0035] From the above description, it can be seen that in this embodiment, when the target test program starts running, an application programming interface is provided to at least two preset objects, and the at least two preset objects are notified of the start-up and exit of the target test program through the application programming interface, so that the at least two preset objects can take corresponding operations according to the start-up and exit of the target test program, thereby ensuring the smooth progress of the test and improving the test efficiency and reliability.

[0036] See also Figure 2 , Figure 2 1 is a flow chart of a second embodiment of the test scene recognition method provided by the present invention. The test scene recognition method provided by the present invention comprises the following steps:

[0037] S201: Obtain first logic information of a function entry set in a target test program, and determine whether the target test program is started and run according to the first logic information. If yes, execute step S202.

[0038] In a specific implementation scenario, the target test program is a Monkey test program, which is a bin file, i.e., an executable file. For Android executable files, there are usually function entries, such as main function, start function, etc. The Monkey command startup can be identified at the main function entry. For example, a monitoring logic is set at the main function entry, the first logic information of the monitoring logic is obtained, and the Monkey test program is judged whether it is started and running according to the first logic information.

[0039] S202: providing an application programming interface to at least two preset objects, so that the at least two preset objects can call the application programming interface.

[0040] In a specific implementation scenario, step S202 is substantially consistent with step S102 in the first embodiment of the test scenario identification method provided by the present invention, and will not be described in detail herein.

[0041] S203: After at least two preset objects call the application programming interface, record the at least two preset objects that call the application programming interface.

[0042] In a specific implementation scenario, after at least two preset objects, such as the APP layer and the Native layer, call the API, they will register themselves in the subscription list, and the at least two preset objects that call the application programming interface will be recorded according to the subscription list. The subscription list may include information on all preset objects that call the API. If other preset objects have called the API before determining whether the target test program is started, these preset objects will also be included in the subscription list.

[0043] S204: Notify at least two preset objects through an application programming interface that the target test program has started running.

[0044] In a specific implementation scenario, if the Monkey test program has been started, the preset object in the subscription list is notified through the API interface that the Monkey test program has been started.

[0045] S205: Acquire the second logic information set in the exit process of the target test program, and determine whether the target test program has exited according to the second logic information. If yes, execute step S207.

[0046] In a specific implementation scenario, if the Monkey test program runs normally, it will automatically exit after the preset test task is completed. The second logic is embedded in the normal exit process of the Monkey test, the logic information of the second logic is obtained, and it is determined whether the Monkey test program exits according to the second logic information.

[0047] S206: Acquire the third logic information set in the signal processing flow of the target test program, and determine whether the target test program has exited the operation according to the third logic information. If yes, execute step S207.

[0048] In a specific implementation scenario, if a problem occurs during the running of the Monkey test program and it exits abnormally, the system will execute the process destruction process. In the Android or Linux system, the process destruction process is handled by signals. The third logic is embedded in the signal processing process to obtain the third logic information of the third logic. The third logic information is used to determine whether the Monkey test program should exit.

[0049] It should be noted that one of step S205 and step S206 is selected for execution according to the actual usage (whether the exit is normal).

[0050] S207: Notify at least two preset target test programs recorded to exit through the application programming interface.

[0051] In a specific implementation scenario, if it is determined that the Monkey test program has exited, at least two preset objects in the subscription list, such as the APP layer and the Native layer, are notified that the Monkey test program has exited, so that the APP layer and the Native layer can take corresponding measures in response to the exit of the Monkey test program to avoid affecting the test results and improve the reliability and efficiency of the test.

[0052] It can be seen from the above description that in this embodiment, by obtaining the first logic information set at the function entry of the target test program, when the target test program is started and run according to the first logic information, an application programming interface is provided to at least two preset objects, and the at least two preset objects are notified of the start-up and exit of the target test program through the application programming interface, so that the at least two preset objects can take corresponding operations according to the start-up and exit of the target test program, thereby ensuring the smooth progress of the test and improving the test efficiency and reliability.

[0053] See also Figure 3 , Figure 3 The test system 10 includes: a first judgment module 11 , an interface providing module 12 , a second judgment module 13 and an exit notification module 14 .

[0054] The first judgment module 11 is used to judge whether the target test program is started. The interface providing module 12 is used to provide an application programming interface to at least two preset objects if the target test program is started, so that at least two preset objects can call the application programming interface. The second judgment module 13 is used to judge whether the target test program has exited. The exit notification module 14 is used to notify at least two preset objects of the exit of the target test program through the application programming interface if the target test program has exited.

[0055] The interface providing module 12 is further configured to notify the at least two preset objects through the application programming interface that the target test program has started running after the at least two preset objects call the application programming interface.

[0056] The interface providing module 12 is further configured to record the at least two preset objects that call the application programming interface after the at least two preset objects call the application programming interface.

[0057] The exit notification module 14 is used to notify at least two preset target test programs recorded to exit running through an application programming interface.

[0058] The first judgment module 11 is further used to obtain first logic information of a function entry set in the target test program, and judge whether the target test program is started and run according to the first logic information.

[0059] The second judgment module 13 is further used to obtain second logic information set in the exit process of the target test program, and judge whether the target test program is exited according to the second logic information.

[0060] The second judgment module 13 is further used to obtain third logic information set in the signal processing flow of the target test program, and judge whether the target test program has exited the operation according to the third logic information.

[0061] Among them, the target test program is the Monkey test program.

[0062] It can be seen from the above description that in this embodiment, the test system determines when the target test program starts running by setting the first logic information at the function entry of the target test program, and provides an application programming interface to at least two preset objects; determines when the target test program exits running by setting the second logic information in the exit process of the target test program or the third logic information in the signal processing process of the target test program, and notifies the at least two preset objects of the start-up and exit of the target test program through the application programming interface, so that the at least two preset objects can take corresponding operations according to the start-up and exit of the target test program, thereby ensuring the smooth progress of the test and improving the test efficiency and reliability.

[0063] See also Figure 4 , Figure 4 1 is a schematic diagram of the structure of an embodiment of the test device provided by the present invention. The transaction device 20 includes a processor 21 and a memory 22. The processor 21 is coupled to the memory 22. The memory 22 stores a computer program, and the processor 21 executes the computer program when working to implement the following Figure 1-Figure 2 The detailed method can be found in the above, which will not be described here.

[0064] It can be seen from the above description that in this embodiment, the test device determines when the target test program starts running by setting the first logic information at the function entry of the target test program, and provides an application programming interface to at least two preset objects; determines when the target test program exits running by setting the second logic information in the exit process of the target test program or the third logic information in the signal processing process of the target test program, and notifies the at least two preset objects of the start-up and exit of the target test program through the application programming interface, so that the at least two preset objects can take corresponding operations according to the start-up and exit of the target test program, thereby ensuring the smooth progress of the test and improving the test efficiency and reliability.

[0065] See also Figure 5 , Figure 5 The storage medium 30 stores at least one computer program 31, which is used to be executed by the processor to implement the following. Figure 1-Figure 3 In one embodiment, the computer readable storage medium 30 may be a storage chip, a hard disk, a mobile hard disk, a USB flash drive, an optical disk, or other readable and writable storage tools in a device, or a server, etc.

[0066] From the above description, it can be seen that the computer program in the storage medium of the present invention can be used to determine when the target test program starts running by setting the first logic information at the function entry of the target test program, provide an application programming interface to at least two preset objects, determine when the target test program exits running by setting the second logic information in the exit process of the target test program or the third logic information in the signal processing process of the target test program, and notify the at least two preset objects of the start-up and exit of the target test program through the application programming interface, so that the at least two preset objects can take corresponding operations according to the start-up and exit of the target test program, thereby ensuring the smooth progress of the test and improving the test efficiency and reliability.

[0067] Different from the prior art, the present invention provides APIs for at least two preset objects at the same time, which can promptly notify the APP layer and the Native layer whether the Monkey test program is in a running state, so that the corresponding operations can be taken to ensure the smooth progress of the test and improve the test efficiency and reliability.

[0068] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0069] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A method for identifying a test scene, characterized in that: include: Determine whether the target test program is started and running; If the target test program is started, an application programming interface is provided to at least two preset objects so that the at least two preset objects can call the application programming interface; Determine whether the target test program has exited operation; If the target test program exits running, notifying the at least two preset objects through the application programming interface that the target test program exits running; in, The step of determining whether the target test program has exited operation includes: Acquire second logic information set in the exit process of the target test program, and determine whether the target test program is to exit according to the second logic information; The at least two preset objects include an APP layer and a Native layer.

2. The method for identifying a test scene according to claim 1, characterized in that: After the step of providing the application programming interface to at least two preset objects, the method further comprises: After the at least two preset objects call the application programming interface, the at least two preset objects are notified through the application programming interface that the target test program has started running.

3. The method for identifying a test scene according to claim 1, characterized in that: After the step of providing the application programming interface to at least two preset objects, the method further comprises: After the at least two preset objects call the application programming interface, recording the at least two preset objects that call the application programming interface; The step of notifying the at least two preset objects through the application programming interface that the target test program exits operation includes: The at least two preset objects of the record are notified through the application programming interface that the target test program exits execution.

4. The method for identifying a test scene according to claim 1, characterized in that: The step of determining whether the target test program is started and running comprises: The first logic information of the function entry set in the target test program is obtained, and it is determined whether the target test program is started and executed according to the first logic information.

5. The method for identifying a test scene according to claim 1, characterized in that: The step of determining whether the target test program has exited operation includes: Acquire third logic information set in the signal processing flow of the target test program, and determine whether the target test program exits operation according to the third logic information.

6. The method for identifying a test scene according to claim 1, characterized in that: The target test program is the Monkey test program.

7. A testing system, characterized in that: include: The first judgment module is used to judge whether the target test program is started and running; An interface providing module, configured to provide an application programming interface to at least two preset objects if the target test program is started, so that the at least two preset objects can call the application programming interface; A second judgment module is used to judge whether the target test program has exited operation; An exit notification module, configured to notify the at least two preset objects through the application programming interface that the target test program has exited if the target test program has exited; in, The step of determining whether the target test program has exited operation includes: Acquire second logic information set in the exit process of the target test program, and determine whether the target test program is to exit according to the second logic information; The at least two preset objects include an APP layer and a Native layer.

8. A testing device, characterized in that: include: A processor and a memory, wherein the processor is coupled to the memory, a computer program is stored in the memory, and the processor executes the computer program to implement the method according to any one of claims 1 to 6.

9. A storage medium, characterized in that: A computer program is stored, and the computer program can be executed by a processor to implement the method according to any one of claims 1 to 6.