Test method and device

By analyzing the event cache of the to-test application, automatically exploring and generating properties related to data processing functions, the problem of time-consuming and labor-consuming manual writing properties in the prior art is solved, and efficient property acquisition and testing efficiency is achieved.

CN119669075APending Publication Date: 2025-03-21BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411748462.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-29
Publication Date
2025-03-21

AI Technical Summary

Technical Problem

Property-based testing methods require manual writing of properties, which is time-consuming and costly, and the prior art is difficult to improve testing efficiency and reduce costs.

Method used

By analyzing the event cache of the to-test application, properties related to the data processing function, including preconditions, event sequences, and postconditions, are automatically explored and generated, including preconditions, event sequences, and postconditions, to indicate that the application performs expected behavior under specific inputs and operations.

Benefits of technology

It realizes automatic exploration of applications to be tested and generates properties, improves property acquisition efficiency and property-based testing efficiency, reduces testing costs, and improves the practicality of the test method.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119669075A_ABST
    Figure CN119669075A_ABST
Patent Text Reader

Abstract

The invention discloses a test method, aiming at an application to be tested, each event corresponding to the operation of the application to be tested is cached, and aiming at a cached first event, if an object list associated with a first page corresponding to the first event is non-null and an object list associated with a second page is determined to change compared with the object list associated with the first page, the first event is cached; and if yes, acquiring at least part of events executed between the second event and the first event. Wherein the occurrence time of the second event corresponding to the second page is earlier than that of the first event, and the state of the second page is the target state. And judging whether the features corresponding to the at least part of events are matched with the features of the function corresponding to the target content, if so, obtaining the properties corresponding to the function based on the at least part of events, and testing the to-be-tested application based on the properties. Therefore, according to the scheme, the to-be-tested application can be automatically explored, the property related to the data processing function is generated, and the property-based testing efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a testing method and device. Background Art

[0002] Property-based testing is a popular automated testing technique. The principle is that the tester writes real logical statements (i.e. properties) that apply to the software to be tested, and then uses automated testing tools to generate a large number of test inputs to fully test the software to be tested and verify whether the properties written by the tester are met. If the properties are violated, it indicates that there may be errors (bugs) in the software.

[0003] However, the property-based testing method requires testers to manually write properties. To obtain properties, testers not only need to have a certain understanding of the application to be tested, but also need to be proficient in the property definition language, which places certain requirements on testers. Moreover, manually writing properties is time-consuming, labor-intensive, and costly. Summary of the invention

[0004] In view of this, an embodiment of the present application provides a testing method and apparatus to improve the efficiency of property-based testing and reduce testing costs.

[0005] To achieve the above purpose, the technical solutions provided by the embodiments of the present application are as follows:

[0006] In a first aspect of the present application, a testing method is provided, the method comprising:

[0007] For a first event in the event cache corresponding to the application to be tested, if the object list associated with the first page corresponding to the first event is not empty, determine whether the object list associated with the second page has changed from the object list associated with the first page; wherein the occurrence time of the second event corresponding to the second page is earlier than the occurrence time of the first event, and the state of the second page is the target state;

[0008] If there is a change, obtaining at least part of the events executed between the second event and the first event;

[0009] If the features corresponding to at least part of the events match the features of the functions corresponding to the target content, obtaining the properties of the functions based on at least part of the events; wherein the application to be tested includes the functions, the properties are logical statements used to describe the implementation of the functions by the application to be tested, and the properties are used to instruct the application to be tested to perform expected behaviors under specific inputs and operations;

[0010] The application to be tested is tested based on the property.

[0011] In a second aspect of the present application, a testing device is provided, the device comprising:

[0012] A processing unit, configured to determine, for a first event in an event cache corresponding to an application to be tested, whether a list of objects associated with a second page has changed from a list of objects associated with the first page if the list of objects associated with the first page corresponding to the first event is not empty; wherein, if an occurrence time of a second event corresponding to the second page is earlier than an occurrence time of the first event, a state of the second page is a target state;

[0013] an acquisition unit, configured to acquire, if a change occurs, at least a portion of events executed between the second event and the first event;

[0014] The acquisition unit is further configured to acquire the property of the function based on the at least part of the event if the feature corresponding to the at least part of the event matches the feature of the function corresponding to the target content; wherein the application to be tested includes the function, the property is a logical statement used to describe the implementation of the function by the application to be tested, and the property is used to instruct the application to be tested to perform expected behavior under specific input and operation;

[0015] A testing unit is used to test the application to be tested based on the property.

[0016] In the third aspect of the present application, an electronic device is provided, comprising: a processor and a memory; the memory is used to store instructions or computer programs; the processor is used to execute the instructions or computer programs in the memory, so that the electronic device executes the method described in the first aspect.

[0017] In a fourth aspect of the present application, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium. When the instructions are executed on a device, the device executes the method described in the first aspect.

[0018] In a fifth aspect of the present application, a computer program product is provided, wherein the computer program product comprises a computer program / instructions, and when the computer program / instructions are executed by a processor, the method described in the first aspect is implemented.

[0019] It can be seen that the embodiments of the present application have the following beneficial effects:

[0020] In the present application, for a certain application to be tested, the application to be tested is operated, and each event corresponding to the application to be tested when the operation is executed is cached. For any cached event (first event), it is determined whether the object list associated with the first page corresponding to the first event is non-empty. If so, it is determined whether the object list associated with the second page has changed compared with the object list associated with the first page. If it has changed, at least part of the events (including the first event and the second event) executed from the second event to the first event are obtained. Among them, the occurrence time of the second event corresponding to the second page is earlier than the occurrence time of the first event, and the state of the second page is the target state. It is determined whether the characteristics corresponding to the at least part of the event match the characteristics of the function corresponding to the target content. If they match, the properties corresponding to the function are obtained based on the at least part of the event, and the application to be tested is tested based on the properties. It can be seen that this scheme can automatically explore the application to be tested and generate properties related to the data processing function without manual writing, improve the efficiency of property acquisition and the efficiency of property-based testing, and improve the practicality of the property-based testing method. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the embodiments of the present application 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 recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0022] Figure 1 A flow chart of an event caching method provided in an embodiment of the present application;

[0023] Figure 2 A schematic diagram of events or keywords corresponding to different functions provided in an embodiment of the present application;

[0024] Figure 3 A schematic diagram of a testing method flow chart provided in an embodiment of the present application;

[0025] Figure 4 A schematic diagram of a triple corresponding to different functions provided in an embodiment of the present application;

[0026] Figure 5 A property acquisition framework structure diagram provided in an embodiment of the present application;

[0027] Figure 6 A schematic diagram of an application scenario provided for an embodiment of the present application;

[0028] Figure 7 A structural diagram of a test device provided in an embodiment of the present application;

[0029] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0030] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0031] The property-based application testing method requires defining the properties of each function, including preconditions, event sequences, impact on application data (can be empty), and postconditions. During the test, the tool will continuously select and execute the event sequences of each function in the application to check whether the application meets the defined properties. Once the properties are violated, it indicates that there is an error in the application. At this time, all executed event sequences will be recorded and further analyzed by replaying the errors. Among them, the properties of the function refer to the expected behavior or results that the application should provide under specific inputs and operations.

[0032] Normally, the properties of a function can be represented by a triple, such as <precondition, event sequence, postcondition>. For example, the properties of adding a function can be represented as a precondition: there is an entry to add the function; an event sequence: click the add button - enter the added data - click the save button; the postcondition is: the added data is saved in the data list corresponding to the page. From the above property representation, it can be seen that for any application page with an add function, after performing the following three actions: click the add button - enter the data - click the save button, an application state that meets the postcondition (the added data exists in the data list) will be reached. It can be seen that property-based testing can quickly detect potential errors.

[0033] Since property-based testing does not require too many detailed descriptions of the output, it only needs to check whether the output has certain specific characteristics, which can be used to detect mobile applications. Since property-based testing methods still require testers to manually define properties, the efficiency of property acquisition is low.

[0034] Based on this, the present application proposes a testing method that can automatically generate properties for verifying common functions in mobile applications, such as adding, deleting, modifying, and searching, and test the mobile application based on the properties, which not only improves the efficiency of obtaining properties, but also improves the efficiency and practicality of property-based testing.

[0035] It should be noted that, in the present application, a series of events generated when the application is operated are usually cached first, and then the cached event sequence is analyzed to identify and output the properties of a certain function.

[0036] To facilitate understanding of the specific implementation of the present application, the event caching process will be described below in conjunction with a specific embodiment.

[0037] See also Figure 1 , which is a flow chart of an event caching method provided in an embodiment of the present application, such as Figure 1 As shown, the method includes:

[0038] S101: Start the application to be tested.

[0039] In order to obtain the properties of certain functions in the application to be tested, the application to be tested may be installed on the device generating the properties, and the application to be tested may be started.

[0040] S102: Obtain the identifier of the page currently presented by the application.

[0041] When the application enters a page, the page's ID is obtained.

[0042] It should be noted that the implementation of a function may involve only one page or different pages. However, the implementation of a function usually corresponds to multiple actions, that is, multiple events (one action corresponds to one event). For example, the implementation of the add function includes the action of clicking the add button, the input action, and the action of clicking the save button. In order to distinguish different events, they can be distinguished based on the state hash value of the page corresponding to each event. That is, the identifier of the page is defined as the hash value of the corresponding state of the page, and the hash value is determined by the object list corresponding to the page and / or the controls existing on the page. For example, the component tree and object list of the current page are obtained, and the identifier of the current page is determined based on the component tree and object list.

[0043] In this implementation, when the object list corresponding to a page changes or the controls existing on the page change, the hash value of the corresponding state of the page will change.

[0044] S103: For the controls included in the page, record relevant events generated by triggering the controls.

[0045] For the controls included in the current page, a matching action (such as click, long press, input) can be generated for each control. By executing the action, a corresponding event is generated, and information such as the event corresponding to each action, the identifier of the corresponding page where the event occurs, and the object list corresponding to the page is recorded, thereby obtaining the cached events.

[0046] In order to avoid generating unnecessary events and causing a large event cache, actions can be generated for certain specific controls and executed. Specifically, the following situations can be included:

[0047] If the current page has a control or a control sequence related to adding functions, an action is generated for the control and executed.

[0048] If there is a control or a control sequence related to the deletion function on the current page, an action is generated for the control and executed.

[0049] If there is a control or a control sequence related to the search function on the current page, an action is generated for the control and executed.

[0050] If there is a control or a control sequence related to the modification function on the current page, an action is generated for the control and executed.

[0051] If the current page does not have any controls related to adding, deleting, modifying, or checking, a control is randomly selected, an action is generated for the control, and the action is executed.

[0052] Usually, the cached events are related to the executable events or control keywords existing in the current page. When the page has the corresponding executable events or control keywords, the above executable events will be executed or the controls containing the keywords will be operated according to a certain probability, thereby generating related events and obtaining event cache.

[0053] For example, Figure 2 As shown, for the add function, the executable events existing in the corresponding page include input events, and the control keywords include save, ok, add, new and fab; for the delete function, the control keywords existing in the corresponding page include more, delete, achive, trash; for the search function, the executable events existing in the corresponding page include input events, and the control keywords include search and enter; for the modify function, the executable events existing in the corresponding page include input events, and the control keywords include save and ok.

[0054] After obtaining the event cache corresponding to the application to be tested, the event cache is analyzed, and the properties corresponding to each data operation function included in the application to be tested are determined according to the cached data.

[0055] See also Figure 3 , which is a flow chart of a test method provided in an embodiment of the present application, such as Figure 3 As shown, the method includes:

[0056] S301: For a first event in the event cache, if the object list associated with the first page corresponding to the first event is not empty, determine whether the object list associated with the second page has changed from the object list associated with the first page.

[0057] S302: If a change occurs, obtain at least a portion of events executed between the second event and the first event.

[0058] Among them, the occurrence time of the second event corresponding to the second page is earlier than the occurrence time of the first event, and the state of the second page is the target state. The object list corresponding to the first page and the object list corresponding to the second page are the same list, but the contents in the object lists may be different. Among them, the object list corresponding to the page usually refers to the collection of all interactive elements on the page and their related attributes. These elements can include buttons, text boxes, links, drop-down menus, pictures, labels, etc., all of which can be regarded as "objects" of the page. By defining an object list, it can help testers and developers locate and operate page elements, especially in automated testing.

[0059] The state of the second page being in the target state means that the second page has target content, and the target content means that the page has keywords and other content related to the operable controls. Keywords related to the operable controls corresponding to different data operation functions may be the same or different. For details, see Figure 2 .

[0060] When it is determined that the object list associated with the first page is not empty, it is necessary to compare it with the object list associated with the page corresponding to the previous event to determine whether the object list associated with the previous page and the object list corresponding to the first page have changed. If so, obtain at least part of the events executed between the second event and the first event, and the at least part of the events include the first event and the second event.

[0061] It should be noted that, usually, a page is transferred between the following states: idle state, start state, keyword state and end state. Among them, the idle state refers to an uninitialized state, and the initialized state is usually the "start state". The implementation of a function includes transferring from the start state to the keyword state and then to the end state, and the corresponding events of each of the above states are used as the event sequence of the function. In this embodiment, the target state can be replaced by the keyword state.

[0062] Normally, for a newly read event in the cache, for the page corresponding to the event, if the page is transferred from the idle state to the starting state, it is necessary to compare with the object list associated with the pages corresponding to all events before the event. However, when the object list changes, the state of the previous page will be transferred to the ending state, and the state transfer cannot jump directly from the starting state to the ending state. Therefore, when comparing, it is only necessary to compare with the object list associated with the previous page in the keyword state, thereby improving processing efficiency.

[0063] Based on this, if the object list associated with the second page changes with the object list associated with the first page, the state of the second page is updated to the end state, so that the second page completes the transition between all states.

[0064] Specifically, when traversing the first event in the event cache, first determine whether there is an object list for the first event. If there is an object list, determine the state of the first page as the starting state; then determine whether there is target content in the first page. If there is target content, determine the state of the first page as the target state. That is, if there is an object list in the first page, determine the state of the first page as the starting state; if there is still target content in the first page, transfer the state of the first page from the starting state to the target state; if there is no target content, the state of the first page remains in the starting state.

[0065] It should be noted that since the object list associated with the second page is fixed, the content in the object list will not change regardless of when the comparison is made. Therefore, the timing for judging whether the object list associated with the second page and the object list associated with the first page have changed can be when the state of the first page is the starting state, or when the state of the first page is the target state. It is sufficient to compare with the second page once to improve processing efficiency.

[0066] S303: If the feature corresponding to the at least part of the event matches the feature of the function corresponding to the target content, obtain the property of the function based on the at least part of the event.

[0067] The feature corresponding to at least part of the event refers to the feature of the change in the content of the object list, and based on the feature, it is determined whether it matches the feature of the function corresponding to the target content, and if it matches, the property of the function is obtained based on the at least part of the event. The application to be tested includes the function, and the property is a logical statement used to describe the implementation of the function by the application to be tested, which is used to instruct the application to be tested to perform expected behavior under specific input and operation.

[0068] Among them, different functions correspond to different features, such as Figure 4As shown, the feature corresponding to the add function is that a new object is added to the object list; the feature corresponding to the delete function refers to the reduction of an object from the object list; the feature corresponding to the search function refers to the inclusion of only one object in the object list and the object is an object in the original object list; the feature corresponding to the modify function refers to the fact that the number of objects included in the object list has not changed, but the specific content of the object has changed.

[0069] Specifically, if the content of the object list corresponding to the first page is compared with the content of the object list corresponding to the second page, the object is increased (that is, the so-called characteristics corresponding to at least part of the event), and it matches the characteristics of the added function, then the properties of the added function are obtained based on the at least part of the event.

[0070] If the contents of the object list corresponding to the first page are compared with the contents of the object list corresponding to the second page, the objects are reduced (that is, the so-called characteristics corresponding to at least part of the event), and they match the characteristics of the deletion function, then the properties of the deletion function are obtained based on the at least part of the event.

[0071] If the number of objects in the object list corresponding to the first page is reduced compared to the content of the object list corresponding to the second page, but the objects in the object list corresponding to the second page include the objects in the object list corresponding to the first page (i.e., the so-called characteristics corresponding to at least part of the events), which match the characteristics of the search function, then the properties of the search function are obtained based on the at least part of the events.

[0072] If the content of the object list corresponding to the first page is compared with the content of the object list corresponding to the second page, the number of objects has not changed but the form of expression of an object has changed (that is, the so-called feature corresponding to at least part of the event), and it matches the feature of the modification function, then the properties of the modification function are obtained based on the at least part of the event.

[0073] Wherein, obtaining the properties of the function based on at least part of the events includes: determining the preconditions, event sequences and postconditions corresponding to the realization of the function based on the at least part of the events; and taking the triple consisting of the preconditions, event sequences and postconditions as the properties of the function. Wherein, the preconditions refer to the prerequisites for realizing a certain function, the event sequence refers to a series of events executed to realize the function, and the postconditions refer to the expected results that can be achieved after executing the function, and the event sequence includes at least part of the above events arranged in chronological order.

[0074] S304: Testing the application to be tested based on its properties.

[0075] In this embodiment, after obtaining the properties of the corresponding functions of the application to be tested, the properties can be used to test various functions of the application to be tested to test whether each function can achieve expected behavior.

[0076] It can be seen that this solution can automatically explore the application to be tested and generate properties related to the data processing function without manual writing, thereby improving the efficiency of property acquisition and property-based testing, and enhancing the practicality of property-based testing methods.

[0077] To understand the specific implementation of this application, see Figure 5 The properties shown generate a framework diagram, such as Figure 5 As shown, the implementation framework includes:

[0078] Get the event cache and traverse the different events in the event cache;

[0079] Determine whether all events have been traversed. If so, end the process. If not, read the events in the order of their occurrence.

[0080] Determine whether the object list of the page corresponding to the event is empty. If it is empty, determine whether the target content exists on the current page. If it is not empty, determine whether the state of the page is initialized, that is, whether the current state is the "starting state";

[0081] If the state of the page has not been initialized, the state of the page is updated to the "starting state"; if the state of the page has been initialized, it is determined whether the current page has the target content;

[0082] If the target content does not exist, determine whether the object list corresponding to the current page has changed compared to the target page; wherein the target page refers to a page in a target state and the event occurrence time corresponding to the target page is earlier than the event occurrence time corresponding to the current page;

[0083] If the target content exists, the state of the current page is updated to the target state, and it is determined whether the object list corresponding to the current page has changed compared to the target page;

[0084] If no change occurs, check the next event; if a change occurs, obtain all events from the event corresponding to the target page to the event corresponding to the current page, and determine whether the features corresponding to all events match the features of a certain function;

[0085] If there is a match, the nature of the function is determined based on all the events; otherwise, it is determined whether all events have been traversed and the next event is obtained.

[0086] It should be noted that for each cached event and the page corresponding to the event, it is necessary to determine whether the page has completed the transition from idle state-starting state-target state-end state. Specifically, when the page is in idle state and the object list corresponding to the page is not empty, the page is transferred from idle state to start state; continue to determine whether the page has target content, if so, the page is transferred from start state to target state; then determine whether the object list corresponding to the page is compared with the object list corresponding to the target page, if there is any change, the state of the target page is transferred from target state to end state.

[0087] For easier understanding, see Figure 6 The following is a schematic diagram of an application scenario using search as an example. In this scenario, Figure 6 Each page in the event list corresponds to an event, which are event 1 to event 5 from left to right. The target content is the keyword related to the control.

[0088] In event 1, the object list is empty and the DMF keyword is empty. Check the next event.

[0089] In event 2, the object list is not empty, the current page hash is "bc3d9d", and the state corresponding to the page is the starting state. In this state, the object list is ["cantaloupe", "pumpkin", "yumberry"]. Since the keyword of the page is not empty, it is "Search_cantaloupe", and the state of the current page is updated to the keyword state, that is, the state of the "bc3d9d" page is the keyword state. The object list ["cantaloupe", "pumpkin", "yumberry"] has not changed compared to the starting state. Currently, the state of the "bc3d9d" page is the keyword state (Search_cantaloupe), and the next event is checked.

[0090] In event 3, the object list is not empty, the current page hash is "0704ae", and the state corresponding to the page is the start state. The page keyword is empty, and the object list ["cantaloupe", "pumpkin", "yumberry"] has not changed compared to the object list of the "bc3d9d" page in the keyword state. Currently, the state of the "bc3d9d" page is the keyword state, and the state of the "0704ae" page is the start state. Check the next event.

[0091] In event 4, the object list is not empty, the current page hash is "0dc803", and the state of the page is the starting state. The keyword of the page is empty, and the object list ["cantaloupe", "pumpkin", "yumberry"] has not changed compared to the object list of the "bc3d9d" page in the keyword state. Currently, the state of the "bc3d9d" page is the keyword state (Search_cantaloupe), the state of the "0704ae" page is the starting state, and the state of the "0dc803" page is the starting state. Check the next event.

[0092] In event 5, the object list is not empty, the current page hash is "27b667", and the state of the page is the starting state. The keyword of the page is not empty, it is "Add", and the state corresponding to the current page is updated to the keyword state, that is, the state of the "27b667" page is the keyword state (Add). Currently, the keyword state of the "bc3d9d" page is "Search_cantaloupe", and the keyword state of the "27b667" page is "Add". Among them, the object list ["cantaloupe"] corresponding to the "27b667" page has changed compared to the object list ["cantaloupe", "pumpkin", "yumberry"] corresponding to the "bc3d9d" page and satisfies the property triple of Searh_cantaloupe. The event sequence that saves the starting state to the present is the search (search) property.

[0093] Based on the above method embodiments, the embodiments of the present application provide a testing device and an electronic device, which will be described below in conjunction with the accompanying drawings.

[0094] See also Figure 7 , which is a structural diagram of a test device provided in an embodiment of the present application, such as Figure 7 As shown, the device includes: a processing unit 701, an acquisition unit 702 and a testing unit 703.

[0095] The processing unit 701 is used for determining, for a first event in an event cache corresponding to the application to be tested, whether a list of objects associated with a second page has changed from a list of objects associated with the first page if the list of objects associated with the first page corresponding to the first event is not empty; wherein, if the occurrence time of the second event corresponding to the second page is earlier than the occurrence time of the first event, the state of the second page is the target state;

[0096] An acquisition unit 702 is configured to acquire, if a change occurs, at least a portion of events executed between the second event and the first event;

[0097] The acquisition unit 702 is further configured to acquire the property of the function based on the at least part of the event if the feature corresponding to the at least part of the event matches the feature of the function corresponding to the target content; wherein the application to be tested includes the function, the property is a logical statement used to describe the implementation of the function by the application to be tested, and the property is used to instruct the application to be tested to perform expected behavior under specific input and operation;

[0098] The testing unit 703 is configured to test the application to be tested based on the property.

[0099] In some embodiments, the acquisition unit 702 is specifically used to determine the precondition, event sequence, and postcondition corresponding to implementing the function based on the at least part of the events, and the event sequence includes the at least part of the events arranged in sequence; and the triple consisting of the precondition, event sequence, and postcondition is used as the property of the function.

[0100] In some implementations, the target content includes keywords related to operable controls present on the page.

[0101] In some implementations, the processing unit 701 determines the state of the second page as an end state.

[0102] In some embodiments, the processing unit 701 is further used to determine the state of the first page as the starting state if the object list associated with the first page corresponding to the first event is not empty; if the first page has target content, determine the state of the first page as the target state.

[0103] In some implementations, the functions include at least one or more of the following: adding, deleting, modifying, and searching.

[0104] In some implementations, the process of acquiring the event cache includes:

[0105] Start the application to be tested;

[0106] Obtaining an identifier of a page currently being presented by the application;

[0107] For the controls included in the page, relevant events generated by triggering the controls are recorded, and the event cache includes the identifier of the page, the object list corresponding to the page, and the relevant events.

[0108] In some implementations, the controls include at least one or more of the following: a control related to an add function, a control related to a delete function, a control related to the search function, and a control related to the modify function.

[0109] In some implementations, the identifier of the page is a hash value of a state corresponding to the page, and the hash value of the state is determined by an object list corresponding to the page and / or a control existing on the page.

[0110] It should be noted that the specific implementation of each unit in this embodiment can refer to the relevant description in the above method embodiment. The division of units in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. The functional units in the embodiment of the present application can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. For example, in the above embodiment, the processing unit and the sending unit can be the same unit or different units. The above integrated units can be implemented in the form of hardware or in the form of software functional units.

[0111] See also Figure 8 , which shows a schematic diagram of the structure of an electronic device 800 suitable for implementing the embodiment of the present disclosure. The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 8 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0112] like Figure 8 As shown, the electronic device 800 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage device 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic device 800 are also stored. The processing device 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

[0113] Typically, the following devices may be connected to the I / O interface 805: input devices 806 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 807 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 808 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 809. The communication device 809 may allow the electronic device 800 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 8 The electronic device 800 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0114] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 809, or installed from the storage device 808, or installed from the ROM 802. When the computer program is executed by the processing device 801, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0115] The electronic device provided by the embodiment of the present disclosure and the method provided by the above embodiment belong to the same inventive concept, and the technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0116] The embodiments of the present disclosure provide a computer storage medium on which a computer program is stored. When the program is executed by a processor, the method provided by the above embodiments is implemented.

[0117] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0118] In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, apparatus, or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0119] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0120] The computer-readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device can execute the method.

[0121] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0122] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0123] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit / module does not, in some cases, constitute a limitation on the unit itself.

[0124] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0125] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the system or device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.

[0126] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0127] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0128] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A testing method, characterized in that: The method comprises: For a first event in the event cache corresponding to the application to be tested, if the object list associated with the first page corresponding to the first event is not empty, determine whether the object list associated with the second page has changed from the object list associated with the first page; wherein the occurrence time of the second event corresponding to the second page is earlier than the occurrence time of the first event, and the state of the second page is the target state; If there is a change, obtaining at least part of the events executed between the second event and the first event; If the features corresponding to at least part of the events match the features of the functions corresponding to the target content, obtaining the properties of the functions based on at least part of the events; wherein the application to be tested includes the functions, the properties are logical statements used to describe the implementation of the functions by the application to be tested, and the properties are used to instruct the application to be tested to perform expected behaviors under specific inputs and operations; The application to be tested is tested based on the property.

2. The method according to claim 1, characterized in that: The obtaining the property of the function based on at least part of the events comprises: Determine, based on the at least part of the events, a precondition, an event sequence, and a postcondition corresponding to implementing the function, wherein the event sequence includes the at least part of the events arranged in sequence; The triple consisting of the precondition, the event sequence and the postcondition is used as the property of the function.

3. The method according to claim 1 or 2, characterized in that: The target content includes keywords related to operable controls existing on the page.

4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: The state of the second page is determined as an end state.

5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: If the object list associated with the first page corresponding to the first event is not empty, determining the state of the first page as the initial state; If the first page has target content, the state of the first page is determined as the target state.

6. The method according to any one of claims 1 to 5, characterized in that: The functions include at least one or more of the following: adding, deleting, modifying, and searching.

7. The method according to claim 1, characterized in that The process of obtaining the event cache includes: Start the application to be tested; Obtaining an identifier of a page currently being presented by the application; For the controls included in the page, relevant events generated by triggering the controls are recorded, and the event cache includes the identifier of the page, the object list corresponding to the page, and the relevant events.

8. The method according to claim 7, characterized in that The controls include at least one or more of the following: a control related to an adding function, a control related to a deleting function, a control related to the searching function, and a control related to the modifying function.

9. The method according to claim 7 or 8, characterized in that: The identifier of the page is a hash value of a state corresponding to the page, and the hash value of the state is determined by an object list corresponding to the page and / or a control existing on the page.

10. A testing device, characterized in that: The device comprises: A processing unit, configured to determine, for a first event in an event cache corresponding to an application to be tested, whether a list of objects associated with a second page has changed from a list of objects associated with the first page if the list of objects associated with the first page corresponding to the first event is not empty; wherein, if an occurrence time of a second event corresponding to the second page is earlier than an occurrence time of the first event, a state of the second page is a target state; an acquisition unit, configured to acquire at least a portion of events executed between the second event and the first event if a change occurs; The acquisition unit is further configured to acquire the property of the function based on the at least part of the event if the feature corresponding to the at least part of the event matches the feature of the function corresponding to the target content; wherein the application to be tested includes the function, the property is a logical statement used to describe the implementation of the function by the application to be tested, and the property is used to instruct the application to be tested to perform expected behavior under specific input and operation; A testing unit is used to test the application to be tested based on the property.

11. An electronic device, characterized in that: The electronic device comprises: a processor and a memory; The memory is used to store instructions or computer programs; The processor is used to execute the instructions or computer programs in the memory so that the electronic device executes the method according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on a device, the device executes the method according to any one of claims 1 to 9.

13. A computer program product, characterized in that The computer program product comprises a computer program / instruction, and when the computer program / instruction is executed by a processor, the method according to any one of claims 1 to 9 is implemented.