本发明的实施方式Embodiments of the invention
以下描述中,为了说明而不是为了限定,提出了诸如特定系统结构、技术之类的具体细节,以便透彻理解本申请实施例。然而,本领域的技术人员应当清楚,在没有这些具体细节的其它实施例中也可以实现本申请。在其它情况中,省略对众所周知的系统、装置、电路以及方法的详细说明,以免不必要的细节妨碍本申请的描述。In the following description, for the purpose of illustration rather than limitation, specific details such as a specific system structure and technology are proposed for a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid unnecessary details from obstructing the description of this application.
为了说明本申请所述的技术方案,下面通过具体实施例来进行说明。In order to illustrate the technical solutions described in the present application, specific embodiments are used for description below.
图1示出了本申请实施例提供的基于功能测试的因素影响程度确定方法的实现流程,详述如下:Figure 1 shows the implementation process of the method for determining the degree of influence of factors based on functional testing provided by an embodiment of the present application, which is described in detail as follows:
在S101中,根据预设的标准环境参数将网络环境配置为标准环境,并在所述标准环境下执行待测功能对应的程序,将执行完成所述待测功能对应的程序所用的时长确定为标准时长。In S101, the network environment is configured as a standard environment according to preset standard environmental parameters, and the program corresponding to the function to be tested is executed in the standard environment, and the time taken to execute the program corresponding to the function to be tested is determined as Standard duration.
在本申请实施例中,为了判定不同的网络因素对终端设备上的待测功能对应的程序的影响程度,首先对待测功能对应的程序在标准环境下的执行情况进行分析,具体地,根据预设的标准环境参数将终端设备的网络环境配置为标准环境,并在标准环境下执行待测功能对应的程序,获取执行完成待测功能对应的程序所用的时长,为了便于区分,将本步骤中获取到的时长命名为标准时长。值得一提的是,本申请实施例对待测功能的具体类型并不做限定,比如待测功能可为数据统计、步数监测或线上购物等功能,并且,本申请实施例中的网络因素专指的是导致弱信号的因素,如低带宽、高时延或高丢包率等,可由测试人员预先定义网络因素的种类。上述的标准环境参数可由测试人员预先自定义设置,也可在获取到待测功能对应的程序的预期网络环境后(如4G或Wi-Fi等),将标准环境参数设置为与预期网络环境的环境参数相同。为了便于说明,假设本申请实施例中的环境参数包括上行带宽、下行带宽、上行丢包率、下行丢包率、上行时延以及下行时延,当然根据实际应用场景不同,环境参数还可包括与网络相关的更多的内容。In the embodiment of the present application, in order to determine the degree of influence of different network factors on the program corresponding to the function to be tested on the terminal device, the execution of the program corresponding to the function to be tested in the standard environment is first analyzed, specifically, according to the forecast Set the standard environment parameters to configure the network environment of the terminal device as a standard environment, and execute the program corresponding to the function to be tested in the standard environment, and obtain the time taken to execute the program corresponding to the function to be tested. In order to facilitate the distinction, this step The obtained duration is named the standard duration. It is worth mentioning that the specific types of functions to be tested are not limited in the embodiments of this application. For example, the functions to be tested can be functions such as data statistics, step count monitoring, or online shopping. Moreover, the network factors in the embodiments of this application It specifically refers to the factors that cause weak signals, such as low bandwidth, high delay, or high packet loss rate. Testers can predefine the types of network factors. The above standard environmental parameters can be customized by the tester in advance, or after obtaining the expected network environment of the program corresponding to the function to be tested (such as 4G or Wi-Fi, etc.), the standard environmental parameters can be set to match the expected network environment. The environmental parameters are the same. For the convenience of description, it is assumed that the environmental parameters in the embodiments of this application include uplink bandwidth, downlink bandwidth, uplink packet loss rate, downlink packet loss rate, uplink delay, and downlink delay. Of course, depending on actual application scenarios, environmental parameters may also include More content related to the web.
可选地,设置标准环境参数与所有的网络因素均不对应。在本申请实施例中,为了使获取到的标准时长不受任一个网络因素的影响,可设置标准环境参数与所有的网络因素均不对应,举例来说,可设置标准环境参数中的上行带宽为33000千比特每秒(kbps),下行带宽为40000kbps,上行丢包率和下行丢包率均为0,上行时延和下行时延均为1毫秒,则根据该标准环境配置出的标准环境类似于Wi-Fi环境,其中,配置标准环境的操作可基于开源的网络模拟工具实现。通过上述方法,提升了后续基于标准时长进行分析的准确性。Optionally, setting standard environmental parameters does not correspond to all network factors. In the embodiment of this application, in order to prevent the obtained standard duration from being affected by any network factor, the standard environment parameter can be set to be incompatible with all network factors. For example, the uplink bandwidth in the standard environment parameter can be set as 33000 kilobits per second (kbps), downlink bandwidth is 40000kbps, uplink packet loss rate and downlink packet loss rate are both 0, uplink delay and downlink delay are both 1 millisecond, then the standard environment configured according to this standard environment is similar In the Wi-Fi environment, the operation of configuring the standard environment can be implemented based on open source network simulation tools. Through the above method, the accuracy of subsequent analysis based on the standard duration is improved.
在S102中,获取至少两组待测环境参数,选取至少两组中的任一组作为目标组,根据所述目标组的所述待测环境参数将所述网络环境配置为所述待测环境参数对应的待测环境,并在所述待测环境下执行所述待测功能对应的程序,将执行完成所述待测功能对应的程序所用的时长确定为所述目标组的测试时长,直到得到每组所述待测环境参数对应的所述测试时长为止,其中,每组所述待测环境参数对应至少一个网络因素,所述网络因素为弱信号因素。In S102, at least two sets of environmental parameters to be tested are acquired, any one of the at least two sets is selected as a target group, and the network environment is configured as the environment to be tested according to the environmental parameters to be tested of the target group The environment to be tested corresponding to the parameter, and the program corresponding to the function to be tested is executed in the environment to be tested, and the time taken to complete the program corresponding to the function to be tested is determined as the test duration of the target group until Until the test duration corresponding to each group of the environmental parameters to be tested is obtained, wherein each group of the environmental parameters to be tested corresponds to at least one network factor, and the network factor is a weak signal factor.
与标准环境参数对应的,在本申请实施例中预先设置至少两组待测环境参数,为了分析不同网络因素对待测功能对应的程序的影响程度,限定每组待测环境参数对应至少一个网络因素,且所有组待测环境参数覆盖已定义的所有种类的网络因素。举例来说,在定义的网络因素包括低带宽、高丢包率和高时延的情况下,可设置一组待测环境参数ParameterA对应的网络因素为低带宽,具体将ParameterA中的上行带宽和下行带宽均设置为32kbps,将ParameterA中的其余内容设置为与标准环境参数一致(在标准环境参数为步骤S101中的例子的情况下,设置ParameterA中的上行丢包率和下行丢包率均为0,上行时延和下行时延均为1毫秒);设置另一组待测环境参数ParameterB对应的网络因素为高丢包率,具体将ParameterB中的上行丢包率和下行丢包率均设置为90%,将ParameterB中的其余内容设置为与标准环境参数一致;设置另一组待测环境参数ParameterC对应的网络因素为高时延,具体将ParameterC中的上行时延和下行时延均设置为350毫秒,将ParameterC中的其余内容设置为与标准环境参数一致。当然,以上仅为示例,并不构成对本申请实施例的限定,在实际应用场景中还可设置网络因素对应更多不同的数值(如设置低带宽对应的数值为33kbps),并且还可定义更多的网络因素,如细分上行和下行,定义为低上行带宽的网络因素和为低下行带宽的网络因素等。Corresponding to standard environmental parameters, at least two sets of environmental parameters to be tested are preset in the embodiment of this application. In order to analyze the influence of different network factors on the program corresponding to the function to be tested, it is limited that each set of environmental parameters to be tested corresponds to at least one network factor , And all groups of environmental parameters to be tested cover all types of defined network factors. For example, when the defined network factors include low bandwidth, high packet loss rate, and high latency, you can set a set of environmental parameters to be tested, ParameterA, to correspond to the network factors of low bandwidth, and specifically set the uplink bandwidth in ParameterA to The downlink bandwidth is set to 32kbps, and the rest of the content in ParameterA is set to be consistent with the standard environmental parameters (when the standard environmental parameters are the example in step S101, set the uplink packet loss rate and the downlink packet loss rate in ParameterA to both 0, both the upstream and downstream delays are 1 millisecond); set the network factor corresponding to another set of environmental parameters ParameterB to be high packet loss rate, specifically set both the upstream packet loss rate and the downstream packet loss rate in ParameterB 90%, set the rest of the content in ParameterB to be consistent with the standard environmental parameters; set the network factor corresponding to another set of environmental parameters to be tested ParameterC to be high latency, specifically set both the uplink and downlink delays in ParameterC For 350 milliseconds, set the rest of ParameterC to be consistent with standard environmental parameters. Of course, the above are only examples and do not constitute a limitation to the embodiments of this application. In actual application scenarios, network factors can be set to correspond to more different values (for example, the value corresponding to low bandwidth is set to 33kbps), and more can be defined. Multiple network factors, such as subdividing upstream and downstream, are defined as network factors with low upstream bandwidth and network factors with low downstream bandwidth.
在获取到预设的待测环境参数后,获取待测功能对应的程序在每一组待测环境参数对应的环境下的执行情况,具体选取至少两组中的任一组作为目标组,根据目标组的待测环境参数将终端设备的网络环境配置为待测环境,在待测环境下执行待测功能对应的程序,将执行完成待测功能对应的程序所用的时长确定为测试时长的操作,直到得到每组待测环境参数对应的测试时长为止。After obtaining the preset environmental parameters to be tested, obtain the execution status of the program corresponding to the function to be tested in the environment corresponding to each set of environmental parameters to be tested, and specifically select any one of at least two groups as the target group, according to The environment parameters of the target group to be tested configure the network environment of the terminal device as the environment to be tested, execute the program corresponding to the function to be tested in the environment to be tested, and determine the duration of execution of the program corresponding to the function to be tested as the test duration operation , Until the test duration corresponding to each group of environmental parameters to be tested is obtained.
可选地,在待测环境下执行待测功能对应的程序之后,若经过预设的超时时间段待测功能对应的程序仍未执行完成,则将待测环境对应的测试时长设置为预设的超时时长。由于待测环境为弱信号环境,故待测功能对应的程序可能存在无法执行完成的情况,针对该情况,本申请实施例预先设置一个超时时间段,并设置在待测环境下执行待测功能对应的程序之后,若经过预设的超时时间段待测功能对应的程序仍未执行完成,则将待测环境对应的测试时长设置为预设的超时时长,便于进行后续计算。Optionally, after executing the program corresponding to the function to be tested in the environment to be tested, if the program corresponding to the function to be tested has not been executed after a preset timeout period, the test duration corresponding to the environment to be tested is set to the preset The timeout period of. Since the environment to be tested is a weak signal environment, the program corresponding to the function to be tested may not be able to be executed. For this situation, the embodiment of this application presets a timeout period and sets the function to be tested in the environment to be tested After the corresponding program, if the program corresponding to the function to be tested has not been completed after the preset timeout period, the test duration corresponding to the environment to be tested is set to the preset timeout duration to facilitate subsequent calculations.
在S103中,将所述测试时长与所述标准时长之间的比值确定为告警值,并将所述告警值与所述测试时长对应的所有所述网络因素建立映射关系。In S103, the ratio between the test duration and the standard duration is determined as an alarm value, and a mapping relationship between the alarm value and all the network factors corresponding to the test duration is established.
为了判断不同网络环境对待测功能对应的程序的影响程度,计算测试时长与标准时长之间的比值,将得到的比值命名为告警值,最终将告警值与该测试时长对应的所有网络因素建立映射关系。举例来说,标准时长为10秒,而得到的某个测试时长为20秒,则计算得到该测试时长对应的告警值为2。In order to judge the degree of influence of the program corresponding to the function under test in different network environments, the ratio between the test duration and the standard duration is calculated, and the obtained ratio is named the alarm value. Finally, the alarm value is mapped to all network factors corresponding to the test duration. relationship. For example, if the standard duration is 10 seconds, and a certain test duration is 20 seconds, the alarm value corresponding to the test duration is calculated to be 2.
在S104中,对每个所述网络因素对应的所有所述告警值进行均值运算得到衡量值,按照所述衡量值对所有所述网络因素进行排序,并输出排序后的所有所述网络因素。In S104, perform an average operation on all the alarm values corresponding to each of the network factors to obtain a measurement value, sort all the network factors according to the measurement value, and output all the network factors after sorting.
在计算出所有测试时长对应的告警值后,统计每个网络因素对应的所有告警值,并对每个网络因素对应的所有告警值进行均值运算得到衡量值,具体先计算出每个网络因素对应的所有告警值之和,再将求和的结果除以该网络因素在所有组待测环境参数中的对应次数。举例来说,待测环境参数ParameterD对应的网络因素为FactorD,待测环境参数ParameterE对应的网络因素为FactorE和FactorF,待测环境参数ParameterF对应的网络因素为FactorF,FactorD对应的所有告警值之和为3,FactorF对应的所有告警值之和为7,则可得到FactorD的对应次数为1,求得FactorD的衡量值为3/1=3,可得到FactorF的对应次数为2,求得FactorF的衡量值为7/2=3.5。值得一提的是,若某个网络因素不存在对应的衡量值,即待测功能对应的程序在该网络因素对应的待测环境下的测试时长与标准时长相同(或测试时长与标准时长之间的差值的绝对值小于延迟时长),则可将该网络因素对应的衡量值设置为零,便于进行排序。After calculating the alarm values corresponding to all test durations, count all the alarm values corresponding to each network factor, and perform the average operation on all the alarm values corresponding to each network factor to obtain the measured value. Specifically, first calculate the corresponding value of each network factor The sum of all alarm values of, and then divide the result of the sum by the corresponding times of the network factor in all groups of environmental parameters to be tested. For example, the network factor corresponding to the tested environmental parameter ParameterD is FactorD, the network factor corresponding to the tested environmental parameter ParameterE is FactorE and FactorF, and the network factor corresponding to the tested environmental parameter ParameterF is FactorF. The sum of all alarm values corresponding to FactorD If the sum of all alarm values corresponding to FactorF is 7, then the corresponding number of FactorD is 1, and the measurement value of FactorD is 3/1=3, and the corresponding number of FactorF is 2, and the corresponding number of FactorF is calculated. The measurement value is 7/2=3.5. It is worth mentioning that if there is no corresponding measurement value for a certain network factor, that is, the test duration of the program corresponding to the function to be tested in the environment to be tested corresponding to the network factor is the same as the standard duration (or the test duration and the standard duration are different The absolute value of the difference is less than the delay time), then the measurement value corresponding to the network factor can be set to zero, which is convenient for sorting.
得到的衡量值指示对应的网络因素对待测功能对应的程序的影响程度,衡量值越高,则对应的网络因素的影响程度越大。故基于衡量值对所有网络因素进行排序,排序可基于衡量值从大到小的顺序或从小到大的顺序进行,本申请实施例并不做限定,最终输出排序后的所有网络因素。The obtained measurement value indicates the degree of influence of the corresponding network factor on the program corresponding to the function to be tested, and the higher the measurement value, the greater the degree of influence of the corresponding network factor. Therefore, all network factors are sorted based on the measurement value. The sorting can be performed based on the order of the measurement value from large to small or from small to large. The embodiment of the present application does not limit it, and finally outputs all the network factors after sorting.
测试人员可根据排序后的网络因素对待测功能对应的程序进行代码及功能优化,以克服影响程度较大的网络因素对待测功能对应的程序的影响,尽量避免待测功能对应的程序在弱信号环境下运行不稳定的情况。举例来说,若待测功能为终端设备投票后服务器自动发送已投票提示的功能,且在本步骤中按照衡量值从大到小的顺序对网络因素进行排序,排序后的所有网络因素中位于前列的网络因素为下行高时延,测试人员便可根据该网络因素对该待测功能对应的程序的底层代码进行优化,具体可减少已投票提示的提示内容或者简化与服务器之间的交互认证过程等。Testers can optimize the code and function of the program corresponding to the function to be tested according to the sorted network factors to overcome the influence of the network factors with a greater degree of influence on the program corresponding to the function to be tested, and try to avoid the weak signal of the program corresponding to the function to be tested Unstable operation in the environment. For example, if the function to be tested is the function that the server automatically sends the voting reminder after the terminal device votes, and in this step, the network factors are sorted according to the order of the measured value, and all the network factors after sorting are located The forefront network factor is the high downlink latency, and the tester can optimize the underlying code of the program corresponding to the function to be tested according to the network factor, which can specifically reduce the prompt content of the voting prompt or simplify the interactive authentication with the server Process etc.
通过图1所示实施例可知,在本申请实施例中,通过获取待测功能对应的程序在标准环境下完整执行所用的标准时长,并获取待测功能对应的程序在不同待测环境下完整执行所用的测试时长,获取超过标准时长的测试时长对应的告警值,并将告警值与测试时长对应的所有网络因素建立映射关系,最后基于告警值计算出每个网络因素的衡量值,输出按照衡量值进行排序后的所有网络因素,本申请实施例通过部署不同的待测环境,并通过计算衡量值,对不同网络因素对待测功能对应的程序的影响程度进行了量化,实现了影响程度的精确测定。It can be seen from the embodiment shown in FIG. 1 that, in the embodiment of this application, the standard duration for the complete execution of the program corresponding to the function to be tested in the standard environment is obtained, and the program corresponding to the function to be tested is complete in different environments to be tested. Perform the test duration used, obtain the alarm value corresponding to the test duration exceeding the standard duration, and establish a mapping relationship between the alarm value and all network factors corresponding to the test duration, and finally calculate the measurement value of each network factor based on the alarm value, and the output is as per All network factors after the measurement values are sorted, the embodiment of the application deploys different environments to be tested and calculates the measurement values to quantify the degree of influence of different network factors on the program corresponding to the function to be tested, and realize the degree of influence Accurate determination.
图2所示,是在本申请实施例一的基础上进行扩展后得到的一种基于功能测试的因素影响程度确定方法。本申请实施例提供了基于功能测试的因素影响程度确定方法的实现流程图,如图2所示,该因素影响程度确定方法可以包括以下步骤:Figure 2 shows a method for determining the degree of influence of a factor based on a function test after expansion on the basis of Embodiment 1 of the present application. The embodiment of the present application provides an implementation flow chart of the method for determining the degree of influence of a factor based on functional testing. As shown in FIG. 2, the method for determining the degree of influence of the factor may include the following steps:
在S201中,将在所述待测功能对应的程序执行之前处于的状态保存为初始状态。In S201, the state before the execution of the program corresponding to the function to be tested is saved as the initial state.
在实际应用场景中,待测功能可能为不同类型的功能,比如待测功能可能为可重复执行的功能,比如投票功能或刷新功能,在该情况下,可直接配置标准环境和不同的待测环境,并在标准环境下获取标准时长,在待测环境下获取测试时长。待测功能也可能为执行后无法再度执行的功能,比如待测功能为点击页面A中的某个按钮,跳转至页面B的功能,由于在执行过一次待测功能对应的程序后,终端设备的当前页面为页面B,自然无法在终端设备中再点击页面A中的按钮。针对上述情况,在本申请实施例中,将终端设备在待测功能对应的程序执行之前处于的状态保存为初始状态,该初始状态可为页面状态或数据状态等,根据实际应用场景确定。In actual application scenarios, the function to be tested may be of different types. For example, the function to be tested may be a function that can be executed repeatedly, such as a voting function or a refresh function. In this case, the standard environment and different functions to be tested can be directly configured Environment, and get the standard duration in the standard environment, and get the test duration in the environment to be tested. The function to be tested may also be a function that cannot be executed again after execution. For example, the function to be tested is a function that jumps to page B by clicking a button on page A, because after executing the program corresponding to the function to be tested, the terminal The current page of the device is page B, and it is naturally impossible to click the button on page A in the terminal device. In view of the above situation, in the embodiment of the present application, the state of the terminal device before the execution of the program corresponding to the function to be tested is saved as an initial state. The initial state may be a page state or a data state, etc., which is determined according to actual application scenarios.
在S202中,若检测到在所述标准环境下或在所述待测环境下执行完毕所述待测功能对应的程序,则将当前状态回滚为所述初始状态。In S202, if it is detected that the program corresponding to the function to be tested has been executed in the standard environment or the environment to be tested, the current state is rolled back to the initial state.
若检测到在标准环境下或在待测环境下执行完毕待测功能对应的程序,由于在本申请实施例中待测功能为执行后无法再度执行的功能,故将当前状态回滚为初始状态,以使待测功能对应的程序能够支持重复执行。If it is detected that the program corresponding to the function to be tested is executed in the standard environment or the environment to be tested, since the function to be tested in the embodiment of this application is a function that cannot be executed again after execution, the current state is rolled back to the initial state , So that the program corresponding to the function to be tested can support repeated execution.
可选地,若待测功能为页面跳转功能,且初始状态包括一个初始页面,则在检测到该页面跳转功能执行完毕时,触发页面返回功能,将当前页面切换为初始页面。在待测功能为页面跳转功能的情况下,保存的初始状态至少包括一个初始页面,则在检测到该页面跳转功能执行完毕后,触发终端设备上的页面返回功能(可为用于进行页面返回的控件),将终端设备的当前页面切换为初始页面。Optionally, if the function to be tested is a page jump function, and the initial state includes an initial page, when it is detected that the page jump function is executed, the page return function is triggered to switch the current page to the initial page. When the function to be tested is a page jump function, the saved initial state includes at least one initial page, and after detecting that the page jump function is executed, the page return function on the terminal device (which can be used for Page return control), switch the current page of the terminal device to the initial page.
可选地,若待测功能为数据操作功能,则获取与数据操作功能对应的第一操作语句,并创建与第一操作语句对应的第二操作语句,其中,第一操作语句的执行结果与第二操作语句的执行结果相逆;若检测到该数据操作功能执行完毕,则执行第二操作语句。在待测功能为数据操作功能的情况下(其作用是对终端设备的前端或服务器上的数据进行操作,如添加数据的操作或删除数据的操作等),为了使数据操作功能能够重复执行,首先获取与数据操作功能对应的第一操作语句,该第一操作语句用于被执行以实现数据操作功能,并创建与第一操作语句对应的第二操作语句,其中,第一操作语句的执行结果与第二操作语句的执行结果相逆,比如第一操作语句为删除服务器中的数据A,则第二操作语句为向服务器增加数据A,第一操作语句和第二操作语句可为结构化查询语言(Structured
Query Language,SQL)语句,也可为其他类型的语句,本申请实施例对此不做限定。若检测到该数据操作功能执行完毕,则执行第二操作语句,从而消除因执行该数据操作功能造成的执行结果。Optionally, if the function to be tested is a data operation function, a first operation sentence corresponding to the data operation function is obtained, and a second operation sentence corresponding to the first operation sentence is created, wherein the execution result of the first operation sentence is the same as The execution result of the second operation statement is reversed; if it is detected that the data operation function is executed, the second operation statement is executed. When the function to be tested is a data operation function (its role is to operate on the front end of the terminal device or the data on the server, such as adding data or deleting data, etc.), in order to enable the data operation function to be executed repeatedly, First, obtain the first operation statement corresponding to the data operation function, which is used to be executed to realize the data operation function, and create a second operation statement corresponding to the first operation statement, where the execution of the first operation statement The result is the opposite of the execution result of the second operation statement. For example, the first operation statement is to delete data A in the server, and the second operation statement is to add data A to the server. The first operation statement and the second operation statement can be structured Query language (Structured
Query Language (SQL) statements may also be other types of statements, which are not limited in the embodiment of the present application. If it is detected that the execution of the data operation function is completed, the second operation statement is executed, thereby eliminating the execution result caused by the execution of the data operation function.
通过图2所示实施例可知,在本申请实施例中,将应用程序在待测功能对应的程序执行之前处于的状态保存为初始状态,若检测到待测功能对应的程序执行完毕,则将应用程序的当前状态回滚为初始状态,本申请实施例通过回滚操作保证后续执行待测功能对应的程序的执行过程不受前次的执行结果影响,提升了确定网络因素的影响程度的适用性。It can be seen from the embodiment shown in FIG. 2 that in the embodiment of the present application, the state of the application program before the execution of the program corresponding to the function to be tested is saved as the initial state, if it is detected that the program corresponding to the function to be tested is executed, the The current state of the application is rolled back to the initial state. The embodiment of the present application uses a rollback operation to ensure that the subsequent execution of the program corresponding to the function to be tested is not affected by the previous execution result, which improves the application of determining the degree of influence of network factors Sex.
图3所示,是在本申请实施例一的基础上,对在标准环境下执行待测功能对应的程序,将执行完成待测功能对应的程序所用的时长确定为标准时长的过程进行细化后得到的一种基于功能测试的因素影响程度确定方法。本申请实施例提供了基于功能测试的因素影响程度确定方法的实现流程图,如图3所示,该因素影响程度确定方法可以包括以下步骤:As shown in Figure 3, on the basis of the first embodiment of this application, the process of executing the program corresponding to the function to be tested in a standard environment and determining the time taken to complete the program corresponding to the function to be tested as the standard time length is refined A method for determining the degree of influence of factors based on functional testing is obtained later. The embodiment of the present application provides an implementation flow chart of the method for determining the degree of influence of a factor based on functional testing. As shown in FIG. 3, the method for determining the degree of influence of the factor may include the following steps:
在S301中,获取预设的与所述待测功能对应的程序对应的功能请求与功能应答,并在所述标准环境下触发所述待测功能对应的程序,其中,所述功能请求为所述待测功能对应的程序开始执行的标识,所述功能应答为所述待测功能对应的程序执行完成的标识。In S301, a preset function request and function response corresponding to the program corresponding to the function to be tested are acquired, and the program corresponding to the function to be tested is triggered in the standard environment, wherein the function request is The identifier for starting execution of the program corresponding to the function to be tested, and the function response is the identifier for completing execution of the program corresponding to the function to be tested.
在本申请实施例中,为了提升获取到的标准时长的准确性,可预先设置与待测功能对应的程序对应的功能请求与功能应答,其中功能请求为待测功能对应的程序开始执行的标识,功能应答为待测功能对应的程序执行完成的标识。举例来说,若待测功能对应的程序为访问某个网址的功能,且待测功能对应的程序基于超文本传输协议(HyperText
Transfer Protocol,HTTP)实现访问,则可设置功能请求为包含该网址的HTTP请求报文,并设置功能应答为包含为200的状态码(状态码为200,代表本次访问成功)的HTTP响应报文。在确定了功能请求和功能应答后,触发待测功能对应的程序,待测功能对应的程序的触发操作可预先指定,如触发某个预设的控件或执行预设的脚本文件等。In this embodiment of the application, in order to improve the accuracy of the obtained standard duration, the function request and function response corresponding to the program corresponding to the function to be tested can be preset, where the function request is the identification of the start of execution of the program corresponding to the function to be tested , The function response is the identification of the completion of the program execution corresponding to the function to be tested. For example, if the program corresponding to the function to be tested is a function to access a certain website, and the program corresponding to the function to be tested is based on the HyperText Transfer Protocol (HyperText
Transfer Protocol, HTTP) to achieve access, you can set the function request as an HTTP request message that contains the URL, and set the function response as an HTTP response message that contains a status code of 200 (status code 200 represents the success of this visit) Text. After the function request and function response are determined, the program corresponding to the function to be tested is triggered. The trigger operation of the program corresponding to the function to be tested can be specified in advance, such as triggering a preset control or executing a preset script file.
在S302中,若抓取到所述功能请求和所述功能应答,则获取所述功能请求的发送时间,并获取所述功能应答的接收时间,将所述发送时间与所述接收时间之间的差值的绝对值确定为所述标准时长。In S302, if the function request and the function response are captured, the sending time of the function request and the receiving time of the function response are obtained, and the time between the sending time and the receiving time is obtained. The absolute value of the difference of is determined as the standard duration.
在触发待测功能对应的程序的同时,在终端设备发起和接收的数据中抓取功能请求和功能应答,其中,可获取终端设备的日志,并在日志中以功能请求和功能应答作为搜索条件进行抓取,也可基于第三方的数据包抓取工具如Fidder实现抓取。若抓取到与待测功能对应的程序对应的功能请求和功能应答,则获取功能请求的发送时间以及功能应答的接收时间,将发送时间与接收时间之间的差值的绝对值作为标准时长,进行输出。与标准环境同样地,在网络环境为待测环境时,同样可通过类似步骤S301~S302的方式确定待测环境下的测试时长,即在待测环境下触发待测功能对应的程序,若抓取到功能请求和功能应答,则获取功能请求的发送时间以及功能应答的接收时间,将该发送时间与该接收时间之间的差值的绝对值确定为测试时长。While triggering the program corresponding to the function to be tested, the function request and function response are captured from the data initiated and received by the terminal device. Among them, the log of the terminal device can be obtained, and the function request and function response can be used as search conditions in the log. For crawling, it can also be achieved based on a third-party data packet capturing tool such as Fidder. If the function request and function response corresponding to the program corresponding to the function to be tested are captured, the sending time of the function request and the receiving time of the function response are obtained, and the absolute value of the difference between the sending time and the receiving time is used as the standard duration , To output. Similar to the standard environment, when the network environment is the environment to be tested, the test duration in the environment to be tested can also be determined by similar steps S301 to S302, that is, the program corresponding to the function to be tested is triggered in the environment to be tested. After the function request and the function response are obtained, the sending time of the function request and the receiving time of the function response are obtained, and the absolute value of the difference between the sending time and the receiving time is determined as the test duration.
通过图3所示实施例可知,在本申请实施例中,在标准环境下触发待测功能对应的程序,若抓取到与待测功能对应的程序对应的功能请求和功能应答,则获取功能请求的发送时间以及功能应答的接收时间,将发送时间与接收时间之间的差值的绝对值确定为标准时长,本申请实施例通过抓取功能请求和功能应答的方式计算标准时长,提升了获取到的标准时长的准确性。It can be seen from the embodiment shown in FIG. 3 that, in the embodiment of this application, the program corresponding to the function to be tested is triggered in the standard environment. If the function request and function response corresponding to the program corresponding to the function to be tested are captured, the function is acquired The sending time of the request and the receiving time of the function response, the absolute value of the difference between the sending time and the receiving time is determined as the standard duration. The embodiment of this application calculates the standard duration by capturing the function request and the function response, which improves The accuracy of the obtained standard duration.
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be understood that the size of the sequence number of each step in the foregoing embodiment does not mean the order of execution. The execution sequence of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiment of the present application.
对应于上文实施例所述的功能测试方法,图4示出了本申请实施例提供的基于功能测试的因素影响程度确定装置的结构框图,参照图4,该因素影响程度确定装置包括:Corresponding to the functional test method described in the above embodiment, FIG. 4 shows a structural block diagram of the device for determining the degree of influence of a factor based on a function test provided by an embodiment of the present application. Referring to FIG. 4, the device for determining the degree of influence of a factor includes:
第一执行单元41,用于根据预设的标准环境参数将网络环境配置为标准环境,并在所述标准环境下执行待测功能对应的程序,将执行完成所述待测功能对应的程序所用的时长确定为标准时长;The first execution unit 41 is configured to configure the network environment as a standard environment according to preset standard environmental parameters, and execute the program corresponding to the function to be tested in the standard environment, and execute the program corresponding to the function to be tested The duration of is determined as the standard duration;
第二执行单元42,用于获取至少两组待测环境参数,选取至少两组中的任一组作为目标组,根据所述目标组的所述待测环境参数将所述网络环境配置为所述待测环境参数对应的待测环境,并在所述待测环境下执行所述待测功能对应的程序,将执行完成所述待测功能对应的程序所用的时长确定为所述目标组的测试时长,直到得到每组所述待测环境参数对应的所述测试时长为止,其中,每组所述待测环境参数对应至少一个网络因素,所述网络因素为弱信号因素;The second execution unit 42 is configured to obtain at least two groups of environmental parameters to be tested, select any one of the at least two groups as a target group, and configure the network environment as the target group according to the environmental parameters to be tested in the target group. The environment to be tested corresponding to the environmental parameter to be tested, and the program corresponding to the function to be tested is executed in the environment to be tested, and the time taken to execute the program corresponding to the function to be tested is determined as the target group The test duration until the test duration corresponding to each group of the environmental parameters to be tested is obtained, wherein each group of the environmental parameters to be tested corresponds to at least one network factor, and the network factor is a weak signal factor;
告警值确定单元43,用于将所述测试时长与所述标准时长之间的比值确定为告警值,并将所述告警值与所述测试时长对应的所有所述网络因素建立映射关系;The alarm value determining unit 43 is configured to determine the ratio between the test duration and the standard duration as an alert value, and establish a mapping relationship between the alert value and all the network factors corresponding to the test duration;
排序单元44,用于对每个所述网络因素对应的所有所述告警值进行均值运算得到衡量值,按照所述衡量值对所有所述网络因素进行排序,并输出排序后的所有所述网络因素。The sorting unit 44 is configured to perform an average operation on all the alarm values corresponding to each of the network factors to obtain a measurement value, sort all the network factors according to the measurement value, and output all the networks after sorting factor.
可选地,因素影响程度确定装置还包括:Optionally, the device for determining the degree of influence of the factor further includes:
保存单元,用于将所述待测功能对应的程序执行之前处于的状态保存为初始状态;The saving unit is configured to save the state that the program corresponding to the function to be tested was in before execution as the initial state;
回滚单元,用于若检测到在所述标准环境下或在所述待测环境下执行完毕所述待测功能对应的程序,则将当前状态回滚为所述初始状态。The rollback unit is configured to roll back the current state to the initial state if it is detected that the program corresponding to the function to be tested has been executed in the standard environment or in the environment to be tested.
可选地,若待测功能为页面跳转功能,且初始状态包括一个初始页面,则回滚单元包括:Optionally, if the function to be tested is a page jump function, and the initial state includes an initial page, the rollback unit includes:
切换单元,用于触发页面返回功能,将当前页面切换为所述初始页面。The switching unit is used to trigger the page return function to switch the current page to the initial page.
可选地,若待测功能为数据操作功能,则回滚单元包括:Optionally, if the function to be tested is a data operation function, the rollback unit includes:
创建单元,用于获取与所述数据操作功能对应的第一操作语句,并创建与所述第一操作语句对应的第二操作语句,其中,所述第一操作语句的执行结果与所述第二操作语句的执行结果相逆;The creation unit is configured to obtain a first operation sentence corresponding to the data operation function, and create a second operation sentence corresponding to the first operation sentence, wherein the execution result of the first operation sentence corresponds to the first operation sentence The execution results of the two operation statements are reversed;
语句执行单元,用于执行所述第二操作语句。The statement execution unit is used to execute the second operation statement.
可选地,第一执行单元41包括:Optionally, the first execution unit 41 includes:
触发单元,用于获取预设的与所述待测功能对应的程序对应的功能请求与功能应答,并在所述标准环境下触发所述待测功能对应的程序,其中,所述功能请求为所述待测功能对应的程序开始执行的标识,所述功能应答为所述待测功能对应的程序执行完成的标识;The trigger unit is used to obtain preset function requests and function responses corresponding to the program corresponding to the function to be tested, and trigger the program corresponding to the function to be tested in the standard environment, wherein the function request is The identification of the start of execution of the program corresponding to the function to be tested, and the function response is the identification of the completion of execution of the program corresponding to the function to be tested;
抓取单元,用于若抓取到所述功能请求和所述功能应答,则获取所述功能请求的发送时间,并获取所述功能应答的接收时间,将所述发送时间与所述接收时间之间的差值的绝对值确定为所述标准时长。The grabbing unit is configured to obtain the sending time of the function request and the receiving time of the function response if the function request and the function response are grabbed, and compare the sending time with the receiving time The absolute value of the difference between is determined as the standard duration.
可选地,第二执行单元42还包括:Optionally, the second execution unit 42 further includes:
设置单元,用于若经过预设的超时时间段所述待测功能对应的程序仍未执行完成,则将所述待测环境对应的所述测试时长设置为预设的超时时长。The setting unit is configured to set the test duration corresponding to the environment to be tested to a preset timeout duration if the program corresponding to the function to be tested has not been completed after a preset timeout period.
因此,本申请实施例提供的因素影响程度确定装置通过量化的方式确定网络因素对待测功能对应的程序的影响程度,便于测试人员根据不同网络因素的影响程度对待测功能对应的程序进行优化。Therefore, the device for determining the degree of influence of a factor provided in the embodiment of the present application determines the degree of influence of the program corresponding to the function to be tested by the network factor in a quantitative manner, so that the tester can optimize the program corresponding to the function to be tested according to the degree of influence of different network factors.
图5是本申请实施例提供的终端设备的示意图。如图5所示,该实施例的终端设备5包括:处理器50、存储器51以及存储在所述存储器51中并可在所述处理器50上运行的计算机可读指令52,例如功能测试程序。所述处理器50执行所述计算机可读指令52时实现上述各个基于功能测试的因素影响程度确定方法实施例中的步骤,例如图1所示的步骤S101至S104。或者,所述处理器50执行所述计算机可读指令52时实现上述各基于功能测试的因素影响程度确定装置实施例中各单元的功能,例如图4所示单元41至44的功能。Fig. 5 is a schematic diagram of a terminal device provided by an embodiment of the present application. As shown in FIG. 5, the terminal device 5 of this embodiment includes: a processor 50, a memory 51, and computer-readable instructions 52 stored in the memory 51 and running on the processor 50, such as a function test program . When the processor 50 executes the computer-readable instructions 52, the steps in the above-mentioned method embodiments for determining the degree of influence of factors based on functional tests are implemented, such as steps S101 to S104 shown in FIG. 1. Alternatively, when the processor 50 executes the computer-readable instruction 52, the function of each unit in the above-mentioned device embodiment for determining the degree of influence of the factor based on the function test is implemented, for example, the functions of the units 41 to 44 shown in FIG. 4.
示例性的,所述计算机可读指令52可以被分割成一个或多个单元,所述一个或者多个单元被存储在所述存储器51中,并由所述处理器50执行,以完成本申请。所述一个或多个单元可以是能够完成特定功能的一系列计算机可读指令的指令段,该指令段用于描述所述计算机可读指令52在所述终端设备5中的执行过程。例如,所述计算机可读指令52可以被分割成第一执行单元、第二执行单元、告警值确定单元以及排序单元,各单元具体功能如下:Exemplarily, the computer-readable instruction 52 may be divided into one or more units, and the one or more units are stored in the memory 51 and executed by the processor 50 to complete the application . The one or more units may be an instruction segment of a series of computer-readable instructions capable of completing specific functions, and the instruction segment is used to describe the execution process of the computer-readable instruction 52 in the terminal device 5. For example, the computer-readable instruction 52 may be divided into a first execution unit, a second execution unit, an alarm value determination unit, and a sorting unit. The specific functions of each unit are as follows:
第一执行单元,用于根据预设的标准环境参数将网络环境配置为标准环境,并在所述标准环境下执行待测功能对应的程序,将执行完成所述待测功能对应的程序所用的时长确定为标准时长;The first execution unit is configured to configure the network environment as a standard environment according to preset standard environmental parameters, and execute the program corresponding to the function to be tested in the standard environment, and execute the program used to complete the program corresponding to the function to be tested The duration is determined as the standard duration;
第二执行单元,用于获取至少两组待测环境参数,选取至少两组中的任一组作为目标组,根据所述目标组的所述待测环境参数将所述网络环境配置为所述待测环境参数对应的待测环境,并在所述待测环境下执行所述待测功能对应的程序,将执行完成所述待测功能对应的程序所用的时长确定为所述目标组的测试时长,直到得到每组所述待测环境参数对应的所述测试时长为止,其中,每组所述待测环境参数对应至少一个网络因素,所述网络因素为弱信号因素;The second execution unit is configured to obtain at least two sets of environmental parameters to be tested, select any one of the at least two sets as the target group, and configure the network environment as the target group according to the environmental parameters to be tested in the target group The environment to be tested corresponding to the environmental parameter to be tested, and the program corresponding to the function to be tested is executed in the environment to be tested, and the time taken to execute the program corresponding to the function to be tested is determined as the test of the target group Duration, until the test duration corresponding to each group of the environmental parameters to be tested is obtained, wherein each group of the environmental parameters to be tested corresponds to at least one network factor, and the network factor is a weak signal factor;
告警值确定单元,用于将所述测试时长与所述标准时长之间的比值确定为告警值,并将所述告警值与所述测试时长对应的所有所述网络因素建立映射关系;An alarm value determination unit, configured to determine a ratio between the test duration and the standard duration as an alert value, and establish a mapping relationship between the alert value and all the network factors corresponding to the test duration;
排序单元,用于对每个所述网络因素对应的所有所述告警值进行均值运算得到衡量值,按照所述衡量值对所有所述网络因素进行排序,并输出排序后的所有所述网络因素。A sorting unit, configured to perform an average operation on all the alarm values corresponding to each of the network factors to obtain a measurement value, sort all the network factors according to the measurement value, and output all the network factors after sorting .
所述终端设备5可以是桌上型计算机、笔记本、掌上电脑及云端服务器等计算设备。所述终端设备可包括,但不仅限于,处理器50、存储器51。本领域技术人员可以理解,图5仅仅是终端设备5的示例,并不构成对终端设备5的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如所述终端设备还可以包括输入输出设备、网络接入设备、总线等。The terminal device 5 may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server. The terminal device may include, but is not limited to, a processor 50 and a memory 51. Those skilled in the art can understand that FIG. 5 is only an example of the terminal device 5, and does not constitute a limitation on the terminal device 5. It may include more or less components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device may also include input and output devices, network access devices, buses, etc.
所称处理器50可以是中央处理单元(Central
Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application
Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。The so-called processor 50 may be a central processing unit (Central
Processing Unit, CPU), it can also be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application
Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
所述存储器51可以是所述终端设备5的内部存储单元,例如终端设备5的硬盘或内存。所述存储器51也可以是所述终端设备6的外部存储设备,例如所述终端设备5上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card,FC)等。进一步地,所述存储器51还可以既包括所述终端设备5的内部存储单元也包括外部存储设备。所述存储器51用于存储所述计算机可读指令以及所述终端设备所需的其他程序和数据。所述存储器51还可用于暂时地存储已经输出或者将要输出的数据。The memory 51 may be an internal storage unit of the terminal device 5, such as a hard disk or a memory of the terminal device 5. The memory 51 may also be an external storage device of the terminal device 6, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), and a secure digital (Secure Digital, SD) equipped on the terminal device 5. Card, Flash Card (Flash Card, FC), etc. Further, the memory 51 may also include both an internal storage unit of the terminal device 5 and an external storage device. The memory 51 is used to store the computer readable instructions and other programs and data required by the terminal device. The memory 51 can also be used to temporarily store data that has been output or will be output.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机可读指令来指令相关的硬件来完成,所述的计算机可读指令可存储于一计算机非易失性可读取存储介质中,该计算机可读指令在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(Read-Only Memory,ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(Random Access Memory,RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink) DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing relevant hardware through computer-readable instructions. The computer-readable instructions can be stored in a non-volatile computer. In a readable storage medium, when the computer-readable instructions are executed, they may include the processes of the above-mentioned method embodiments. Wherein, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and/or volatile memory. Non-volatile memory may include Read-Only Memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (Random Access Memory, RAM) or external cache memory. As an illustration and not a limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Channel (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。The above-mentioned embodiments are only used to illustrate the technical solutions of the present application, not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that it can still implement the foregoing The technical solutions recorded in the examples are modified, or some of the technical features are equivalently replaced; these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the application, and should be included in Within the scope of protection of this application.