A kind of application control testing method and related equipment

By inserting control instrumentation tags into the application code and adjusting trigger weights, the problem of insufficient control testing that may be caused by Monkey testing software is solved and the reliability of control testing is improved.

CN111538652BActive Publication Date: 2024-09-10CHINA PING AN LIFE INSURANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010241600.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-03-30
Publication Date
2024-09-10
Estimated Expiration
2040-03-30

AI Technical Summary

Technical Problem

When the existing Monkey testing software tests APP controls, the controls may not be tested or the number of tests may be too few, resulting in unreliable test results.

Method used

By inserting control instrumentation tags into the application code, count the number of test events triggered by the control, calculate the trigger coverage, and adjust the initial trigger weight of the control based on the coverage to ensure that test events are triggered more evenly in subsequent time periods, improving Reliability of controls testing.

Benefits of technology

It improves the reliability of application control testing, ensures that controls are fully tested within a preset time period, and reduces unreliability of test results due to insufficient coverage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111538652B
    Figure CN111538652B
Patent Text Reader

Abstract

The embodiment of the present invention is applicable to an automated testing tool, and discloses an application control testing method and related equipment, the method comprising: obtaining the tag count of each control plug-in tag in the application code of the first application; determining the trigger coverage of each application control according to the tag count; adjusting the initial trigger weight of the first application control whose trigger coverage is less than the first preset threshold, so that the adjusted trigger weight of the first application control is increased; within a second preset time period, periodically and randomly determining the target test control according to the adjusted trigger weight of each application control, and triggering a test event for the target test control; obtaining the test log generated for the application control in the first application within the second preset time period, and determining the control test result of the first application according to the test log. The reliability of testing the application control can be improved by the present invention.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of automated testing technology, and in particular to an application control testing method and related equipment. Background Art

[0002] With the development of Internet technology, more and more applications (APPs) are used as carriers of mobile application functions to provide users with certain business services. Before an APP is released to users, it usually needs to go through the development and testing stages before it can be released for users to download and use. Among them, APPs usually contain a variety of controls such as text input boxes, buttons, drop-down menus, etc. During the testing stage of the APP, the functions of the controls need to be tested. At present, the common practice in the industry is to use Monkey testing software to generate pulse information that simulates the user's touch screen, buttons, sliding tracking balls, etc., and then simulate the above operations performed by the user on the controls to verify the performance of the controls. When the Monkey testing software simulates the operation of the controls in the APP, the selection of controls is random. There may be problems that the controls are not covered by the test software or the number of tests is too small, which leads to unreliable test results of the control test. Summary of the invention

[0003] The present application provides an application control testing method and related equipment, and the reliability of testing the application control can be improved through the present invention.

[0004] A first aspect of an embodiment of the present invention provides an application control testing method, including:

[0005] Obtaining a tag count of each control stub tag in the application code of the first application; the control stub tag is a tag pre-inserted in the application code and used to count the number of times a test event is triggered for each application control in the first application within a first preset time period;

[0006] Determining the trigger coverage of each application control according to the tag count of each control instrumentation tag, respectively, wherein the trigger coverage is the ratio of the number of times the test event is triggered for each application control to the total number of times the test event is triggered for each application control within the first preset time period;

[0007] Determine, from among the application controls of the first application, a first application control whose trigger coverage is less than a first preset threshold, and adjust an initial trigger weight of the first application control so that the adjusted trigger weight of the first application control is increased; the initial trigger weight of the first application control is a reference weight for triggering a test event for the first application control within the first preset time period;

[0008] Within a second preset time period, according to the adjusted trigger weights of the various application controls, periodically and randomly determine a target test control from the various application controls, and trigger a test event for the target test control;

[0009] A test log generated for an application control in the first application within the second preset time period is obtained, and a control test result of the first application is determined according to the test log.

[0010] In combination with the first aspect, in a first possible implementation manner, the first application includes at least one application interface; the application controls are distributed in the at least one application interface;

[0011] Before periodically and randomly determining a target test control from each application control according to the adjusted trigger weights of each application control within the second preset time period, the method further includes:

[0012] Obtaining the total number of control triggering times set for the second preset time period;

[0013] According to the number of application controls distributed in each application interface, a control triggering number is allocated to each application interface; the control triggering number allocated to each application interface is proportional to the number of application controls contained in each application interface, and the sum of the control triggering number allocated to each application interface is equal to the total control triggering number; the control triggering number is used to indicate the number of times the target test control is periodically determined from each application interface within a second preset time period.

[0014] In combination with the first possible implementation manner of the first aspect, in a second possible implementation manner, within the second preset time period, according to the adjusted trigger weights of the respective application controls, periodically randomly determining the target test control from the respective application controls includes:

[0015] According to the initial trigger weight of each application control in the application interface, each value in the preset random value set is assigned to each application control in the application interface, and the number of values ​​assigned to the application control in the application interface is proportional to its own trigger weight;

[0016] A first random number belonging to the preset random value set is periodically randomly generated, and an application control assigned to the first random number is determined as the target test control.

[0017] In combination with the first aspect, in a third possible implementation manner, adjusting the initial trigger weight of the first application control includes:

[0018] Determine, from among the application controls of the first application, a second application control whose trigger coverage is greater than a second preset threshold;

[0019] Determine a weight adjustment ratio of the first application control and the second application control; the weight adjustment ratio of the first application control and the second application control satisfies the following formula:

[0020]

[0021] Among them, p i is the trigger coverage of the first application control, w i is the initial trigger weight of the first application control, x i is the weight adjustment ratio of the first application control, i is the index of the first application control, m is the number of the first application controls, and i and m are positive integers; q j is the trigger coverage of the second application control, S j is the initial trigger weight of the second application control, y j is the weight adjustment ratio of the second application control, j is the index of the second application control, n is the number of the second application controls, and j and n are positive integers; k is the initial trigger weight of the third application control, the third application control is an application control in the first application whose trigger coverage is between the first preset threshold and the second preset threshold, k is the index of the third application control, l is the number of the third application controls, and k and l are non-negative integers;

[0022] According to the weight adjustment ratio of the first application control, the trigger weight of the first application control is adjusted, and according to the weight adjustment ratio of the second application control, the trigger weight of the second application control is adjusted.

[0023] In combination with the first aspect, in a fourth possible implementation manner, triggering a test event on the target test control includes:

[0024] Acquire the type attribute information of the target test control, and generate a test event for the target test control according to the type attribute information of the target test control;

[0025] The generated test event is triggered for the target test control.

[0026] In combination with the first aspect, in a fifth possible implementation manner, triggering a test event on the target test control includes:

[0027] Acquire the coordinate information of the target test control, and determine the test area of ​​the target test control according to the coordinate information of the target test control;

[0028] The test event is triggered for the target test control in the test area of ​​the target test control.

[0029] In combination with the first aspect, in a sixth possible implementation manner, each of the application controls has a corresponding trigger condition code in the application code of the first application;

[0030] The method further comprises:

[0031] After the trigger condition code corresponding to the application control, insert the stub code for the application control; the stub code includes the control stub tag of the application control, the stub code runs after the trigger condition code corresponding to the application control is triggered, and the tag count of the control stub tag of the application control is increased by one each time the stub code runs.

[0032] A second aspect of an embodiment of the present application provides an application control testing device, including:

[0033] A tag acquisition module, used to obtain a tag count of each control plug-in tag in the application code of the first application; the control plug-in tag is a tag pre-inserted in the application code and used to count the number of times a test event is triggered for each application control in the first application within a first preset time period;

[0034] A coverage determination module, configured to determine the trigger coverage of each of the application controls according to the tag counts of the instrumentation tags of each of the controls, wherein the trigger coverage is a ratio of the number of times the test events are triggered on each of the application controls to the total number of times the test events are triggered on each of the application controls within the first preset time period;

[0035] a weight adjustment module, configured to determine, from among the application controls of the first application, a first application control whose trigger coverage is less than a first preset threshold, and adjust an initial trigger weight of the first application control so that the adjusted trigger weight of the first application control is increased; the initial trigger weight of the first application control is a reference weight for triggering a test event for the first application control within the first preset time period;

[0036] A test module, configured to periodically and randomly determine a target test control from among the application controls according to the adjusted trigger weights of the application controls within a second preset time period, and trigger a test event for the target test control;

[0037] The result generation module is used to obtain a test log generated for the application control in the first application within the second preset time period, and determine a control test result of the first application according to the test log.

[0038] A third aspect of an embodiment of the present invention provides an application control testing device, including: a processor and a memory;

[0039] The processor is connected to a memory, wherein the memory is used to store program codes, and the processor is used to call the program codes to execute the method in any one of the above aspects of the embodiments of the present invention.

[0040] A fourth aspect of an embodiment of the present invention provides a computer storage medium, wherein the computer storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the method in any of the above aspects.

[0041] In an embodiment of the present invention, a tag count of each control plug-in tag in the application code of the first application is obtained, and the control plug-in tag is a tag pre-inserted in the application code and used to count the number of times each application control in the first application is triggered by a test event within a first preset time period. According to the tag count of each control plug-in tag, the trigger coverage of each application control is determined respectively, and then for the first application control whose trigger coverage is less than the first preset threshold, its initial trigger weight is adjusted, so that the adjusted trigger weight of the first application control is increased. Then, within the second preset time period, according to the adjusted trigger weight of each application control, the target test control is periodically randomly determined from each application control, so as to trigger a test event for the target test control, and the test log generated for the application control in the first application within the second preset time period is obtained, and the control test result of the first application is determined according to the test log. By adjusting the trigger weight of the first application control with a low trigger coverage, the test event is triggered according to the adjusted trigger weight within the second preset time period, so that the proportion of the trigger test event for the first application control within the second preset time period is increased, and the reliability of the application control test of the first application is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0043] Figure 1 It is a flowchart of an application control testing method provided in an embodiment of the present application;

[0044] Figure 2 A schematic diagram of an application interface provided in an embodiment of the present application;

[0045] Figure 3It is a flowchart of another application control testing method provided in an embodiment of the present application;

[0046] Figure 4 It is a structural diagram of an application control testing device provided in an embodiment of the present application;

[0047] Figure 5 It is a structural diagram of another application control triggering device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0048] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0049] The application control testing method provided in the embodiment of the present application can be used on the Monkey automated testing platform, the Monkey runner automated testing platform or other automated testing platforms that simulate user-triggered controls. The application control testing method in the embodiment of the present application can be widely used in scenarios where control testing is performed on applications running on terminals, where the terminals include but are not limited to mobile phones, tablet computers, laptop computers, PDAs, mobile internet devices (MIDs), etc., and are not limited here.

[0050] Combine the following Figure 1 to Figure 3 Introduce the application control testing method provided by the embodiment of the present application, see Figure 1 , Figure 1 : is a flowchart of an application control testing method provided by an embodiment of the present application. As shown in the figure, the method may include the following steps:

[0051] S101, obtaining a tag count of each control stub tag in an application code of a first application.

[0052] Before step S101, the application code of the first application is instrumented, and a control instrumentation tag for counting the number of times each application control in the first application is triggered by a test event is inserted into the application code of the first application. Different application controls in the first application correspond to different control instrumentation tags.

[0053] Here, the application code of the first application is parsed to obtain the trigger condition code of the application control, and the part after the trigger condition code is used as the insertion point of the application control. Specifically, each application control has a corresponding trigger condition code and a control event code in the application code of the first application. The insertion code for the application control can be inserted after the trigger condition code corresponding to the application control. The insertion code includes the control insertion tag of the application control. The insertion code runs after the trigger condition code corresponding to the application control is triggered. Each time it runs, the tag count of the control insertion tag of the application control is increased by one. Here, inserting the insertion code for the application control after the trigger condition code corresponding to the application control is not limited to the order of the code appearance, but can also be the logical order of code running.

[0054] For example, the application code of the first application may contain a trigger condition code for detecting a click operation and a control event code that is executed after the click operation occurs. A control stub tag for the button control may be inserted after the trigger condition code of the button control to count the number of times the control button is clicked. For example, if the application code of the first application contains the following code that defines a button control and related information about the button control event operation:

[0055] Function buttonClick(){

[0056] alert("Button clicked");

[0057] }

[0058] ID="button" type="button" value="click" onclick="buttonClick();

[0059] end

[0060] In the above code, a button control with ID "button", type "button class", and display content "click" is defined. The button control uses the onclick function to detect whether there is a click event for the button of the control, that is, onclick is the trigger condition code of the button control. After detecting the click event, the buttonClick function is called to pop up the "button clicked" dialog box, that is, buttonClick is the control event code after the trigger condition. The following inserts the stub code for counting the number of times the button of the control is clicked after the trigger condition code of the button control. The stub code contains the code for accumulating the control stub label i corresponding to the button control. The code after stub is as follows:

[0061] i=0;

[0062] Function buttonClick(i){

[0063] ++i;

[0064] alert("Button clicked");

[0065] return i

[0066] }

[0067] ID="button" type="button" value="click" onclick="buttonClick();

[0068] end

[0069] By inserting the variable i in the buttonClick function, the buttonClick function is called each time the button control is clicked, and i is accumulated once through the buttonClick function.

[0070] The above process can be implemented by various instrumentation tools. For example, for the Android system, it can be implemented by the AndroidHook instrumentation tool and the ASM bytecode instrumentation tool, and for the IOS system, it can be implemented by the Method Swizzling instrumentation tool.

[0071] Furthermore, in the first preset time period before step S101, according to the initial trigger weights of the various application controls of the first application, the application controls to be tested are periodically randomly selected from the various application controls, and then a test event is triggered to the application controls to be tested. The specific implementation method of randomly selecting the application controls to be tested according to the initial trigger weights of the various application controls in the first preset time period will be described later.

[0072] After the first preset time period ends, the tag counts corresponding to each application control within the first preset time period can be recorded according to the preset tag count recording method. For example, the preset tag count recording method can be to record the tag counts corresponding to each application control in a preset storage location in the database. For another example, the preset tag count recording method can be to write the tag counts corresponding to each application control into the test log generated for the application control in the first application within the first preset time period. Then, in step S101, the tag counts of each control plug-in tag can be obtained according to the corresponding tag count recording method.

[0073] S102: Determine the trigger coverage of each of the application controls according to the tag count of each of the control insertion tags.

[0074] Here, the trigger coverage of the application control within a period of time is determined by dividing the number of times the test event is triggered on each application control within the period by the total number of times the test event is triggered on each application control within the period, and the quotient obtained is the trigger coverage of the application control within the period. The trigger coverage determined in step S102 is the trigger coverage of each application control within the first preset time period, that is, the ratio of the number of times the test event is triggered on each application control within the first preset time period to the total number of times the test event is triggered on each application control within the first preset time period.

[0075] S103: Determine, from among the application controls of the first application, a first application control whose trigger coverage is less than a first preset threshold, and adjust an initial trigger weight of the first application control so that the adjusted trigger weight of the first application control is increased.

[0076] Before the first preset time period, an initial trigger weight is first preset for each application control of the first application, and the initial trigger weight is a reference weight for triggering a test event for each application control within the first preset time period. The initial trigger weight for each application control can be an equal weight value or a randomly assigned weight value.

[0077] Normally, application controls with higher initial trigger weights will have a relatively higher number of test events triggered within the first preset time period, and vice versa. However, when a test event is actually triggered on an application control within the first preset time period, the application control to be tested is randomly selected based on the trigger weight, which involves certain random factors. Therefore, there may also be a random situation where an application control with a high trigger weight has a relatively low number of test events triggered. In the test scenarios for each application control of the first application, we do not consider whether the absolute ideal state of averaging the number of test events triggered on each application control is achieved. However, we hope that by adjusting the trigger weight, application controls that have too few test events triggered within the first preset time period can be triggered with a higher probability in the subsequent second preset time period, so as to reduce the situation where the application control is triggered less frequently, which results in the inability to test the stress resistance of the application control well.

[0078] Therefore, here we can first select the first application control whose trigger coverage rate in the first preset time period is less than the first preset threshold, and the first preset threshold can be a threshold value less than or equal to the average trigger coverage rate. Then adjust the initial trigger weight of the first application control so that the trigger weight of the adjusted first application is increased. For example, there are four application controls in the first application, and the corresponding initial trigger weights are 2, 4, 4 and 7 respectively. The trigger coverage rates in the first preset time period are 10%, 25%, 21% and 44% respectively, and the first preset threshold is 20%, then the trigger weight of the application control with an initial trigger weight of 2 is increased. In one implementation method, a certain adjustment rate can be pre-set, for example, the trigger weight of the first application control is increased by a corresponding percentage according to the adjustment rate. In another implementation method, the application control with the highest trigger coverage rate in the first preset time period can be determined, and the initial trigger weight of the first application control and the average value of the initial trigger weight of the application control with the highest trigger coverage rate in the first preset time period are determined as the adjusted trigger weight of the first application control.

[0079] Optionally, the first application may include at least one application interface, and the application controls of the first application are distributed in the at least one application function interface. For an application interface, there may be a corresponding entry application control for entering the application interface in other application interfaces, and the application interface may also have an exit application control for transferring from the application interface to other application interfaces. Here, the average trigger coverage of the application controls in each application interface of the first application can be counted. If the average trigger coverage of a certain application interface is less than the preset first average coverage threshold, it means that the frequency of jumping to the application interface is relatively low, so the frequency of application controls in the application interface being triggered is relatively low. Therefore, in one implementation, the trigger weight of the entry application control corresponding to the application interface can be increased to increase the probability of jumping to the application interface, thereby staying in the application interface to trigger a test event and improve the trigger coverage of the application controls in the application interface. In another implementation, the trigger weight of the exit application control corresponding to the application interface can be reduced to reduce the probability of jumping out of the application interface, thereby staying in the application interface to trigger a test event and improve the trigger coverage of the application controls in the application interface. In yet another implementation, the incoming application control corresponding to the application interface may be raised, while the outgoing application control corresponding to the application interface may be lowered.

[0080] For example, see Figure 2 , Figure 2 A schematic diagram of an application interface provided in an embodiment of the present application is shown in the figure. Figure 2Four application interfaces are shown, including interface 1, interface 2, interface 3 and interface 4, wherein interface 4 is the main interface corresponding to the first application, that is, interface 1 is displayed after the first application is started, and interface 1 contains controls 1, control 2, control 3 and other controls. The function of control 1 is to open interface 2 when a click event is received; the function of control 2 is to open interface 3 when a click event is received; the function of control 3 is to open interface 4 when a click event is received. Interface 2 contains control 4, and the function of control 4 is to return to interface 1 when a click event is received; interface 3 contains control 5, and the function of control 5 is to return to interface 1 when a click event is received; interface 4 contains control 6, and the function of control 6 is to return to interface 1 when a click event is received.

[0081] Taking interface 2 as an example, control 1 is the entry application control corresponding to interface 2, and control 4 is the exit application control corresponding to interface 2. If the average coverage rate of the application controls in interface 2 in the first preset time period is lower than the first average coverage rate threshold, then the trigger weight corresponding to control 1 can be increased, and / or the trigger weight corresponding to control 4 can be reduced. Similarly, if the average coverage rate of the application controls in interface 3 in the first preset time period is lower than the first average coverage rate threshold, then the trigger weight corresponding to control 2 can be increased, and / or the trigger weight corresponding to control 5 can be reduced; if the average coverage rate of the application controls in interface 4 in the first preset time period is lower than the first average coverage rate threshold, then the trigger weight corresponding to control 3 can be increased, and / or the trigger weight corresponding to control 6 can be reduced.

[0082] S104, within a second preset time period, periodically and randomly determine a target test control from the various application controls according to the adjusted trigger weights of the various application controls, and trigger a test event for the target test control.

[0083] Here, the trigger weights of each application control after adjustment refer to the trigger weights corresponding to each application control after the initial trigger weight of the first application control is adjusted in S103. During the second preset time period, the trigger weights of each application control after adjustment used by the target test control are randomly determined, including the adjusted trigger weight of the first application control, and the trigger weights of other application controls except the first application control. The trigger weights of other application controls except the first application control used can be adjusted or unadjusted, initial trigger weights. No limitation is made here.

[0084] The process of testing the application controls in the first application within the second preset time period may be a process of testing the application controls in each application interface of the first application respectively. Before testing the application controls in each application interface, a preset random value set may be set for each application interface according to the adjusted trigger weight of the application controls in each application interface, and each value in the preset random value set may be assigned to each application control in the application interface, and the number of values ​​assigned to the application controls in the application interface is proportional to its own trigger weight.

[0085] In an implementation method of determining a preset random value set and assigning values ​​in the preset random value set: if the adjusted trigger weights of each application control in the application interface are integers, the sum of the adjusted trigger weights of each application control in the application interface is determined as a first number, and any continuous first number of integer values ​​can be used as a preset random value set corresponding to the application interface. Then, according to the adjusted trigger weights of each application control, a corresponding number of values ​​in the preset random value set are assigned to it. For example, if the adjusted trigger weights of four application controls in a certain application interface are 5, 4, 4, and 7, respectively, and the first number is 20, integers from 1 to 20 can be used as a preset random value set corresponding to the application interface, or any other continuous 20 integers, such as integers from 2 to 21, can be used as a preset random value set corresponding to the application interface. If the integers from 1 to 20 are the preset random value sets corresponding to the application interface, integers from 1 to 5 can be assigned to interface controls with a trigger weight of 5 in the application interface, integers from 6 to 9 can be assigned to interface controls with a trigger weight of 4 in the application interface, integers from 10 to 13 can be assigned to interface controls with a trigger weight of 4 in the application interface, and integers from 14 to 20 can be assigned to interface controls with a trigger weight of 7 in the application interface.

[0086] If the adjusted trigger weights of each application control in the application interface have decimals, each trigger weight can be normalized to an integer, and the decimal trigger weights can be normalized to integer trigger weights, and then the preset random value set is determined in the above-mentioned integer manner, and each value in the preset random value set is assigned. Here is an example to illustrate. For example, if the adjusted trigger weights of three application controls in a certain application interface are 0.5, 3, and 1.5, respectively, and the corresponding integer trigger weights after integer normalization are 1, 6, and 3, respectively, integers from 1 to 10 can be combined as the preset random value corresponding to the application interface. Then, 1 is assigned to the application control with a trigger weight of 0.5 in the application interface, integers from 2 to 7 are assigned to the application control with a trigger weight of 3 in the application interface, and integers from 8 to 10 are assigned to the application control with a trigger weight of 1.5 in the application interface.

[0087] The above describes how to determine the preset random value set corresponding to the application interface and how to allocate the values ​​in the preset random value set when the adjusted trigger weight is an integer or a decimal. After the values ​​in the preset random value set are allocated, the first random number belonging to the preset random value set is periodically randomly generated. For example, the first random number can be generated by a random function, and then the application control allocated to the first random number is determined as the target test control. For example, assuming that the application controls with adjusted trigger weights of 0.5, 3, and 1.5 are allocated values ​​of 1, integers from 2 to 7, and integers from 8 to 10, respectively, if the first random number is 3, then the application control with a trigger weight of 3 is determined as the target test control.

[0088] In another implementation, a preset random value set of decimal type can also be determined for the application interface, and then the decimals in the preset random value set are allocated to the application controls of the application interface. The principle of allocation here is still that the number of values ​​allocated to the application controls in the application interface is proportional to their own trigger weights. Then, a first random number of decimals belonging to the preset random value set is generated, and the corresponding target test control is matched. The specific implementation will not be repeated here.

[0089] After the target test control is determined, a test event is triggered for the target test control. The test event triggered for the target test control may be a random type of test event.

[0090] Optionally, the type attribute information of the target test control can be obtained, and a test event for the target test control can be generated according to the type attribute information of the target test control, and then the generated test event can be triggered for the target test control. For example, if the type attribute information of the target test control is a button class, a click test event can be generated; if the type attribute information of the target test control is a text box class, a text input test event can be generated; if the type attribute of the target test control is a trackball class, a sliding test event can be generated, and so on.

[0091] Optionally, the coordinate information of the target test control can be obtained, and the test area of ​​the target test control can be determined based on the coordinate information of the target test control, and then a test event can be triggered for the target test control within the test area of ​​the target test control. For example, the format of the coordinate information of the target test control can be (the horizontal coordinate of the upper left pixel of the target test control, the vertical coordinate of the upper left pixel of the target test control, the width of the target test control, and the height of the target test control); the format of the coordinate information of the target test control can also be (the horizontal coordinate of the leftmost pixel of the target test control, the horizontal coordinate of the rightmost pixel of the target test control, the vertical coordinate of the highest pixel of the target test control, and the vertical coordinate of the lowest pixel of the target test control). Then, based on the coordinate information of the target test control, a test area corresponding to the coordinate information can be determined from the corresponding application interface, and a coordinate within the test area can be further randomly selected as the trigger pixel of the test event.

[0092] The above details the implementation method of periodically triggering test events for application controls in the first application according to the adjusted trigger weights of each application control within the second preset time period. The implementation method of periodically triggering test events for application controls in the first application according to the initial trigger weights of each application control within the first preset time period can refer to the above process and will not be described in detail.

[0093] S105: Obtain a test log generated for an application control in the first application within the second preset time period, and determine a control test result of the first application according to the test log.

[0094] Here, after the second preset time period ends, a test log generated for the application controls in the first application within the second preset time period will be generated. The test log may include the proportion of each application control in the first application that successfully responds to the test event. Then, based on the proportion of each application control that successfully responds to the test event and the preset response proportion threshold, the control test results for each application control of the first application can be determined.

[0095] In some optional implementations, the trigger coverage of each application control of the first application within the second preset time period can be further determined before step S105. If the trigger coverage of each application control within the second preset time period is higher than the first preset threshold, step S105 is executed. If there are application controls whose trigger coverage within the second preset time period is lower than the first preset threshold, the trigger weights of each application control can be adjusted and tested again with reference to the specific implementation of steps S101 to S103 until the trigger coverage of each application control is higher than the first preset threshold after the test.

[0096] In an embodiment of the present invention, a tag count of each control plug-in tag in the application code of the first application is obtained, and the control plug-in tag is a tag pre-inserted in the application code and used to count the number of times each application control in the first application is triggered by a test event within a first preset time period. According to the tag count of each control plug-in tag, the trigger coverage of each application control is determined respectively, and then for the first application control whose trigger coverage is less than the first preset threshold, its initial trigger weight is adjusted, so that the adjusted trigger weight of the first application control is increased. Then, within the second preset time period, according to the adjusted trigger weight of each application control, the target test control is periodically randomly determined from each application control, so as to trigger a test event for the target test control, and the test log generated for the application control in the first application within the second preset time period is obtained, and the control test result of the first application is determined according to the test log. By adjusting the trigger weight of the first application control with a low trigger coverage, the test event is triggered according to the adjusted trigger weight within the second preset time period, so that the proportion of the trigger test event for the first application control within the second preset time period is increased, and the reliability of the application control test of the first application is improved.

[0097] See also Figure 3 , Figure 3 FIG. 1 is a flow chart of another application control testing method provided by an embodiment of the present application. As shown in the figure, the method may include the following steps:

[0098] S301, obtaining a tag count of each control stub tag in an application code of a first application.

[0099] The control stub tag is a tag pre-inserted into the application code and used to count the number of times the test event is triggered for each application control in the first application within a first preset time period.

[0100] S302: Determine the trigger coverage of each application control according to the tag count of each control plug-in tag.

[0101] The trigger coverage rate is the ratio of the number of times each application control is triggered by a test event to the total number of times each application control is triggered by a test event within the first preset time period.

[0102] S303: Determine, from the application controls of the first application, respectively a first application control whose trigger coverage is less than a first preset threshold and a second application control whose trigger coverage is greater than a second preset threshold.

[0103] The first preset threshold may be a threshold that is smaller than an average trigger coverage rate of application controls in the first application, and the second preset threshold may be a threshold that is larger than an average trigger coverage rate of application controls in the first application.

[0104] S304: Adjust the initial trigger weight of the first application control and the initial trigger weight of the second application control respectively, so that the adjusted trigger weight of the first application control increases, and the initial trigger weight of the second application control decreases.

[0105] In the embodiment of the present application, the sum of the initial trigger weights of each application control in the first application is 1. Here, the trigger weight of the first application control with a lower trigger coverage can be increased, and correspondingly, the trigger weight of the second application control with a higher trigger coverage in the first application needs to be reduced. In a specific implementation, the weight adjustment ratio for each of the first application control and the second application control can be determined first, and then the trigger weights of the first application control and the second application control can be adjusted according to the determined weight adjustment ratio.

[0106] In one implementation, the weight adjustment ratios of the first application control and the second application control may be determined according to formula (1), which is as follows:

[0107]

[0108] Among them, p i is the trigger coverage of the first application control, w i is the initial trigger weight of the first application control, x i is the weight adjustment ratio of the first application control, i is the index of the first application control, m is the number of first application controls, and i and m are positive integers; q j is the trigger coverage of the second application control, S j is the initial trigger weight of the second application control, y j is the weight adjustment ratio of the second application control, j is the index of the second application control, n is the number of second application controls, and j and n are positive integers; k is the initial trigger weight of the third application control, the third application control is an application control in the first application whose trigger coverage is between the first preset threshold and the second preset threshold, k is the index of the third application control, l is the number of third application controls, and k and l are non-negative integers.

[0109] For example, if there are five application controls in the first application, the corresponding initial trigger weights and the corresponding trigger coverage rates in the first preset time period are shown in Table 1:

[0110] Control 1 Control 2 Control 3 Control 4 Controls 5 Initial trigger weight 0.25 0.15 0.3 0.2 0.1 Trigger coverage 0.2 0.1 0.3 0.3 0.1

[0111] Table 1

[0112] If the first preset threshold is 0.19 and the second preset threshold is 0.21, then control 2 and control 5 are the first application controls, control 3 and control 4 are the second application controls, and control 1 is the third application control. Substituting the above parameters into formula (1) yields the following equation group:

[0113]

[0114] Solving the above equation yields x 1 is 0.875, x 2 is 1.8125, y 1 is 0.6875, y 2 The trigger weights of the corresponding application controls are then adjusted using the above weight adjustment ratio, and the adjusted trigger weights of controls 1 to 5 are 0.25, 0.28125, 0.28125, 0.09375, and 0.09375, respectively.

[0115] S305: Obtain the total number of control triggering times set for the second preset time period, and allocate the number of control triggering times to each application interface of the first application according to the number of application controls distributed in each application interface.

[0116] Here, for the case where each application interface in the first application is not opened through an application control, it can be opened through a link, etc. Open each application interface of the first application in sequence, and then perform a certain number of test trigger events, wherein the number of control triggers assigned to each application interface is proportional to the number of application controls contained in each application interface, and the sum of the number of control triggers assigned to each application interface is equal to the total number of control triggers; the number of control triggers is used to indicate the number of times the target test control is periodically determined from each application interface within the second preset time period. For example, the total number of control triggers set for the first application within the second preset time period is 200 times, the first application contains 4 application interfaces, and the number of application controls contained in interface 1, interface 2, interface 3, and interface 4 are 10, 5, 3, and 2 respectively, then the number of control triggers assigned to interface 1, interface 2, interface 3, and interface 4 are 100 times, 20 times, 30 times, and 20 times respectively.

[0117] S306, within the second preset time period, according to the trigger weight of the application control in the application interface and the number of times the control corresponding to the application interface is triggered, a target test control is periodically randomly determined from the application controls in the application interface, and a test event is triggered for the target test control.

[0118] Here, for each application interface, the total number of times the target test control is periodically and randomly determined and the test event is triggered is equal to the number of control triggers assigned to the application interface in S305. Figure 1 The implementation process of step S104 in the corresponding embodiment will not be repeated here.

[0119] S307, obtaining a test log generated for the first application control within a second preset time period, and determining a control test result of the first application according to the test log.

[0120] In an embodiment of the present invention, the tag count of each control plug-in tag in the application code of the first application is obtained. The control plug-in tag is a tag pre-inserted in the application code and used to count the number of times the test event is triggered for each application control in the first application within a first preset time period. According to the tag count of each control plug-in tag, the trigger coverage of each application control is determined respectively, and then for the first application control whose trigger coverage is less than the first preset threshold, its initial trigger weight is adjusted to increase the adjusted trigger weight of the first application control, and for the second application control whose trigger coverage is greater than the second preset threshold, its initial trigger weight is adjusted to reduce the adjusted trigger weight. Then, within the second preset time period, according to the adjusted trigger weights of each application control, the target test control is periodically randomly determined from each application control, so as to trigger a test event for the target test control, and the test log generated for the application control in the first application within the second preset time period is obtained, and the control test result of the first application is determined according to the test log. By adjusting the trigger weights of the first application control and the second application control, a test event is triggered according to the adjusted trigger weights within a second preset time period, so that the proportion of trigger test events for the first application control within the second preset time period is increased, thereby improving the reliability of the application control test of the first application.

[0121] See also Figure 4 , Figure 4 : is a structural diagram of an application control test device provided in an embodiment of the present application. As shown in the figure, the application control test device 40 includes:

[0122] The tag acquisition module 401 is used to obtain the tag count of each control plug-in tag in the application code of the first application; the control plug-in tag is a tag pre-inserted in the application code and used to count the number of times the test event is triggered for each application control in the first application within a first preset time period;

[0123] A coverage determination module 402, configured to determine the trigger coverage of each of the application controls according to the tag count of each of the control instrumentation tags, wherein the trigger coverage is the ratio of the number of times the test event is triggered for each of the application controls to the total number of times the test event is triggered for each of the application controls within the first preset time period;

[0124] The weight adjustment module 403 is used to determine, from the various application controls of the first application, a first application control whose trigger coverage is less than a first preset threshold, and adjust the initial trigger weight of the first application control so that the adjusted trigger weight of the first application control is increased; the initial trigger weight of the first application control is a reference weight for triggering a test event for the first application control within the first preset time period;

[0125] The testing module 404 is used to periodically randomly determine a target test control from the various application controls according to the adjusted trigger weights of the various application controls within a second preset time period, and trigger a test event for the target test control;

[0126] The result generation module 405 is used to obtain the test log generated for the application control in the first application within the second preset time period, and determine the control test result of the first application according to the test log.

[0127] In a specific implementation, the application control triggering device can execute the following operations through its built-in functional modules: Figure 1 and Figure 3 For details on the various steps in the application control testing method, see Figure 1 and Figure 3 The implementation details of each step in the corresponding embodiment will not be repeated here.

[0128] In an embodiment of the present invention, the tag acquisition module acquires the tag count of each control plug-in tag in the application code of the first application, and the control plug-in tag is a tag pre-inserted in the application code and used to count the number of times each application control in the first application is triggered by a test event within a first preset time period. The coverage determination module determines the trigger coverage of each application control according to the tag count of each control plug-in tag, and then the weight adjustment module adjusts the initial trigger weight of the first application control whose trigger coverage is less than the first preset threshold, so that the adjusted trigger weight of the first application control is increased. Then, the test module periodically randomly determines the target test control from each application control in the second preset time period according to the adjusted trigger weight of each application control, thereby triggering a test event for the target test control, and the result generation module acquires the test log generated for the application control in the first application in the second preset time period, and determines the control test result of the first application according to the test log. By adjusting the trigger weight of the first application control with a low trigger coverage, the test event is triggered according to the adjusted trigger weight in the second preset time period, so that the proportion of the trigger test event for the first application control in the second preset time period is increased, thereby improving the reliability of the application control test of the first application.

[0129] See also Figure 5 , Figure 5 FIG. 1 is a schematic diagram of another application control triggering device provided by an embodiment of the present invention. Figure 5 As shown, the application control triggering device 50 may include: at least one processor 501, such as a CPU, at least one network interface 504, a user interface 503, a memory 505, and at least one communication bus 502. The communication bus 502 is used to realize the connection and communication between these components. The user interface 503 may include a display screen (Display) and a keyboard (Keyboard), and the optional user interface 503 may also include a standard wired interface and a wireless interface. The network interface 504 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 505 may be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 505 may optionally also be at least one storage device located away from the aforementioned processor 501. As Figure 5 As shown, the memory 505 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a device control application program.

[0130] exist Figure 5In the application control triggering device 50 shown, the network interface 504 is mainly used to connect to the terminal carrying the application; the user interface 503 is mainly used to provide an input interface for the user; and the processor 501 can be used to call the device control application stored in the memory 505 to achieve:

[0131] Obtaining a tag count of each control stub tag in the application code of the first application; the control stub tag is a tag pre-inserted in the application code and used to count the number of times a test event is triggered for each application control in the first application within a first preset time period;

[0132] Determining the trigger coverage of each application control according to the tag count of each control instrumentation tag, respectively, wherein the trigger coverage is the ratio of the number of times the test event is triggered for each application control to the total number of times the test event is triggered for each application control within the first preset time period;

[0133] Determine, from among the application controls of the first application, a first application control whose trigger coverage is less than a first preset threshold, and adjust an initial trigger weight of the first application control so that the adjusted trigger weight of the first application control is increased; the initial trigger weight of the first application control is a reference weight for triggering a test event for the first application control within the first preset time period;

[0134] Within a second preset time period, according to the adjusted trigger weights of the various application controls, periodically and randomly determine a target test control from the various application controls, and trigger a test event for the target test control;

[0135] A test log generated for an application control in the first application within the second preset time period is obtained, and a control test result of the first application is determined according to the test log.

[0136] It should be understood that the application control triggering device 50 described in the embodiment of the present invention can execute the above Figure 1 and Figure 3 The description of the application control triggering method in the corresponding embodiment can also be performed as described above. Figure 4 The description of the application control triggering device 1 in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated here either.

[0137] In addition, it should be pointed out here that: an embodiment of the present invention further provides a computer storage medium, and the computer storage medium stores a computer program executed by the application control triggering device 1 mentioned above, and the computer program includes program instructions. When the processor executes the program instructions, it can execute the above Figure 1 and Figure 3 The description of the application control triggering method in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated. For technical details not disclosed in the computer storage medium embodiment involved in the present invention, please refer to the description of the method embodiment of the present invention.

[0138] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0139] The above disclosure is only the preferred embodiment of the present invention, which certainly cannot be used to limit the scope of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope of the present invention.

Claims

1. A method for testing an application control, characterized in that: include: Obtaining a tag count of each control stub tag in the application code of the first application; the control stub tag is a tag pre-inserted in the application code and used to count the number of times a test event is triggered for each application control in the first application within a first preset time period; Determining the trigger coverage of each application control according to the tag count of each control instrumentation tag, respectively, wherein the trigger coverage is the ratio of the number of times the test event is triggered for each application control to the total number of times the test event is triggered for each application control within the first preset time period; Determine, from the application controls of the first application, a first application control whose trigger coverage is less than a first preset threshold, and adjust the initial trigger weight of the first application control so that the adjusted trigger weight of the first application control is increased; the initial trigger weight of the first application control is a reference weight for triggering a test event for the first application control within the first preset time period; wherein adjusting the initial trigger weight of the first application control includes: Determine, from among the application controls of the first application, a second application control whose trigger coverage is greater than a second preset threshold; Determine a weight adjustment ratio of the first application control and the second application control; the weight adjustment ratio of the first application control and the second application control satisfies the following formula: Among them, p i is the trigger coverage of the first application control, w i is the initial trigger weight of the first application control, x i is the weight adjustment ratio of the first application control, i is the index of the first application control, m is the number of the first application controls, and i and m are positive integers; q j is the trigger coverage of the second application control, S j is the initial trigger weight of the second application control, y j is the weight adjustment ratio of the second application control, j is the index of the second application control, n is the number of the second application controls, and j and n are positive integers; k is the initial trigger weight of the third application control, the third application control is an application control in the first application whose trigger coverage is between the first preset threshold and the second preset threshold, k is the index of the third application control, l is the number of the third application controls, and k and l are non-negative integers; According to the weight adjustment ratio of the first application control, the trigger weight of the first application control is adjusted, and according to the weight adjustment ratio of the second application control, the trigger weight of the second application control is adjusted; Within a second preset time period, according to the adjusted trigger weights of the various application controls, periodically and randomly determine a target test control from the various application controls, and trigger a test event for the target test control; A test log generated for an application control in the first application within the second preset time period is obtained, and a control test result of the first application is determined according to the test log.

2. The method according to claim 1, characterized in that The first application includes at least one application interface; the various application controls are distributed in the at least one application interface; Before periodically and randomly determining a target test control from each application control according to the adjusted trigger weights of each application control within the second preset time period, the method further includes: Obtaining the total number of control triggering times set for the second preset time period; According to the number of application controls distributed in each application interface, a control triggering number is allocated to each application interface; the control triggering number allocated to each application interface is proportional to the number of application controls contained in each application interface, and the sum of the control triggering number allocated to each application interface is equal to the total control triggering number; the control triggering number is used to indicate the number of times the target test control is periodically determined from each application interface within a second preset time period.

3. The method according to claim 2, characterized in that The step of periodically and randomly determining a target test control from each of the application controls according to the adjusted trigger weights of each of the application controls within the second preset time period includes: According to the initial trigger weight of each application control in the application interface, each value in the preset random value set is assigned to each application control in the application interface, and the number of values ​​assigned to the application control in the application interface is proportional to its own trigger weight; A first random number belonging to the preset random value set is periodically randomly generated, and an application control assigned to the first random number is determined as the target test control.

4. The method according to claim 1, characterized in that: The triggering of a test event on the target test control comprises: Acquire the type attribute information of the target test control, and generate a test event for the target test control according to the type attribute information of the target test control; The generated test event is triggered for the target test control.

5. The method according to claim 1, characterized in that: The triggering of a test event on the target test control comprises: Acquire the coordinate information of the target test control, and determine the test area of ​​the target test control according to the coordinate information of the target test control; The test event is triggered for the target test control in the test area of ​​the target test control.

6. The method according to claim 1, characterized in that Each of the application controls has a corresponding trigger condition code in the application code of the first application; The method further comprises: After the trigger condition code corresponding to the application control, insert the stub code for the application control; the stub code includes the control stub tag of the application control, the stub code runs after the trigger condition code corresponding to the application control is triggered, and the tag count of the control stub tag of the application control is increased by one each time the stub code runs.

7. An application control testing device, characterized in that: The application control testing device is used to implement the application control testing method according to any one of claims 1 to 6, wherein the application control testing device comprises: A tag acquisition module, used to obtain a tag count of each control plug-in tag in the application code of the first application; the control plug-in tag is a tag pre-inserted in the application code and used to count the number of times a test event is triggered for each application control in the first application within a first preset time period; A coverage determination module, configured to determine the trigger coverage of each of the application controls according to the tag counts of the instrumentation tags of each of the controls, wherein the trigger coverage is a ratio of the number of times the test events are triggered on each of the application controls to the total number of times the test events are triggered on each of the application controls within the first preset time period; a weight adjustment module, configured to determine, from among the application controls of the first application, a first application control whose trigger coverage is less than a first preset threshold, and adjust an initial trigger weight of the first application control so that the adjusted trigger weight of the first application control is increased; the initial trigger weight of the first application control is a reference weight for triggering a test event for the first application control within the first preset time period; A test module, configured to periodically and randomly determine a target test control from among the application controls according to the adjusted trigger weights of the application controls within a second preset time period, and trigger a test event for the target test control; The result generation module is used to obtain a test log generated for the application control in the first application within the second preset time period, and determine a control test result of the first application according to the test log.

8. An application control triggering device, characterized in that: include: Processor and memory; The processor is connected to a memory, wherein the memory is used to store program codes, and the processor is used to call the program codes to execute the method according to any one of claims 1 to 6.

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