Method for testing a graphical user interface and related device

By setting up incremental round steps and reinforcement learning in graphical user interface testing, filtering trigger methods, and combining multi-device collaborative testing, the problems of low coverage and stability were solved, achieving more efficient test coverage and discovering application crashes.

CN114625661BActive Publication Date: 2026-03-27GUANGZHOU HUYA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-22
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing technologies have low coverage in graphical user interface testing, failing to detect more application crashes. Furthermore, traditional reinforcement learning strategies fail to balance depth and breadth, and multi-machine parallel strategies are affected by test stability when the central control node fails.

Method used

A graphical user interface testing method is adopted. By setting the number of steps in each round to increase, the triggering methods that meet the conditions are filtered out. The operation is strengthened based on the feedback. The GUI is used to carry whether it carries a completion/incomplete flag. Combined with multi-device collaborative testing, invalid traversal is reduced and coverage is improved.

Benefits of technology

Increase test coverage within a preset timeframe to uncover more application crashes, save testing time, avoid invalid triggers, and enhance test stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114625661B_ABST
    Figure CN114625661B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a kind of graphical user interface test method and related equipment, it is related to software testing field.The method corresponds to a test process, the test process includes multiple rounds of step increment, specifically: obtain first test component, and determine the test GUI in first test component, the test GUI carries unfinished mark and corresponds to the structure tree including multiple test controls;Then, traverse each test control in the structure tree until the end condition is satisfied;Wherein traversal includes triggering test control by screening out trigger mode and carrying out reinforcement operation on the trigger mode adopted according to the feedback obtained by triggering.This application sets multiple rounds of step increment, tests the test GUI carrying unfinished mark, and implements reinforcement operation on trigger mode, to improve the depth and breadth when testing, and effectively utilize test time, so as to improve test coverage in preset time.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of software testing, in particular, the present application relates to a graphical user interface testing method and related equipment. BACKGROUND

[0002] Monkey tool, a test tool using random test strategy, is widely used in Android application testing.

[0003] At present, the native Monkey tool uses a random strategy to traverse the graphical user interface (GUI), but after the test is completed, some GUIs are not tested, that is, the coverage of the traversal process is low. If more GUI scenarios cannot be covered, more application program crash related problems cannot be found.

[0004] To solve this problem, the prior art proposes two technical solutions: (1) a single machine algorithm exploration capability using a traditional reinforcement learning strategy GUI traversal strategy; (2) a multi-machine parallel GUI traversal strategy relying on a central control node.

[0005] However, for solution (1), the exploration of balance depth and breadth cannot improve the coverage effect in the traversal process; for solution (2), if the central control node fails, each test device cannot make autonomous decisions on test actions, that is, the stability of the test process is affected, and finally the entire test result is affected. SUMMARY

[0006] The present application aims to solve one of the above technical problems.

[0007] According to an aspect of an embodiment of the present application, a graphical user interface testing method is provided, which corresponds to a test process, the test process includes multiple rounds, and the number of steps in each round increases in turn. The method comprises:

[0008] In the current round of the test process, a first to-be-tested component is obtained; a to-be-tested graphical user interface (GUI) in the first to-be-tested component is determined, wherein the to-be-tested GUI carries an unfinished flag and corresponds to a structure tree including multiple test controls; each test control in the structure tree is traversed in the following manner until a termination condition is met: the test control is triggered by a selected trigger mode, and the selected trigger mode is reinforced according to the feedback obtained by triggering.

[0009] In one possible implementation, each trigger mode includes a weight value; the test control is triggered by the selected trigger mode, and the selected trigger mode is reinforced according to the feedback obtained by triggering, comprising:

[0010] screening a trigger mode meeting a condition from the plurality of preset trigger modes, wherein a weight value of the trigger mode meeting the condition is greater than a preset threshold; for each trigger mode meeting the condition, the following operations are performed: triggering the test control according to the trigger mode meeting the condition, and obtaining feedback; and performing a reinforcement operation on the trigger mode according to the feedback.

[0011] In a possible implementation, the reinforcement operation on the trigger mode according to the feedback comprises:

[0012] If the feedback is to keep the to-be-tested GUI, the weight value of the trigger mode is set to a preset first value, wherein the first value is less than or equal to the preset threshold; if the feedback is to obtain a new to-be-tested GUI, the weight value of the trigger mode is increased; and if the feedback is to detect a state cycle, the weight value of the trigger mode is decreased.

[0013] In a possible implementation, the test process comprises a historical component set for storing historical to-be-tested components, and if the feedback is to obtain a new to-be-tested GUI, the weight value of the trigger mode is increased, which comprises:

[0014] determining a second to-be-tested component corresponding to the new to-be-tested GUI; if the second to-be-tested component is the same as the first to-be-tested component, the weight value of the trigger mode is increased according to a preset second value; if the second to-be-tested component is different from the first to-be-tested component and is a historical to-be-tested component, the weight value of the trigger mode is increased according to a preset third value; and if the second to-be-tested component is different from the first to-be-tested component and is not a historical to-be-tested component, the weight value of the trigger mode is increased according to a preset fourth value; wherein the second value is less than the third value, and the third value is less than the fourth value.

[0015] In a possible implementation, if the current round has ended and the test process has not ended, the method further comprises:

[0016] performing the test of the next round based on the second to-be-tested component.

[0017] In a possible implementation, after the structure tree is traversed, the method further comprises:

[0018] if the to-be-tested GUI corresponds to a leaf node, determining that a flag of the to-be-tested GUI is complete, wherein the leaf node corresponds to a GUI without a jumpable GUI, and the jumpable GUI is a GUI determined according to a trigger mode corresponding to a test control on the structure tree; and if the to-be-tested GUI corresponds to a non-leaf node and flags of all jumpable GUIs of the to-be-tested GUI are complete, determining that the flag of the to-be-tested GUI is complete.

[0019] In a possible implementation, the to-be-tested GUI in the first to-be-tested component is determined, and specifically comprises:

[0020] According to a preset hash algorithm, a hash operation is performed on a structure tree corresponding to a current GUI of the first to-be-tested component, and an operation result obtained is determined as a code of the current GUI, wherein a flag of the current GUI is unfinished; according to the code of the current GUI, a matching is performed in a historical state set to determine whether there is a historical to-be-tested GUI with the same code; and if the matching fails, the current GUI is determined as a to-be-tested GUI.

[0021] In a possible implementation, the method is applied to any device in a system including a plurality of devices, and in a current round of a test process, a first to-be-tested component is obtained, including:

[0022] In response to a start message sent by the server to the plurality of devices at the same time, a first round is started; at least one common component obtained when the test process is initialized is obtained; each of the at least one common component is sequentially determined as the first to-be-tested component and is tested.

[0023] In a possible implementation, after the test on the at least one common component is ended, the method further includes:

[0024] At least one new to-be-tested component is determined; the at least one new to-be-tested component is sent to the server, and a latest historical component set fed back by the server according to the at least one new to-be-tested component is received; the first to-be-tested component is determined according to the latest historical component set.

[0025] In a possible implementation, the end condition includes at least one of the following:

[0026] The structure tree is traversed completely; the current round is ended; and the test process is ended.

[0027] According to another aspect of the embodiments of the present application, a testing device of a graphical user interface is provided, the device corresponds to a test process, the test process includes a plurality of rounds, and the number of steps in each round is sequentially increased, the device includes:

[0028] An obtaining module is configured to obtain a first to-be-tested component in a current round of a test process; a determining module is configured to determine a to-be-tested GUI in the first to-be-tested component, wherein the to-be-tested GUI carries an unfinished flag and corresponds to a structure tree including a plurality of test controls; and a triggering module is configured to traverse each test control in the structure tree in the following manner until an end condition is met: the test control is triggered by a screened triggering manner, and the screened triggering manner is reinforced according to feedback obtained by the triggering.

[0029] According to another aspect of the embodiments of the present application, an electronic device is provided, which comprises a memory, a processor, and a computer program stored in the memory, and the processor executes the computer program to implement the steps of the method shown in the above-mentioned aspect of the present application.

[0030] According to still another aspect of the embodiments of the present application, a computer readable storage medium is provided, which stores a computer program, and the computer program is executed by a processor to implement the steps of the method shown in the above-mentioned aspect of the present application.

[0031] The technical scheme provided by the embodiments of the present application has the following beneficial effects:

[0032] The present application provides a test method of a graphical user interface, which corresponds to a test process, and the test process comprises a plurality of rounds with increasing steps. The method specifically comprises: obtaining a first to-be-tested component, and determining a to-be-tested GUI in the first to-be-tested component, wherein the to-be-tested GUI carries an unfinished flag and corresponds to a structure tree comprising a plurality of test controls; subsequently, each test control in the structure tree is traversed until a termination condition is met; wherein the traversal comprises triggering the test control by a selected triggering manner and performing a reinforcement operation on the triggering manner adopted for triggering according to the feedback obtained by triggering. The embodiments of the present application achieve the breadth of traversal by setting the increasing steps in each round. In the initial rounds, a plurality of GUIs can be explored, so that the breadth of traversal is achieved. Based on the exploration in the early stage, many GUIs have been marked as completed, so that more steps can be set in the later stage to explore the GUIs that are not easy to be found, so that the depth of traversal is achieved. The GUIs that need to be traversed are determined by setting whether the GUIs carry a completed / unfinished flag, so that the time is saved. The triggering manner that can be triggered is selected by the selection operation on the triggering manner, so that the test time consumed by invalid triggering due to invalid triggering manner is avoided. Then, the triggering manner adopted for triggering is reinforced according to the result of triggering, so that a positive feedback is formed for the subsequent triggering operation. Based on the above technical means, the test coverage can be improved within the preset time of the test process. By covering more scenarios, more application crash-related problems can be found. BRIEF DESCRIPTION OF DRAWINGS

[0033] In order to more clearly illustrate the technical schemes in the embodiments of the present application, the drawings needed in the description of the embodiments of the present application will be briefly introduced.

[0034] Figure 1 A flowchart of a test method of a graphical user interface provided by the embodiments of the present application;

[0035] Figure 2a A scene diagram of a GUI and its structure tree provided by the embodiments of the present application;

[0036] Figure 2b A schematic diagram of results of Experiment 1 provided for an embodiment of the present application;

[0037] Figure 2c A schematic diagram of results of Experiment 2 provided for an embodiment of the present application;

[0038] Figure 3a A schematic diagram of a structure of a test device of a graphical user interface provided for an embodiment of the present application;

[0039] Figure 3b A schematic diagram of a structure of a test device of another graphical user interface provided for an embodiment of the present application;

[0040] Figure 4 A schematic diagram of a structure of an electronic device provided for an embodiment of the present application. DETAILED DESCRIPTION

[0041] Embodiments of the present application will be described herein below with reference to the accompanying drawings. It should be understood that the embodiments described below with reference to the accompanying drawings are exemplary descriptions of the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions of the embodiments of the present application.

[0042] Those skilled in the art can understand that the singular forms "a", "an" and "the" used herein include plural forms unless specifically stated otherwise. It should be further understood that the terms "comprise" and "include" used in the embodiments of the present application mean that the corresponding features can be implemented as the presented features, information, data, steps, operations, elements and / or components, but do not exclude other features, information, data, steps, operations, elements, components and / or combinations thereof supported by the present technology. It should be understood that when we say that an element is "connected" or "coupled" to another element, the element can be directly connected or coupled to the other element, or can mean that the element and the other element are connected through an intermediate element. In addition, "connected" or "coupled" used herein can include wireless connection or wireless coupling. The term "and / or" used herein means at least one of the items defined by the term, for example, "A and / or B" can be implemented as "A", or as "B", or as "A and B".

[0043] In order to make the purposes, technical solutions and advantages of the present application clearer, the embodiments of the present application will be described in further detail below with reference to the accompanying drawings.

[0044] First, several terms related to the present application are introduced and explained:

[0045] Hash algorithm: An algorithm that transforms an arbitrary length input (also called pre-image) into a fixed length output, which is the hash value, through a hash algorithm.

[0046] Monkey tool: A black-box testing tool that uses random testing strategies, commonly used for testing Android applications.

[0047] Activity: One of the four components of an Android application, which includes the graphical user interface part. The graphical user interface refers to the interactive interface when a user operates an Android application. An application includes multiple activities, and an activity includes multiple graphical user interfaces.

[0048] Graphical User Interface (GUI): An operating user interface displayed in graphical form. In mobile platforms (such as Android), the GUI is displayed through activities. Each activity contains one or more GUIs, and each GUI contains different controls. Triggering any control of the GUI currently displayed in the activity may activate another new GUI, which may belong to another activity rather than the current activity.

[0049] Model-based testing (MBT): A testing method characterized by that test cases can be automatically generated completely or partially using models. Specifically, in the process of traversing the GUI, first, the GUI jump model of the application under test is constructed through a testing tool, and then the jump model is used to guide the traversal. Usually, the control tree structure is used to describe the hierarchical structure of the GUI. Different GUIs correspond to different control structure trees, so the GUI can be regarded as a node of the model. By taking appropriate triggering methods (such as clicking, long pressing, scrolling, etc.) on the controls of the GUI, it is possible to switch from one GUI to another, thereby constructing a directed and cyclic graph model of the application under test.

[0050] Reinforcement learning (RL): is one of the paradigms and methodologies of machine learning, which is used to describe and solve the problem of an agent in the process of interaction with the environment by learning a strategy to maximize the reward or achieve a specific goal. Reinforcement learning is the third basic machine learning method in addition to supervised learning and unsupervised learning. Unlike supervised learning, reinforcement learning does not require labeled input-output pairs, and it does not need to correct non-optimal solutions accurately. Its focus is on finding the balance between exploration (of unknown areas) and exploitation (of existing knowledge). Q-learning: a specific reinforcement learning method. Q-learning is to record the learned strategy, so as to tell the agent what action will have the maximum reward value in what situation.

[0051] The application provides a test method, device, electronic equipment and computer readable storage medium of a graphical user interface, which aims to solve one of the technical problems shown in the background.

[0052] The technical solutions of the embodiments of the application and the technical effects produced by the technical solutions of the application will be described below by describing several exemplary embodiments. It should be noted that the following embodiments can be mutually referenced, borrowed or combined. For the same terms, similar features and similar implementation steps in different embodiments, they will not be described repeatedly.

[0053] Referring to Figure 1 The embodiments of the application provide a flowchart of a test method of a graphical user interface, which includes steps S110-S130.

[0054] S110, in the current round of the test process, a first to-be-tested component is acquired.

[0055] The method corresponds to a test process, and the test process includes multiple rounds, and the number of steps in each round is sequentially increased. The "multiple rounds" can represent one round, or two or more rounds, and the current round can be any one of the multiple rounds. Specifically, the number of steps in each round is sequentially increased, which can include: according to the execution order of each round, the number of steps in the corresponding round is sequentially increased.

[0056] In one example, if the multiple rounds have a total of 3 rounds, the first round can be set to 50 steps, the second round can be set to 100 steps, and the third round can be set to 150 steps.

[0057] S120, a to-be-tested graphical user interface (GUI) in the first to-be-tested component is determined, wherein the to-be-tested GUI carries an unfinished flag and corresponds to a structure tree including multiple test controls.

[0058] S130, traversing each test control in the structure tree until a termination condition is met: triggering the test control by the selected trigger mode, and performing a reinforcement operation on the selected trigger mode according to the feedback resulting from the triggering.

[0059] Specifically, the termination condition includes at least one of the following: traversing the structure tree, ending the current round, and ending the test process.

[0060] For example, referring to Figure 2a the structure tree shown, the structure tree includes multiple levels, and each level includes at least one test control. A complete traversal process of a structure tree can include: starting from a first level, determining multiple test controls in the first level, starting from a first test control in the first level, traversing all test controls at the next level of the first test control, after traversing, starting from a second test control in the first level, traversing all test controls at the next level of the second test control, and so on until the last test control in the first level.

[0061] The present application provides a test method of a graphical user interface, which corresponds to a test process including multiple rounds with an increasing number of steps. The method specifically includes: obtaining a first to-be-tested component, and determining a to-be-tested GUI in the first to-be-tested component, the to-be-tested GUI carrying an unfinished flag and corresponding to a structure tree including multiple test controls; subsequently, traversing each test control in the structure tree until a termination condition is met; wherein the traversal includes triggering the test control by a selected trigger mode and performing a reinforcement operation on the trigger mode adopted for triggering according to the feedback resulting from the triggering. The implementation of the present application can explore multiple GUIs in the initial rounds to achieve the breadth of traversal, and based on the exploration in the early stage, many GUIs have been marked as completed, so that more steps can be set in the later stage to explore GUIs that are not easy to be discovered, thereby achieving the depth required for traversal; by setting whether the GUI carries a completed / unfinished flag, the GUIs that need to be traversed are determined, thereby saving time; by the selection operation on the trigger mode, the trigger mode that can be triggered is distinguished, thereby avoiding the test time consumed by invalid triggering due to invalid trigger modes, and then the trigger mode adopted for triggering is reinforced according to the result of the triggering, thereby forming positive feedback for the subsequent triggering operation. Based on the above technical means, the test coverage can be improved within a preset time of the test process. By covering more scenarios, more application crash-related problems can be found.

[0062] The present application also provides a possible implementation, which can include S131-S132.

[0063] S131, screen the trigger mode meeting the condition from the preset plurality of trigger modes, wherein the weight value of the trigger mode meeting the condition is greater than a preset threshold.

[0064] Specifically, the plurality of trigger modes include but are not limited to: a way of clicking a test control, a way of scrolling a test control, and a way of long-pressing a test control.

[0065] Specifically, the current weight value of each trigger mode is obtained, and the current weight value is compared with the preset threshold. Wherein, the trigger mode with the current weight value greater than the preset threshold is determined as the trigger mode meeting the condition.

[0066] Since the trigger mode that can obtain feedback for each test control is not clear, the number and type of the trigger mode set for each test control are the same. Wherein, a weight value is set for each type of trigger mode, and an initial value is set for the weight value when the control belongs to the GUI under test is obtained for the first time. During the test, the weight value of each trigger mode will be adjusted accordingly.

[0067] S132, for each trigger mode meeting the condition, the following operations are performed: triggering the test control in the trigger mode and obtaining feedback; and performing reinforcement operation on the trigger mode according to the feedback.

[0068] In a possible implementation, the reinforcement operation on the trigger mode according to the feedback can specifically include:

[0069] If the feedback is to keep the GUI under test, the weight value of the trigger mode is set to a preset first value; if the feedback is to obtain a new GUI under test, the weight value of the trigger mode is increased; and if the feedback is to detect a state cycle, the weight value of the trigger mode is decreased.

[0070] Specifically, if the state of the GUI under test is kept, i.e. no new GUI is obtained, the weight value of the trigger mode needs to be set to a preset first value. Wherein, the first value is less than or equal to the preset threshold. In an example, the first value can be zero.

[0071] Specifically, the process of detecting a state cycle can include: first, the feedback is to obtain a new GUI and a new component, and second, the new GUI is the same as the GUI under test. Or, triggering any control in the new GUI in any trigger mode, and obtaining another new GUI, the other new GUI is the same as the GUI under test. In view of the above two results of obtaining the same GUI, it can be determined that the feedback is to detect a state cycle, rather than to obtain a new GUI or a new component.

[0072] Each of the GUIs has a code, which can be obtained from a structure tree corresponding to the GUI. By comparing the codes of two GUIs, it is determined whether the two GUIs are identical.

[0073] The triggering mode causing the cycle can be marked by means of reducing the weight value. Setting the weight value to zero can prevent part of the invalid triggering, thereby saving the test time; and the valid triggering can be marked by means of increasing the weight value. The above means are all reinforcement operations based on the feedback obtained from the triggering mode, and embody the essence of reinforcement learning.

[0074] In a possible implementation, if the feedback is a new GUI to be tested, the weight value of the triggering mode is increased, and specifically, the increasing can include:

[0075] A second component to be tested corresponding to the new GUI to be tested is determined.

[0076] If the second component to be tested is identical to the first component to be tested, the weight value of the triggering mode is increased by a preset second value; if the second component to be tested is different from the first component to be tested and is a historical component to be tested, the weight value of the triggering mode is increased by a preset third value; if the second component to be tested is different from the first component to be tested and is not a historical component to be tested, the weight value of the triggering mode is increased by a preset fourth value; wherein the second value is less than the third value, and the third value is less than the fourth value.

[0077] Specifically, the test process includes a historical component set for storing historical components to be tested. The historical component set includes all the components to be tested in all rounds before the current round. The historical component set not only includes a plurality of historical components to be tested, but also includes a jump relationship between each of the historical components to be tested. Each of the components has a code. In the test stage, whether two components are identical can be determined from the perspective of the code.

[0078] In a possible implementation, after the weight value of the triggering mode is increased by the preset fourth value, the second component to be tested is added to the historical component set.

[0079] Specifically, after the second component to be tested is obtained, the second component to be tested is added to the historical component set, and a jump relationship between the second component to be tested and the first component to be tested is established. The jump relationship can include: jumping from a GUI state of the first component to be tested to a new GUI state of the second component to be tested.

[0080] In a possible implementation, if the current round has ended and the test process has not ended: the test of the next round is performed based on the second component to be tested.

[0081] Specifically, in the GUI traversal strategy of the conventional reinforcement learning, the traversal of the next round is generally started by restarting the application after the current round is finished. Since the application is restarted each time, the traversal is started from the start page (e.g., a start advertisement page, a login page, a registration page, etc.) of the application, which results in that the start page is accessed much more frequently than other pages, especially some pages that are not easy to appear. Therefore, if the second test component is found in the current round, the application is not started, and the first test component can be used to enter the second test component to represent the start of the next round.

[0082] In the above embodiment, the weight value of the test control is used to determine whether the test control is traversed, which avoids invalid traversal. However, this cannot avoid repeated traversal of the same GUI. Embodiments of the present application also provide a possible implementation manner. After the structure tree is traversed, the method can further include:

[0083] If the test GUI corresponds to a leaf node, it is determined that the flag of the test GUI is complete; if the test GUI corresponds to a non-leaf node and the flags of all next-level GUIs of the test GUI are complete, it is determined that the flag of the test GUI is complete.

[0084] In the above embodiment, the weight value of the test control is used to determine whether the test control is traversed, which avoids invalid traversal. However, this cannot avoid repeated traversal of the same GUI. Embodiments of the present application also provide a possible implementation manner. After the structure tree is traversed, the method can further include:

[0085] In the above embodiment, the weight value of the test control is used to determine whether the test control is traversed, which avoids invalid traversal. However, this cannot avoid repeated traversal of the same GUI. Embodiments of the present application also provide a possible implementation manner. After the structure tree is traversed, the method can further include:

[0086] In a possible implementation manner, the test GUI in the first test component is determined, which can specifically include:

[0087] The structure tree corresponding to the current GUI of the first test component is subjected to a hash operation according to a preset hash algorithm, and the obtained operation result is determined as the code of the current GUI; and the current GUI is matched in the historical state set according to the code of the current GUI to determine whether there is a historical test GUI with the same code.

[0088] Specifically, a hierarchy structure of a structure tree corresponding to the current GUI of the first to-be-tested component is determined, and from the hierarchy structure, information of all test controls in a first level is sequentially spliced to obtain a string; or information of all test controls in the first level and a second level is sequentially spliced to obtain a string. The length of the obtained string is not fixed. It should be pointed out that the splicing process of the string can be customized according to requirements, and the present application does not limit it. Secondly, the obtained string is subjected to a hash operation according to a preset hash algorithm, and an operation result is a fixed-length string, which can be determined as the code of the current GUI.

[0089] In one example, the information of the test control can include a plurality of attribute information of the test control, such as control ID, type of the control, name, position (coordinates), size, color, etc.

[0090] Specifically, the historical to-be-tested GUI in the historical state set carries a corresponding code, and the acquisition process of the code is consistent with the determination process of the code of the current GUI. The code of the current GUI determined and the code of each historical to-be-tested GUI in the historical state set are matched to determine whether there is a historical to-be-tested GUI with the same code.

[0091] If the matching fails, the current GUI is determined as a to-be-tested GUI. If the matching succeeds, it is determined that the current GUI carries a completion flag, and other flags of the first to-be-tested component are obtained as uncompleted GUIs, and a similar matching process is performed until a to-be-tested GUI is determined.

[0092] The state of the GUI is marked, which can provide a reference when the to-be-tested GUI is determined, so that it is not necessary to spend time to traverse the GUI that has been completed again, thereby leaving valuable test time for the uncompleted GUI, and further improving the coverage of the test process.

[0093] In a possible implementation, a target GUI in the historical to-be-tested GUI carrying a completion flag is subjected to state resetting, and the state resetting condition can include that no new GUI is obtained within a preset time of the test process. The target GUI can be a historical to-be-tested GUI with a jump number less than a certain threshold.

[0094] In the test process, the jump number of each GUI is also counted.

[0095] The existing multi-device parallel GUI traversal strategy is centered on a central control node, and the central control node distributes the traversal strategy to each device. Therefore, once the central control node has a problem, the device cannot independently determine the traversal strategy, thereby delaying the test progress.

[0096] The embodiment of the application further provides a possible implementation, which still uses multiple devices to form a system for testing, but removes the controller node. In addition, a server is additionally added to share information through the server. The test method of the graphical user interface shown in the embodiment of the application can be applied to any one of the multiple devices.

[0097] In a possible implementation, in a current round of the test process, the first to-be-tested component is obtained, including:

[0098] In response to the start message sent by the server to the multiple devices at the same time, the first round is started; at least one common component obtained when the test process is initialized is obtained; each common component in the at least one common component is sequentially determined as the first to-be-tested component and is tested.

[0099] Specifically, at least one common component carried in the start message is obtained, and each common component in the at least one common component is sequentially determined as the first to-be-tested component and is tested. The process of testing the first to-be-tested component can refer to the above embodiment, which is not limited in the application. The common component is a component that needs to be tested by each device.

[0100] In the embodiment of the application, the process in which the server simultaneously feeds back the at least one common component to the multiple devices can be understood as the process in which the server simultaneously sends the start message to the multiple devices.

[0101] In an example, the test file package can be a file package with an.apk suffix, and the common component can include a component corresponding to a boot advertisement page, a component corresponding to a login page, a component corresponding to a registration page, and the like. It should be pointed out that the common component can be understood as components corresponding to the first few pages appearing when the to-be-tested application is started.

[0102] In one example, the server can be a single server such as Redis, MySQL, kafka, etc. Through the server, the obtained to-be-tested GUIs can be aggregated to obtain a real-time historical state set; and the obtained new components can be aggregated to obtain a real-time historical component set. The device can obtain the real-time historical state set and the historical component set from the server within a preset time; or the device can obtain the latest historical state set and the historical component set after obtaining the new GUI and / or the new component. After obtaining the real-time historical state set and the historical component set, the corresponding operations can be performed with reference to the above embodiments.

[0103] In one possible implementation, after increasing the weight value of the triggering mode by the preset fourth value, the method further includes: sending the second to-be-tested component to the server, so that the server adds the second to-be-tested component to the historical component set.

[0104] Specifically, after obtaining the second to-be-tested component, the second to-be-tested component is added to the historical component set, and a path between the first to-be-tested component and the second to-be-tested component is established.

[0105] In one possible implementation, after ending the test on the at least one common component, the method further includes:

[0106] determining at least one new to-be-tested component; sending the at least one new to-be-tested component to the server, and receiving a latest historical component set fed back by the server according to the at least one new to-be-tested component; and determining the first to-be-tested component according to the latest historical component set.

[0107] Specifically, during the test on the common component, a plurality of new GUIs can be obtained. At least one of the new GUIs corresponds to a new component, and the new component can be determined as a to-be-tested component. After the test on the common component is completed, at least one to-be-tested component can be obtained, and the device can feed back the at least one to-be-tested component to the server. The server can add the fed back to-be-tested component to the historical to-be-tested component set for backup; then, the server feeds back the latest historical component set to the device, and the device receives the historical component set and determines the first to-be-tested component according to the information of each historical to-be-tested component in the historical component set.

[0108] In one example, the information of the historical to-be-tested component can include: a number of the device that discovers the historical to-be-tested component, a number of the device that tests the historical to-be-tested component, a test time, a flag indicating whether to start the test, a flag indicating whether to end the test, etc.

[0109] The latest information is shared through the server, so that other devices can avoid testing the same component or the same GUI as the current device at the same time, thereby saving testing time, obtaining more traversal scenes in limited testing time, and improving the coverage of traversal.

[0110] To more clearly illustrate the difference between the method shown in the embodiments of the present application and the prior art, the embodiments of the present application also provide experiments 1 and 2 to reflect the improvement degree of the method shown in the embodiments of the present application relative to the prior art from the practical point of view. In experiments 1 and 2, the test time is 5 hours, and the number of historical components to be tested at each time from 1 hour to 5 hours is compared.

[0111] The comparison object of experiment 1 is the method shown in the embodiments of the present application (single device) and the traversal method of the traditional reinforcement learning strategy (single device test). The test results of the foregoing two methods can be seen in FIG. 1. Figure 2b As shown in line segment 1 and line segment 2, the components explored by the method shown in the embodiments of the present application (single device) at each time are relatively more, that is, more scenes are covered.

[0112] The comparison object of experiment 2 is the method shown in the embodiments of the present application (multi-device cooperative test), the method shown in the embodiments of the present application (single device test), and the traversal method of the traditional reinforcement learning strategy (single device test). The test results of the foregoing three methods can be seen in FIG. 2. Figure 2c As shown in line segment 4, line segment 5, and line segment 6 in FIG. 2, the components explored by the method shown in the embodiments of the present application (multi-device cooperative test) at each time are relatively more, that is, more scenes are covered.

[0113] Referring to FIG. 3, Figure 3a The embodiments of the present application provide a test device 300 of a graphical user interface, which corresponds to a test process including multiple rounds, and the number of steps of each round is sequentially increased. The device 300 can include:

[0114] The acquisition module 310 is configured to acquire a first component to be tested in a current round of the test process. The determination module 320 is configured to determine a GUI to be tested in the first component to be tested, wherein the GUI to be tested carries an unfinished flag and corresponds to a structure tree including multiple test controls. The triggering module 330 is configured to traverse each test control in the structure tree in the following manner until a termination condition is met: triggering the test control by a selected triggering manner, and performing a reinforcement operation on the selected triggering manner according to feedback obtained by triggering.

[0115] The termination condition includes at least one of the following: traversing the structure tree, ending the current round, and ending the test process.

[0116] In a possible implementation, each trigger mode includes a weight value, and the triggering module 330 is specifically configured to:

[0117] select a trigger mode meeting a condition from the plurality of preset trigger modes, where the weight value of the trigger mode meeting the condition is greater than a preset threshold value; and perform the following operations on each trigger mode meeting the condition: triggering the test control by the trigger mode, and obtaining a feedback; and performing a reinforcement operation on the trigger mode according to the feedback.

[0118] In a possible implementation, the triggering module 330 is specifically configured to, in the reinforcement operation on the trigger mode according to the feedback:

[0119] if the feedback is to keep the GUI under test, setting the weight value of the trigger mode to a preset first value, where the first value is less than or equal to the preset threshold value; if the feedback is to obtain a new GUI under test, increasing the weight value of the trigger mode; or if the feedback is to detect a state cycle, decreasing the weight value of the trigger mode.

[0120] In a possible implementation, the test process includes a historical component set for storing historical components under test, and the triggering module 330 is specifically configured to, in the operation of increasing the weight value of the trigger mode if the feedback is to obtain a new GUI under test:

[0121] determining a second component under test corresponding to the new GUI under test; if the second component under test is the same as the first component under test, increasing the weight value of the trigger mode according to a preset second value; if the second component under test is different from the first component under test and is a historical component under test, increasing the weight value of the trigger mode according to a preset third value; or if the second component under test is different from the first component under test and is not a historical component under test, increasing the weight value of the trigger mode according to a preset fourth value; where the second value is less than the third value, and the third value is less than the fourth value.

[0122] In a possible implementation, if the current round has ended and the test process has not ended, the obtaining module 310 can be further configured to:

[0123] performing a test in a next round based on the second component under test.

[0124] In a possible implementation, after the structure tree is traversed, the determining module 320 is configured to:

[0125] If the GUI under test corresponds to a leaf node, the GUI under test is marked as complete. A leaf node corresponds to a GUI without a jumpable GUI. A jumpable GUI is a GUI determined by the triggering method of the test control on the structure tree. If the GUI under test corresponds to a non-leaf node, and all jumpable GUIs of the GUI under test are marked as complete, the GUI under test is marked as complete.

[0126] In one possible implementation, the device 300 is applied to any device in a system comprising multiple devices, and the acquisition module 310, in the current round of the test process, acquires information from the first component under test, specifically for the following purposes:

[0127] In response to the server sending startup messages to multiple devices simultaneously, the first round is initiated; at least one common component obtained during the initialization test process is acquired; each of the at least one common component is sequentially identified as the first component to be tested and tested.

[0128] See Figure 3b This application embodiment also provides a possible implementation, in which the device 300 further includes a transceiver module 340, which, after completing the test for at least one common component, is specifically used for:

[0129] Identify at least one new component to be tested; send at least one new component to be tested to the server and receive the latest historical component set from the server based on the at least one new component to be tested; determine the first component to be tested based on the latest historical component set.

[0130] This application provides an electronic device (e.g., a computer device / equipment / system) including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement a method for a graphical user interface.

[0131] In one alternative embodiment, an electronic device is provided, such as Figure 4 As shown, Figure 4 The illustrated electronic device 4000 includes a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, for example, via a bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004, which can be used for data interaction between the electronic device and other electronic devices, such as sending and / or receiving data. It should be noted that in practical applications, the transceiver 4004 is not limited to one type, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of this application.

[0132] The processor 4001 can be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic device, transistor logic device, hardware component, or any combination thereof. It can implement or execute various exemplary logical blocks, modules and circuits described in connection with the disclosure. The processor 4001 can also be a combination of computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0133] The bus 4002 can include a path for transmitting information between the above-mentioned components. The bus 4002 can be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus 4002 can be divided into an address bus, a data bus, a control bus, etc. For convenience of representation, Figure 4 Only one thick line is used in the figure, but it does not mean that there is only one bus or only one type of bus.

[0134] The memory 4003 can be a ROM (Read Only Memory) or other type of static storage device that can store static information and instructions, a RAM (Random Access Memory) or other type of dynamic storage device that can store information and instructions, an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, an optical disk storage (including a compact disk, a laser disk, an optical disk, a digital versatile disk, a Blu-ray disk, etc.), a magnetic disk storage medium, other magnetic storage device, or any other medium capable of carrying or storing computer programs and capable of being read by a computer, without limitation.

[0135] The memory 4003 is configured to store a computer program for implementing the embodiments of the present application, and the processor 4001 is configured to control the execution of the computer program stored in the memory 4003. The processor 4001 is configured to execute the computer program stored in the memory 4003 to implement the steps shown in the foregoing method embodiments.

[0136] The electronic device includes, but is not limited to, a mobile terminal.

[0137] The computer readable storage medium of the embodiments of the present application stores a computer program, and the computer program is executed by the processor to implement the steps and corresponding contents of the foregoing method embodiments.

[0138] The terms "first", "second", "third", "fourth", "1", "2", and the like (if any) in the specification and claims of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that shown or described.

[0139] It should be understood that, although the flowcharts of the embodiments of the present application indicate the respective operation steps by arrows, the implementation order of the steps is not limited to the order indicated by the arrows. Unless otherwise specified herein, in some implementation scenarios of the embodiments of the present application, the implementation steps in each flowchart can be executed in other orders as required. In addition, part or all of the steps in each flowchart can include multiple sub-steps or multiple stages based on the actual implementation scenario. Part or all of these sub-steps or stages can be executed at the same time, and each of these sub-steps or stages can also be executed at different times. In the scenario where the execution times are different, the execution order of these sub-steps or stages can be flexibly configured according to requirements, and the embodiments of the present application do not limit this.

[0140] The above is only an optional implementation of some implementation scenarios of the present application, and it should be pointed out that, for those skilled in the art, other similar implementation means based on the technical concept of the present application can also be used without departing from the technical concept of the present application, and such implementation also falls within the protection scope of the embodiments of the present application.

Claims

1. A method of testing a graphical user interface, characterized by, The method corresponds to a test process, and the test process includes multiple rounds, and the number of steps in each round is sequentially increased. The method includes: In the current round of the test process, a first to-be-tested component is obtained; A to-be-tested GUI in the first to-be-tested component is determined, wherein the to-be-tested GUI carries an unfinished flag and corresponds to a structure tree including multiple test controls; each GUI included in the first to-be-tested component carries a flag, and the flag includes an indication of whether the test of the GUI is completed or not completed; if the to-be-tested GUI corresponds to a non-leaf node and the flags of all next-level GUIs of the to-be-tested GUI are completed, it is determined that the flag of the to-be-tested GUI is completed; Each test control in the structure tree is traversed: the test control is triggered through a screened triggering manner, and a reinforcement operation is performed on the screened triggering manner according to feedback obtained by triggering. The reinforcement operation includes: based on the feedback obtained by the to-be-tested GUI, adjusting a weight value of the corresponding triggering manner, and the feedback obtained by the to-be-tested GUI includes at least one of keeping the to-be-tested GUI, a new to-be-tested GUI, or detecting a state cycle.

2. The method of claim 1, wherein, The test control is triggered through the screened triggering manner, and the reinforcement operation is performed on the screened triggering manner according to feedback obtained by triggering, including: Screening a triggering manner that meets a condition from a plurality of preset triggering manners, wherein the weight value of the triggering manner that meets the condition is greater than a preset threshold value; For each triggering manner that meets the condition, the following operations are performed: Triggering the test control in the triggering manner and obtaining feedback; Performing a reinforcement operation on the triggering manner according to the feedback.

3. The method of claim 1, wherein, The reinforcement operation on the triggering manner according to the feedback includes: If the feedback is to keep the to-be-tested GUI, the weight value of the triggering manner is set to a preset first value, wherein the first value is less than or equal to a preset threshold value; If the feedback is to obtain a new to-be-tested GUI, the weight value of the triggering manner is increased; If the feedback is to detect a state cycle, the weight value of the triggering manner is decreased.

4. The method of claim 3, wherein, The test process includes a historical component set for storing historical to-be-tested components, and the weight value of the triggering manner is increased if the feedback is to obtain a new to-be-tested GUI, including: Determining a second to-be-tested component corresponding to the new to-be-tested GUI; If the second to-be-tested component is the same as the first to-be-tested component, the weight value of the triggering manner is increased by a preset second value; If the second to-be-tested component is different from the first to-be-tested component and is the historical to-be-tested component, the weight value of the triggering manner is increased by a preset third value; If the second to-be-tested component is different from the first to-be-tested component and is not the historical to-be-tested component, the weight value of the triggering manner is increased by a preset fourth value; The second value is less than the third value, and the third value is less than the fourth value.

5. The method of claim 4, wherein, If the current round has ended and the test process has not ended, the method further includes: Based on the second to-be-tested component, testing in a next round is performed.

6. The method of claim 1, wherein, After the structure tree is traversed, the method further includes: If the to-be-tested GUI corresponds to a leaf node, determining that a flag of the to-be-tested GUI is complete, wherein the leaf node corresponds to a GUI without a jumpable GUI, and the jumpable GUI is a GUI determined according to a trigger mode corresponding to a test control on the structure tree; If the to-be-tested GUI corresponds to a non-leaf node, and flags of all jumpable GUIs of the to-be-tested GUI are complete, determining that the flag of the to-be-tested GUI is complete.

7. The method of claim 1, wherein, The method for determining the to-be-tested GUI in the first to-be-tested component comprises: performing a hash operation on a structure tree corresponding to a current GUI of the first to-be-tested component according to a preset hash algorithm, and determining an operation result obtained by the hash operation as an encoding of the current GUI, wherein the flag of the current GUI is incomplete; matching the encoding of the current GUI in a historical state set to determine whether there is a historical to-be-tested GUI with the same encoding; if the matching fails, determining the current GUI as the to-be-tested GUI.

8. The method of claim 1, wherein, The method is applied to any device in a system comprising a plurality of devices, and the first to-be-tested component is obtained in a current round of a test process, comprising: starting a first round in response to a start message sent by a server to the plurality of devices simultaneously; obtaining at least one common component obtained when the test process is initialized; determining each common component in the at least one common component as the first to-be-tested component in turn and performing a test.

9. The method of claim 8, wherein, After ending the test on the at least one common component, the method further comprises: determining at least one new to-be-tested component; sending the at least one new to-be-tested component to the server, and receiving a latest historical component set fed back by the server according to the at least one new to-be-tested component; determining the first to-be-tested component according to the latest historical component set.

10. The method of claim 1, wherein, In a case where an ending condition is met, ending the traversal of the test controls in the structure tree; The ending condition comprises at least one of the following: traversing the structure tree completely; ending the current round; ending the test process.

11. A test apparatus for a graphical user interface, characterized by The device corresponds to a test process, and the test process comprises a plurality of rounds, and a step number of each round is increased in turn. The device comprises: an obtaining module, configured to obtain a first to-be-tested component in a current round of a test process; a determining module, configured to determine a to-be-tested GUI in the first to-be-tested component, wherein the to-be-tested GUI carries an incomplete flag and corresponds to a structure tree comprising a plurality of test controls; each GUI included in the first to-be-tested component carries a flag, and the flag comprises a flag for indicating that a test of the GUI is complete or incomplete; if the to-be-tested GUI corresponds to a non-leaf node, and flags of all next-level GUIs of the to-be-tested GUI are complete, determining that the flag of the to-be-tested GUI is complete; a triggering module, configured to traverse each test control in the structure tree in the following manner until an ending condition is met: triggering the test control by a screened trigger mode, and performing a reinforcement operation on the screened trigger mode according to feedback obtained by the triggering; The reinforcement operation comprises: adjusting a weight value of a corresponding triggering mode based on a feedback obtained GUI, the feedback obtained GUI comprising at least one of a maintained test GUI, a new test GUI, or a detected state cycle.

12. An electronic device comprising a memory, a processor, and a computer program stored on the memory, wherein the computer program, when executed by the processor, is arranged to perform the method of any one of claims 1 to 11. The processor executes the computer program to implement the steps of the method of any one of claims 1-10.

13. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program, when executed by the processor, implements the steps of the method of any one of claims 1-10.

Citation Information

Patent Citations

  • Method, device and system for testing terminal application interface

    CN104572430A

  • Application interface control traversal test method and application interface control traversal test devices

    CN108628732A