[go: up one dir, main page]

CN106909503B - A simplified method of automated test cases for Android applications - Google Patents

A simplified method of automated test cases for Android applications Download PDF

Info

Publication number
CN106909503B
CN106909503B CN201710034953.3A CN201710034953A CN106909503B CN 106909503 B CN106909503 B CN 106909503B CN 201710034953 A CN201710034953 A CN 201710034953A CN 106909503 B CN106909503 B CN 106909503B
Authority
CN
China
Prior art keywords
node
sequence
events
nodes
current
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710034953.3A
Other languages
Chinese (zh)
Other versions
CN106909503A (en
Inventor
姜博
李腾
吴宇轩
万寒
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beihang University
Original Assignee
Beihang University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beihang University filed Critical Beihang University
Priority to CN201710034953.3A priority Critical patent/CN106909503B/en
Publication of CN106909503A publication Critical patent/CN106909503A/en
Application granted granted Critical
Publication of CN106909503B publication Critical patent/CN106909503B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

本发明公开了一种Android应用自动化测试用例精简方法,属于软件测试技术领域:以触发Android应用程序崩溃的测试用例作为输入,该测试用例在层内精简算法下递归地产生新测试用例;若新测试用例不在失败测试用例集合中,则对新测试用例进行测试,若测试过程中未检测出Android应用程序错误或检测出的错误与原测试用例的错误不一致,则将该新测试用例添加到失败测试用例集合中,否则,若新测试用例检测出错误与原Android应用程序错误一致,则将其作为新的输入进行新一轮的精简;如此循环处理,直至该新测试用例满足层内精简算法的输出条件为止。在本发明中,失败测试用例集合的设置,用来存储失败的测试用例,能够减少重复测试以期提高测试用例精简的效率。

Figure 201710034953

The invention discloses a method for simplifying an Android application automatic test case, belonging to the technical field of software testing. The test case that triggers the crash of an Android application is used as an input, and the test case recursively generates a new test case under an in-layer reduction algorithm; If the test case is not in the failed test case set, the new test case is tested. If no Android application error is detected during the testing process or the detected error is inconsistent with the original test case error, the new test case will be added to the failed test case. In the test case set, otherwise, if the error detected by the new test case is consistent with the error of the original Android application, it will be used as a new input for a new round of simplification; this cycle is processed until the new test case satisfies the in-layer simplification algorithm the output conditions. In the present invention, the setting of the set of failed test cases is used to store the failed test cases, which can reduce repeated tests and improve the efficiency of simplifying test cases.

Figure 201710034953

Description

一种Android应用自动化测试用例精简方法A simplified method of automated test cases for Android applications

技术领域technical field

本发明属于软件测试技术领域,具体是一种Android应用自动化测试用例精简方法。The invention belongs to the technical field of software testing, in particular to a method for streamlining Android application automation test cases.

背景技术Background technique

Google开发的Android系统,作为智能手机操作系统之一,是基于Linux平台的开源手机操作系统,如今已占据全球智能手机操作系统市场大部分的份额。用户对Android应用的需求与日俱增,为更加快速有效地开发出稳定的应用,Android应用自动化测试技术得到了良好发展。The Android system developed by Google, as one of the smart phone operating systems, is an open source mobile operating system based on the Linux platform, and now it has occupied the majority of the global smart phone operating system market. Users' demand for Android applications is increasing day by day. In order to develop stable applications more quickly and effectively, Android application automation testing technology has been well developed.

基于自动化测试技术的测试工具在提高Android应用测试效率的同时,也带来了一些副作用。其中,最重要的问题是,因其不了解被测应用程序,这些工具生成的测试用例中具有大量无效和冗余,使得测试用例尺寸规格比较大。当某一测试用例引发Android应用程序的崩溃时,若按原测试用例进行程序缺陷分析,通常很难精确地对应用缺陷进行查找定位,或缺陷确定的范围可能会变得很大,同时也会耗费大量的时间和人力。对于调试人员来说,要修改此错误,就需要对如此多的事件手动执行,以期重现Android应用中的错误。但是,即使重现,也可能仍然很难准确地对触发错误的事件序列进行定位。Test tools based on automated testing technology improve the efficiency of Android application testing, but also bring some side effects. Among them, the most important problem is that because they do not know the application under test, the test cases generated by these tools have a lot of invalidity and redundancy, which makes the size of test cases relatively large. When a test case causes the Android application to crash, if the program defect analysis is performed according to the original test case, it is usually difficult to accurately locate and locate the application defects, or the range of defects may become very large, and also It consumes a lot of time and manpower. For a debugger, fixing this bug would require manual execution of so many events in hopes of reproducing the bug in the Android app. However, even if reproduced, it may still be difficult to pinpoint the exact sequence of events that triggered the error.

增量调试是用于自动化的测试用例最小化的方法,是一种使用系统的“假设—试验—结果”循环进行自动化程序调试的贪婪搜索方法。最初实现的增量调试算法采用的是基于字符的删减策略,通过删除待精简的测试用例中连续的字符串或者语句块来产生一系列变异体测试用例。Incremental debugging is a test case minimization method for automation, a greedy search method for automated program debugging using a systematic "what-if-test-result" loop. The initial implementation of the incremental debugging algorithm adopts a character-based pruning strategy, which generates a series of variant test cases by deleting consecutive strings or statement blocks in the test cases to be simplified.

层次化增量调试是将增量调试算法思想推广到输入的分层结构中,与增量调试算法不同的是,层次化增量调试不是将输入看作一个扁平的块,而是首先为其构建一个树结构,然后应用类似增量调试的算法自顶向下地处理树的每一层。与增量调试算法相比,层次化增量调试能够通过更少的步骤来生成更小的输出结果,其精简效率有明显提高。Hierarchical incremental debugging is to generalize the idea of incremental debugging algorithm into the hierarchical structure of the input. Different from the incremental debugging algorithm, hierarchical incremental debugging does not regard the input as a flat block, but first for it. Build a tree structure and then apply an algorithm like incremental debugging to process each level of the tree top-down. Compared with the incremental debugging algorithm, the hierarchical incremental debugging can generate smaller output results through fewer steps, and its simplification efficiency is significantly improved.

发明内容SUMMARY OF THE INVENTION

本发明针对现有技术中存在的测试用例较长时无法对程序的缺陷进行精确定位,传统精简方法效率低、耗时长的问题,提出了一种Android应用自动化测试用例精简方法。Aiming at the problems existing in the prior art that the defects of the program cannot be accurately located when the test cases are long, and the traditional simplification method is inefficient and time-consuming, the invention proposes an automatic test case simplification method for Android applications.

具体步骤如下:Specific steps are as follows:

步骤一、针对某Android应用程序,根据能触发该应用程序错误的某个测试用例的状态日志,状态信息及迁移关系构建该测试用例的事件序列树;Step 1. For an Android application, build the event sequence tree of the test case according to the state log, state information and migration relationship of a test case that can trigger the application error;

具体构建过程如下:The specific construction process is as follows:

首先、从树的虚拟根节点i=0开始,每有一个新的事件,则建立对应的树节点;First, starting from the virtual root node i=0 of the tree, each time there is a new event, the corresponding tree node is established;

新的事件对应的树节点集合为{i1,i2,i3,...,in,...};The set of tree nodes corresponding to the new event is {i 1 ,i 2 , i 3 ,...,in ,...};

然后,确定新的事件对应的树节点在树中的位置:Then, determine the position of the tree node corresponding to the new event in the tree:

针对新的事件的树节点in,若节点in的状态信息与上一个节点in-1的状态信息相同,则节点in为节点in-1的兄弟节点,两个节点的状态等价;For the tree node in of the new event, if the state information of the node in is the same as the state information of the previous node in -1 , then the node in is the sibling node of the node in -1 , the state of the two nodes, etc. price;

若节点in的状态信息与从根节点i=0到上一个节点in-1的路径中的某一节点im的状态信息相同,则节点in为节点im的兄弟节点;If the state information of the node in is the same as the state information of a certain node im in the path from the root node i = 0 to the previous node in -1 , then the node in is the sibling node of the node im;

若节点in的状态信息与从根节点i=0到上一个节点in-1的路径中的任一节点的状态信息均不相同,则节点in为节点in-1的子节点。If the state information of the node in is different from the state information of any node in the path from the root node i = 0 to the previous node in -1 , the node in is a child node of the node in -1 .

步骤二、事件序列树构建完成后,从事件序列树的根节点的下一层开始遍历,获取事件序列树的当前遍历层次的所有事件的节点集合;Step 2: After the construction of the event sequence tree is completed, start traversing from the next layer of the root node of the event sequence tree, and obtain the node set of all events of the current traversed level of the event sequence tree;

当前遍历层次初始设置为1;The current traversal level is initially set to 1;

步骤三、判断当前遍历层次的节点集合是否为空,如果是,进入步骤六;否则,进入步骤四;Step 3: Determine whether the node set of the current traversal level is empty, if so, go to Step 6; otherwise, go to Step 4;

步骤四、使用层内精简算法对当前遍历层次的节点集合进行精简,获得能触发原Android应用程序错误的最小配置单元;Step 4: Use the in-layer simplification algorithm to simplify the node set of the current traversed layer to obtain the smallest configuration unit that can trigger the error of the original Android application;

具体步骤如下:Specific steps are as follows:

步骤401、针对当前遍历层次的节点集合中的每个节点,统计每个节点对应的子序列块的事件数,并生成公用事件序列;Step 401, for each node in the node set of the current traversal level, count the number of events of the subsequence blocks corresponding to each node, and generate a public event sequence;

子序列块是以该节点为根的整个子树中的所有节点形成的块;A subsequence block is a block formed by all nodes in the entire subtree rooted at this node;

公用事件序列是指当前遍历层次向上的所有层次中所有节点对应的事件进行组合。The common event sequence refers to the combination of events corresponding to all nodes in all levels up to the current traversal level.

步骤402、根据当前遍历层次的节点集合中的节点数,或者每个节点的子序列块的事件数,对当前节点集合中的节点分组,每组作为一个序列块;Step 402, according to the number of nodes in the node set of the current traversal level, or the number of events of the sub-sequence blocks of each node, group the nodes in the current node set, and each group is used as a sequence block;

分组值初始为N=2;The grouping value is initially N=2;

当按节点数进行分组时,尽量让每个序列块中包含的子块数接近;When grouping by the number of nodes, try to keep the number of sub-blocks contained in each sequence block as close as possible;

当按事件数进行分组时,每个序列块中各自包含的总事件数尽量接近。When grouping by number of events, the total number of events contained in each sequence block is as close as possible.

步骤403、依次获取每个序列块,将当前序列块中所有节点对应的事件,或将当前序列块的补集序列块中所有节点对应的事件,分别与公用事件序列中的事件按序合并,作为待测事件序列集合;Step 403: Acquire each sequence block in turn, and merge the events corresponding to all nodes in the current sequence block, or the events corresponding to all nodes in the complement sequence block of the current sequence block, respectively, and the events in the public event sequence are merged in order, as a set of event sequences to be tested;

初始选择第一个待测事件序列作为当前待测事件序列,且待测事件序列集合有两种:不包含当前遍历层次的节点集合中最后一个节点的集合,以及包括当前遍历层次的节点集合中最后一个节点的集合。The first sequence of events to be tested is initially selected as the current sequence of events to be tested, and there are two types of sequence of events to be tested: the set of the last node in the node set that does not include the current traversal level, and the set of nodes that include the current traversal level. The collection of the last node.

步骤404、判断当前待测事件序列中是否包含节点集合中的最后一个节点,如果包含,进入步骤405;否则,进入步骤406;Step 404, determine whether the current sequence of events to be tested includes the last node in the node set, if so, go to step 405; otherwise, go to step 406;

步骤405、判断当前待测事件序列是否出现在失败测试用例集合中,如果未出现,进入步骤407;否则,进入步骤406;Step 405, determine whether the current sequence of events to be tested appears in the set of failed test cases, if not, go to step 407; otherwise, go to step 406;

失败测试用例集合中存储的是在之前的运行中,证明了无法触发原Android应用程序错误的待测事件序列;失败测试用例集合初始为空。The failed test case set stores the sequence of events to be tested that proved that the error of the original Android application could not be triggered in the previous operation; the failed test case set is initially empty.

步骤406、将当前待测事件序列集合直接跳过不执行测试,选择下一个待测事件序列集合,返回步骤404;Step 406, skip the current event sequence set to be tested without executing the test, select the next event sequence set to be tested, and return to step 404;

步骤407、将当前待测事件序列集合对应的脚本传入原Android应用程序测试机运行,判断是否成功触发原Android应用程序错误,如果是,进入步骤408;否则,进入步骤409;Step 407: Transfer the script corresponding to the current event sequence set to be tested to the original Android application testing machine to run, and determine whether the original Android application error is successfully triggered. If so, go to step 408; otherwise, go to step 409;

步骤408、判断当前待测事件序列集合对应的当前遍历层次的节点集合中节点数是否大于1,如果是,重新分组并返回步骤403;否则,当前遍历层次的节点集合不能再分组,得到的节点集合即为最小配置单元。Step 408: Determine whether the number of nodes in the node set of the current traversal level corresponding to the current event sequence set to be tested is greater than 1, if so, regroup and return to step 403; otherwise, the node set of the current traversal level cannot be grouped again, and the obtained node A collection is the smallest unit of configuration.

当前待测事件序列集合为补集序列时,将该待测事件序列对应的当前序列块中的节点合并到一个节点集合;且新一轮的分组数应该在原数值N上减1;否则N的值置为默认值2。When the current sequence of events to be tested is a complementary sequence, the nodes in the current sequence block corresponding to the sequence of events to be tested are merged into a set of nodes; and the number of groups in a new round should be reduced by 1 from the original value N; otherwise, the value of N The value is set to the default value of 2.

步骤409、将当前待测事件序列存储在失败测试用例集合中,并选择下一个待测事件序列集合,返回步骤404;Step 409: Store the current sequence of events to be tested in the set of failed test cases, select the next sequence of events to be tested, and return to step 404;

步骤410、判断所有序列块对应的待测事件序列,以及所有补集对应的待测事件序列,是否均未能触发原Android应用程序错误,且分组值N是否小于节点集合中的节点数,如果是,需要重新设置当前节点集合的分组数N等于:2N与节点集合中节点数两者的较小值;返回步骤403;否则,分组值N等于节点集合中的节点数,得到最小配置单元。Step 410: Determine whether the sequence of events to be tested corresponding to all sequence blocks and the sequence of events to be tested corresponding to all complements fail to trigger the original Android application error, and whether the grouping value N is less than the number of nodes in the node set, if Yes, the grouping number N of the current node set needs to be reset equal to the smaller value of 2N and the number of nodes in the node set; return to step 403; otherwise, the grouping value N is equal to the number of nodes in the node set, and the minimum configuration unit is obtained.

步骤五、根据最小配置单元对事件序列树进行子树裁剪,裁剪后的事件序列树作为新的待精简事件序列树,将当前遍历层次自增1,并返回步骤二;Step 5: Perform subtree clipping on the event sequence tree according to the minimum configuration unit, and use the clipped event sequence tree as a new event sequence tree to be simplified, increment the current traversal level by 1, and return to step two;

步骤六、当前层中获得的节点集合均为空,得到成功触发原Android应用程序错误的最小测试用例的事件序列树。Step 6: The node sets obtained in the current layer are all empty, and the event sequence tree of the smallest test case that successfully triggers the error of the original Android application is obtained.

本发明的优点在于:The advantages of the present invention are:

1)、一种Android应用自动化测试用例精简方法,为程序测试人员精简测试用例,精确定位程序错误提供了极大的方便。1) A method for streamlining test cases for Android application automation, which provides great convenience for program testers to simplify test cases and precisely locate program errors.

2)、一种Android应用自动化测试用例精简方法,相比于传统增量调试方法,提升了很大的效率,对于大多数测试用例,精简的用时可以缩短到传统方法的20%-50%,节省了大量的时间。2), a simplified method of Android application automated test cases, compared with the traditional incremental debugging method, the efficiency is greatly improved. For most test cases, the simplified time can be shortened to 20%-50% of the traditional method, Save a lot of time.

附图说明Description of drawings

图1是本发明Android应用自动化测试用例精简的原理图;Fig. 1 is the schematic diagram of Android application automation test case simplification of the present invention;

图2是本发明一种Android应用自动化测试用例精简方法流程图;Fig. 2 is a flow chart of a method for streamlining Android application automation test cases according to the present invention;

图3是本发明采用的层内精简算法原理示意图;Fig. 3 is the schematic diagram of the principle of the reduction algorithm in the layer adopted by the present invention;

图4是本发明采用的层内精简算法流程示意图;Fig. 4 is the schematic flow chart of the reduction algorithm in the layer adopted by the present invention;

图5-1至5-8是本发明具体实施例的精简示意图;5-1 to 5-8 are simplified schematic diagrams of specific embodiments of the present invention;

图6是本发明选用11个测试用例进采用本方法与传统方法的效果与用时统计表;Fig. 6 is that the present invention selects 11 test cases to adopt the effect and time statistics table of this method and traditional method;

图7是本发明选用11个测试用例采用本方法与传统方法用时对比示意图。FIG. 7 is a schematic diagram showing the time-consuming comparison between the present method and the traditional method using 11 test cases selected by the present invention.

具体实施方式Detailed ways

下面将结合附图和实施示例对本发明作进一步的详细说明。The present invention will be further described in detail below with reference to the accompanying drawings and implementation examples.

本发明基于Android应用的自动化测试技术,为Android应用软件的错误定位及调试工作提供条件;基本原理如图1所示,针对运行在Android系统智能设备上的某个应用程序,在该Android应用程序给定的测试环境下,设计了该应用程序测试用例的精简模型,并提出对测试用例进行精简工作的基于树状层次结构的测试用例精简算法,下文简称层次精简算法。The present invention is based on the automatic testing technology of Android application, which provides conditions for the error location and debugging of Android application software; the basic principle is shown in Figure 1. Under the given test environment, a simplified model of the application test cases is designed, and a tree-like hierarchical structure-based test case reduction algorithm is proposed to simplify the test cases, hereinafter referred to as the hierarchical reduction algorithm.

本精简模型设计的目的是对触发Android应用程序崩溃的测试用例进行精简,尽可能地减少测试用例的尺寸规模,使得精简后的测试用例仍能触发原程序崩溃,也即是,精简后测试用例与原测试用例在测试效果上等价。The purpose of this simplified model design is to simplify the test cases that trigger Android application crashes, reduce the size of the test cases as much as possible, so that the simplified test cases can still trigger the crash of the original program, that is, the simplified test cases It is equivalent to the original test case in terms of test effect.

具体是以触发Android应用程序崩溃的测试用例作为模型的输入,该测试用例在指定的精简策略的作用下递归地产生新测试用例;若新测试用例不在失败测试用例集合中,则对新测试用例进行测试,若测试过程中未检测出Android应用程序错误或检测出的错误与原测试用例的错误不一致,则将该新测试用例添加到失败测试用例集合中,然而,若新测试用例检测出错误与原Android应用程序错误一致,则将其作为新的输入进行新一轮的精简;如此循环处理,直至该新测试用例满足精简策略的输出条件为止。在该模型中,失败测试用例集合的设置,用来存储失败的测试用例,能够减少重复测试以期提高测试用例精简的效率。Specifically, the test case that triggers the crash of the Android application is used as the input of the model, and the test case recursively generates a new test case under the action of the specified reduction strategy; if the new test case is not in the set of failed test cases, the new test case Carry out the test. If the Android application error is not detected during the test or the detected error is inconsistent with the error of the original test case, the new test case is added to the set of failed test cases. However, if the new test case detects an error If the error is consistent with the original Android application, it will be used as a new input for a new round of simplification; this cycle is processed until the new test case satisfies the output conditions of the simplification strategy. In this model, the setting of the set of failed test cases is used to store the failed test cases, which can reduce repeated tests and improve the efficiency of test case reduction.

本发明采用层次精简算法的思想,利用测试用例在执行过程中的状态信息对增量调试算法进行改进,将较为成熟的增量调试技术与层次化思想引入到Android应用测试用例精简领域中,并在此基础上提出并实现了层次精简算法;其核心思想是利用测试用例中事件执行后的等价状态来挖掘事件之间的层次关系,将基于时间的事件序列转化为具有层次结构的事件序列树,然后按层次精简事件序列树的子树集合,以期提高精简效率,其工作流程如图2所示,具体步骤如下:The present invention adopts the idea of hierarchical simplification algorithm, improves the incremental debugging algorithm by using the state information of the test case in the execution process, and introduces the relatively mature incremental debugging technology and hierarchical idea into the field of Android application test case simplification, and On this basis, a hierarchical reduction algorithm is proposed and implemented; its core idea is to use the equivalent state after the event execution in the test case to mine the hierarchical relationship between events, and convert the time-based event sequence into an event sequence with a hierarchical structure. tree, and then simplifies the subtree set of the event sequence tree hierarchically, in order to improve the simplification efficiency. The workflow is shown in Figure 2, and the specific steps are as follows:

步骤一、针对某Android应用程序,根据能触发该应用程序错误的某个测试用例的状态日志,状态信息及迁移关系构建该测试用例的事件序列树;Step 1. For an Android application, build the event sequence tree of the test case according to the state log, state information and migration relationship of a test case that can trigger the application error;

具体构建过程如下:The specific construction process is as follows:

首先、从树的虚拟根节点i=0开始,每有一个新的事件,则建立对应的树节点;First, starting from the virtual root node i=0 of the tree, each time there is a new event, the corresponding tree node is established;

新的事件对应的树节点集合为{i1,i2,i3,...,in,...};The set of tree nodes corresponding to the new event is {i 1 ,i 2 , i 3 ,...,in ,...};

然后,确定新的事件对应的树节点在树中的位置:Then, determine the position of the tree node corresponding to the new event in the tree:

针对新的事件的树节点in,若节点in的状态信息与上一个节点in-1的状态信息相同,则节点in为节点in-1的兄弟节点,两个节点的状态等价;For the tree node in of the new event, if the state information of the node in is the same as the state information of the previous node in -1 , then the node in is the sibling node of the node in -1 , the state of the two nodes, etc. price;

若节点in的状态信息与从根节点i=0到上一个节点in-1的路径中的某一节点im的状态信息相同,则节点in为节点im的兄弟节点;If the state information of the node in is the same as the state information of a certain node im in the path from the root node i = 0 to the previous node in -1 , then the node in is the sibling node of the node im;

若节点in的状态信息与从根节点i=0到上一个节点in-1的路径中的任一节点的状态信息均不相同,则节点in为节点in-1的子节点。If the state information of the node in is different from the state information of any node in the path from the root node i = 0 to the previous node in -1 , the node in is a child node of the node in -1 .

对输入的测试用例的状态日志进行解析,再根据状态等价及其迁移关系构建事件序列树,状态日志,状态信息及迁移关系均是应用运行过程中的某种属性;状态等价信息是在执行测试用例的同时抓取并记录的,以状态等价使用应用运行时的事件或节点的Activity信息的情况为例,测试用例中每有一个事件,就有一个应用响应此事件后对应的Activity信息。节点、事件、Activity信息呈一一对应关系。Analyze the state log of the input test case, and then construct an event sequence tree according to the state equivalence and its migration relationship. The state log, state information and migration relationship are all attributes of the application running process; Captured and recorded while executing the test case, taking the case where the state is equivalent to using the event of the application runtime or the activity information of the node as an example, for each event in the test case, there is an application corresponding to the Activity after the event is responded to. information. Nodes, events, and Activity information are in a one-to-one correspondence.

从树的虚拟根节点i=0开始,对于每一个新的事件i=1,2,3...,则建立一个新的树节点i,并按照该事件的Activity信息确定该节点i在树中的位置:若节点i的Activity与上一个节点i-1的Activity相同,则节点i为节点i-1的兄弟节点;若节点i的Activity与从根节点i=0到上一个节点i-1的路径中的某一节点的Activity相同,则节点i为该某节点的兄弟节点;若节点i的Activity与从根节点i=0到上一个节点i-1的路径中的任一节点的Activity均不相同,则节点i为节点i-1的子节点。Starting from the virtual root node i=0 of the tree, for each new event i=1, 2, 3..., a new tree node i is established, and according to the Activity information of the event, it is determined that the node i is in the tree Position in: If the activity of node i is the same as that of the previous node i-1, then node i is the sibling node of node i-1; If the activity of a node in the path of 1 is the same, then node i is the sibling node of the node; if the activity of node i is the same as that of any node in the path from the root node i=0 to the previous node i-1 Activity is different, then node i is the child node of node i-1.

本发明构建测试用例的事件序列树的方法,保证了:每个节点的子节点均具有相同的Activity信息。由于子树具有封闭性与独立性,即记子树顶节点的Activity为Activity0,则在事件序列达到新的和Activity0相同的Activity前,产生的对应节点均在子树内。反之当事件序列达到了新的和Activity0相同的Activity后,产生的对应节点一定不在上一子树内;这样,保证了进行层内精简算法处理时:1)对每层的节点进行精简尝试时,一层中的节点及对应子树一定是独立的,相对互不相关的。2)以节点及对应子树为单位进行保留或舍去尝试时,最小单位一定是一个封闭的,从同一个子树顶端Activity发出与达到的Activity集合,与对应的事件序列块。做子树裁剪时亦然;保证了层内精简算法是高效的,无遗漏的。The method for constructing the event sequence tree of the test case in the present invention ensures that the child nodes of each node have the same Activity information. Since the subtree is closed and independent, that is, the activity of the top node of the subtree is Activity0, the corresponding nodes generated are all in the subtree before the event sequence reaches a new Activity that is the same as Activity0. Conversely, when the event sequence reaches a new Activity that is the same as Activity0, the corresponding node generated must not be in the previous subtree; in this way, it is ensured that when processing the in-layer reduction algorithm: 1) When trying to reduce the nodes of each layer , the nodes and corresponding subtrees in one layer must be independent and relatively unrelated to each other. 2) When making reservations or discarding attempts in units of nodes and corresponding subtrees, the smallest unit must be a closed, set of Activity emitted and reached from the top Activity of the same subtree, and the corresponding event sequence block. The same is true when doing subtree pruning; it is guaranteed that the reduction algorithm in the layer is efficient and has no omissions.

步骤二、事件序列树构建完成后,从事件序列树的根节点的下一层开始遍历,获取事件序列树的当前遍历层次的所有事件的节点集合;Step 2: After the construction of the event sequence tree is completed, start traversing from the next layer of the root node of the event sequence tree, and obtain the node set of all events of the current traversed level of the event sequence tree;

建树完成后设置当前遍历层次为1,即从事件序列树的根节点的下一层开始遍历;After the tree is built, set the current traversal level to 1, that is, start traversing from the next level of the root node of the event sequence tree;

步骤三、判断当前遍历层次的节点集合是否为空,如果是,进入步骤六;否则,进入步骤四;Step 3: Determine whether the node set of the current traversal level is empty, if so, go to Step 6; otherwise, go to Step 4;

获取事件序列树的当前遍历层次的所有事件的节点集合,若节点集合不为空,则使用层内精简算法对节点集合进行精简,获得能触发原Android应用程序错误的最小配置单元;Obtain the node set of all events in the current traversal level of the event sequence tree. If the node set is not empty, use the in-layer reduction algorithm to reduce the node set to obtain the smallest configuration unit that can trigger the error of the original Android application;

步骤四、使用层内精简算法对当前遍历层次的节点集合进行精简,获得能触发原Android应用程序错误的最小配置单元;Step 4: Use the in-layer simplification algorithm to simplify the node set of the current traversed layer to obtain the smallest configuration unit that can trigger the error of the original Android application;

与增量调试算法相似,层内精简算法是使用系统的“假设—试验—结果”循环进行自动化程序调试的贪婪搜索算法,如图3和图4所示,具体步骤如下:Similar to the incremental debugging algorithm, the intra-layer reduction algorithm is a greedy search algorithm that uses the system's "hypothesis-test-result" cycle for automatic program debugging, as shown in Figure 3 and Figure 4. The specific steps are as follows:

步骤401、针对当前遍历层次的节点集合中的每个节点,统计每个节点对应的子序列块的事件数,并生成公用事件序列;Step 401, for each node in the node set of the current traversal level, count the number of events of the subsequence blocks corresponding to each node, and generate a public event sequence;

公用事件序列是指当前遍历层次向上的所有层次中所有节点对应的事件进行组合;当前遍历层次向上的所有层次是指0层至当前遍历层次-1层;The public event sequence refers to the combination of events corresponding to all nodes in all levels up from the current traversal level; all levels up from the current traversal level refer to level 0 to the current traversal level -1 level;

子序列块是以该节点为根的整个子树中的所有节点形成的块;子序列块中至少有一个元素;对子序列块中的事件进行计数是指对该节点以及该节点的所有子节点对应的事件统计总数。A subsequence block is a block formed by all nodes in the entire subtree rooted at that node; there is at least one element in a subsequence block; counting events in a subsequence block refers to that node and all its children. The total number of event statistics corresponding to the node.

步骤402、根据当前遍历层次的节点集合中的节点数,或者每个节点的子序列块的事件数,对当前节点集合中的节点分组,每组作为一个序列块;Step 402, according to the number of nodes in the node set of the current traversal level, or the number of events of the sub-sequence blocks of each node, group the nodes in the current node set, and each group is used as a sequence block;

根据节点集合中的节点数,或子树中事件数,对节点集合中的节点进行N分组,形成N个序列块,其中N的默认分组值初始为2,每组作为一个序列块;当按节点数进行分组时,分组策略为使N个序列块中各自包含的子块数尽量接近,或当按事件数进行分组时,每个序列块中各自包含的总事件数尽量接近,可依照应用界面特性进行选择。According to the number of nodes in the node set or the number of events in the subtree, the nodes in the node set are grouped by N to form N sequence blocks, where the default grouping value of N is initially 2, and each group is used as a sequence block; When grouping by the number of nodes, the grouping strategy is to make the number of sub-blocks contained in each of the N sequence blocks as close as possible, or when grouping by the number of events, the total number of events contained in each sequence block is as close as possible. interface features to choose from.

针对当前遍历层次中的子序列块中节点分布均匀的情况,选用按节点数进行分组或者按事件数进行分组均可。For the situation that the nodes in the subsequence blocks in the current traversal level are evenly distributed, either grouping by the number of nodes or grouping by the number of events can be selected.

针对当前遍历层次中的子序列块中节点分布,明显后边的子序列块中节点多而前边子序列块中节点少的情况,选用按事件数进行分组。According to the distribution of nodes in the subsequence blocks in the current traversal level, it is obvious that there are many nodes in the subsequence blocks in the back and few nodes in the subsequence blocks in the front.

应用程序中界面间的转移关系会导致建树后节点分布有后多前少的倾向。The transfer relationship between the interfaces in the application program will lead to the tendency of the node distribution after the tree is built.

步骤403、依次获取每个序列块,将当前序列块中所有节点对应的事件,或将当前序列块的补集序列块中所有节点对应的事件,分别与公用事件序列中的事件按序合并,作为待测事件序列集合;Step 403: Acquire each sequence block in turn, and merge the events corresponding to all nodes in the current sequence block, or the events corresponding to all nodes in the complement sequence block of the current sequence block, respectively, and the events in the public event sequence are merged in order, as a set of event sequences to be tested;

按序合并是指合并过程中保证事件序列中的事件有序,实际上序列块中的事件往往是插入到公用事件序列中间的某个位置。Sequential merging refers to ensuring that the events in the event sequence are in order during the merging process. In fact, the events in the sequence block are often inserted into a certain position in the middle of the common event sequence.

待测事件序列的表达形式为根节点以及所有子节点形成的集合,初始选择第一个序列块的待测事件序列作为当前待测事件序列,且待测事件序列集合有两种:不包含当前遍历层次的节点集合中最后一个节点的集合,以及包括当前遍历层次的节点集合中最后一个节点的集合,且待测事件序列不包含节点集合中最后一个节点的序列块或其补集,无需获取后续测试,直接跳过。The expression form of the sequence of events to be tested is the set formed by the root node and all child nodes. Initially, the sequence of events to be tested in the first sequence block is selected as the current sequence of events to be tested, and there are two types of sequence of events to be tested. The set of the last node in the node set of the traversal level, and the set of the last node in the node set of the current traversal level, and the event sequence to be tested does not contain the sequence block of the last node in the node set or its complement, no need to obtain Subsequent tests, skip directly.

补集针对当前序列块而言,补集是指除去当前序列块后剩余的其它所有序列块。Complement For the current sequence block, the complement refers to all other sequence blocks remaining after the current sequence block is removed.

序列块的补集生成的事件序列,仍是一个普通的待测事件序列,与非补集生成的事件序列是平等的。The sequence of events generated by the complement of the sequence block is still a common sequence of events to be tested, which is equal to the sequence of events generated by the non-complement.

若该事件序列为补集,则新一轮的N在数值上等于原N的值减1,否则N的值置为默认值2。If the event sequence is a complement, the value of N in the new round is equal to the value of the original N minus 1, otherwise the value of N is set to the default value of 2.

步骤404、判断当前待测事件序列中是否包含节点集合中的最后一个节点,如果包含,进入步骤405;否则,进入步骤406;Step 404, determine whether the current sequence of events to be tested includes the last node in the node set, if so, go to step 405; otherwise, go to step 406;

步骤405、判断当前待测事件序列是否出现在失败测试用例集合中,如果未出现,进入步骤407;否则,进入步骤406;Step 405, determine whether the current sequence of events to be tested appears in the set of failed test cases, if not, go to step 407; otherwise, go to step 406;

失败测试用例集合中存储的是在之前的运行中,证明了无法触发原Android应用程序错误的待测事件序列;失败测试用例集合初始为空。The failed test case set stores the sequence of events to be tested that proved that the error of the original Android application could not be triggered in the previous operation; the failed test case set is initially empty.

当前待测事件序列未出现在失败测试用例集合中,表明该待测事件序列是未处理过的,而后执行该待测事件序列。The current sequence of events to be tested does not appear in the set of failed test cases, indicating that the sequence of events to be tested has not been processed, and then the sequence of events to be tested is executed.

步骤406、将当前待测事件序列集合直接跳过不执行测试,选择下一个待测事件序列集合,返回步骤404;Step 406, skip the current event sequence set to be tested without executing the test, select the next event sequence set to be tested, and return to step 404;

因未包含最后一个节点而跳过的当前待测事件序列集合不用加入失败测试用例集合,因为事实上所有未包含最后一个节点的待测事件序列集合都会被跳过,失败测试用例集合仅用于保存在之前的运行中,证明了无法触发原Android应用程序错误的待测事件序列集合。The current set of events to be tested that is skipped because it does not contain the last node does not need to be added to the set of failed test cases, because in fact all sets of events to be tested that do not contain the last node will be skipped, and the set of failed test cases is only used for Saved in the previous run, it proves that the sequence of events under test cannot trigger the error of the original Android application.

步骤407、将当前待测事件序列集合对应的脚本传入原Android应用程序测试机运行,判断是否成功触发原Android应用程序错误,如果是,进入步骤408;否则,进入步骤409;Step 407: Transfer the script corresponding to the current event sequence set to be tested to the original Android application testing machine to run, and determine whether the original Android application error is successfully triggered. If so, go to step 408; otherwise, go to step 409;

步骤408、判断当前待测事件序列集合对应的当前遍历层次的节点集合中节点数是否大于1,如果是,重新分组并返回步骤403;否则,当前遍历层次的节点集合不能在分组,得到的节点集合即为最小配置单元。Step 408: Determine whether the number of nodes in the node set of the current traversal level corresponding to the current event sequence set to be tested is greater than 1, if so, regroup and return to step 403; otherwise, the node set of the current traversal level cannot be grouped, and the obtained node A collection is the smallest unit of configuration.

能重新分组的条件是:当前的节点集合中节点数大于1。因为对于非补集分组数是2,节点数大于1就能分组;对于补集分组数是N-1,但是补集的节点集合中节点数肯定是大于等于N-1的,也能分组。The condition for regrouping is: the number of nodes in the current node set is greater than 1. Because the number of non-complement groups is 2, and the number of nodes is greater than 1, it can be grouped; for the number of complement groups is N-1, but the number of nodes in the complement node set must be greater than or equal to N-1, and it can also be grouped.

当前待测事件序列集合为补集序列时,将该待测事件序列对应的当前序列块中的节点合并到一个节点集合;且新一轮的分组数应该在原数值N上减1;否则N的值置为默认值2。When the current sequence of events to be tested is a complementary sequence, the nodes in the current sequence block corresponding to the sequence of events to be tested are merged into a set of nodes; and the number of groups in a new round should be reduced by 1 from the original value N; otherwise, the value of N The value is set to the default value of 2.

步骤409、将当前待测事件序列存储在失败测试用例集合中,并选择下一个待测事件序列集合,返回步骤404;Step 409: Store the current sequence of events to be tested in the set of failed test cases, select the next sequence of events to be tested, and return to step 404;

步骤410、判断所有序列块对应的待测事件序列,以及所有补集对应的待测事件序列,是否均未能触发原Android应用程序错误,且分组值N是否小于节点集合中的节点数,如果是,需要重新设置当前节点集合的分组数N等于:2N与节点集合中节点数两者的较小值;返回步骤403;否则,分组值N等于节点集合中的节点数,得到最小配置单元。Step 410: Determine whether the sequence of events to be tested corresponding to all sequence blocks and the sequence of events to be tested corresponding to all complements fail to trigger the original Android application error, and whether the grouping value N is less than the number of nodes in the node set, if Yes, the grouping number N of the current node set needs to be reset equal to the smaller value of 2N and the number of nodes in the node set; return to step 403; otherwise, the grouping value N is equal to the number of nodes in the node set, and the minimum configuration unit is obtained.

若该事件序列未能成功触发原Android应用程序错误,则将其添加到失败集合中;若事件序列能够触发原Android应用程序错误,则该事件序列是一次成功的精简,作为新一轮的输入进行精简。If the event sequence fails to trigger the original Android application error, it will be added to the failure set; if the event sequence can trigger the original Android application error, the event sequence is a successful streamlining, as a new round of input to simplify.

若N个序列块的事件序列,及其对应的N个补集的事件序列,均未能触发原Android应用程序错误,且N的值小于节点集合中的节点数,则表明原测试用例事件序列还有在进一步更细粒度划分中精简的可能,此时N的值取介于2N与节点集合节点数之中的最小值,以保证新一轮事件序列的有效划分;若N的值与节点集合节点数相等,则表明每个序列块中只包含一个节点及其子树,没有更细粒度划分的可能,此时待精简的事件序列即是层内精简算法作用下获得的能够成功触发原Android应用程序错误的最小事件序列集合,称为最小配置单元,至此该层次下的层内精简算法结束。If the event sequence of N sequence blocks and the corresponding event sequence of N complements fail to trigger the original Android application error, and the value of N is less than the number of nodes in the node set, it indicates that the original test case event sequence There is also the possibility of simplification in further fine-grained division. At this time, the value of N takes the minimum value between 2N and the number of nodes in the node set to ensure the effective division of a new round of event sequences; If the number of set nodes is equal, it means that each sequence block contains only one node and its subtree, and there is no possibility of finer-grained division. At this time, the event sequence to be simplified is the one obtained under the action of the in-layer simplification algorithm that can successfully trigger the original The minimum event sequence set of Android application errors is called the minimum configuration unit, and the in-layer reduction algorithm under this layer ends.

步骤五、根据最小配置单元对事件序列树进行子树裁剪,裁剪后的事件序列树作为新的待精简事件序列树,将当前遍历层次自增1后返回步骤二;Step 5: Perform subtree pruning on the event sequence tree according to the minimum configuration unit, and use the pruned event sequence tree as a new event sequence tree to be simplified, and return to step 2 after increasing the current traversal level by 1;

根据最小配置单元对事件序列树进行子树裁剪,裁剪后的事件序列树作为新的待精简事件序列树,当前遍历层次自增1后重复精简过程。The event sequence tree is trimmed according to the minimum configuration unit, and the trimmed event sequence tree is used as a new event sequence tree to be simplified. The current traversal level is incremented by 1 and the streamlining process is repeated.

步骤六、当前层中获得的节点集合均为空,得到成功触发原Android应用程序错误的最小测试用例的事件序列树。Step 6: The node sets obtained in the current layer are all empty, and the event sequence tree of the smallest test case that successfully triggers the error of the original Android application is obtained.

直到某一层中获得的节点集合为空,此时的事件序列树即为能够成功触发原Android应用程序错误的最小测试用例。Until the node set obtained in a certain layer is empty, the event sequence tree at this time is the smallest test case that can successfully trigger the error of the original Android application.

具体实例:Specific examples:

首先,针对某Android应用程序,根据能触发该应用程序错误的某个测试用例的状态日志,Activity信息及迁移关系构建该测试用例的事件序列树;First, for an Android application, build the event sequence tree of the test case according to the status log, Activity information and migration relationship of a test case that can trigger the application error;

如图5-1到5-8所示,事件序列树的根节点为1,根节点下的子节点分别为:{2,7,17,18,21和22};节点2下的子节点为:{3,4,5和6};节点7下的子节点为:{8-16};节点17下无子节点;节点18下的子节点为{19和20};节点21下无子节点;节点22下的子节点为{23-36}。As shown in Figures 5-1 to 5-8, the root node of the event sequence tree is 1, and the child nodes under the root node are: {2, 7, 17, 18, 21, and 22}; the child nodes under node 2 are: {3, 4, 5 and 6}; the child nodes under node 7 are: {8-16}; there is no child node under node 17; the child nodes under node 18 are {19 and 20}; there is no child node under node 21 Child nodes; the child nodes under node 22 are {23-36}.

从意义上来讲,状态是节点,事件是节点间即状态间的转移关系,因为每次有事件执行应用的状态都有可能改变。为了方便处理,把节点,状态和事件绑定,比如根节点是1,其状态是状态1,对应的事件1连接在根节点1和第一层的节点2之间,表示执行事件1后,应用的状态从状态1变成了状态2。状态i和事件i的关系为:状态i为事件i发生前应用的状态。比如第一次精简去掉了节点{2,7,17}及其子树,保留了{1,18,19-20,21,22,23-36},代表本来从状态1,经过事件1-17到达了状态18,但去除了事件2-17,仅由事件1还是能从状态1到达状态18。In a sense, a state is a node, and an event is a transition relationship between nodes, that is, between states, because the state of the application may change every time an event executes. In order to facilitate processing, the node, state and event are bound. For example, the root node is 1, its state is state 1, and the corresponding event 1 is connected between the root node 1 and the node 2 of the first layer, indicating that after event 1 is executed, The state of the application changes from state 1 to state 2. The relationship between state i and event i is: state i is the state of the application before event i occurs. For example, in the first simplification, the node {2, 7, 17} and its subtrees are removed, and {1, 18, 19-20, 21, 22, 23-36} are retained, which means that the original state 1 passed through the event 1- 17 reaches state 18, but with events 2-17 removed, it is still possible to get from state 1 to state 18 by event 1 alone.

然后,将根节点1的下一层作为第1层进行遍历,得到第1层的所有事件的节点集合{2,7,17,18,21,22}。Then, the next layer of the root node 1 is traversed as the first layer, and the node set {2, 7, 17, 18, 21, 22} of all events of the first layer is obtained.

使用层内精简算法对第1层的节点集合{2,7,17,18,21,22}进行精简,获得最小配置单元;Use the in-layer reduction algorithm to reduce the node set {2, 7, 17, 18, 21, 22} of the first layer to obtain the minimum configuration unit;

具体的层内精简处理如下:The specific intra-layer reduction processing is as follows:

首先,对节点集合{2,7,17,18,21,22}按节点数进行分组,根据节点数划分成两个序列块,分组数N=2,分别为{2,7,17}和{18,21,22};First, the node set {2, 7, 17, 18, 21, 22} is grouped according to the number of nodes, and divided into two sequence blocks according to the number of nodes. The number of groups is N=2, which are {2, 7, 17} and {18, 21, 22};

然后,依次获取序列块生成待测事件序列,第一个序列块{2,7,17}对应的待测事件序列集合{1,2,3-6,7,8-16,17}因不包含节点集合中的最后一个节点22而被跳过;第二个待测事件序列集合为:{1,18,19-20,21,22,23-36};包含节点集合中的最后一个节点22,且没有出现在失败测试用例集合中;Then, the sequence blocks are sequentially acquired to generate the sequence of events to be tested. The sequence of events to be tested {1, 2, 3-6, 7, 8-16, 17} corresponding to the first sequence block {2, 7, 17} Contains the last node 22 in the node set and is skipped; the second event sequence set to be tested is: {1, 18, 19-20, 21, 22, 23-36}; contains the last node in the node set 22, and does not appear in the set of failed test cases;

随后将第二个待测事件序列集合对应的脚本传入原Android应用程序测试机运行,成功触发原Android应用程序错误,精简尝试成功,然后,该节点集合中的节点数{18,21,22}为3个,大于1;要重新分组再次尝试精简;Then, the script corresponding to the second event sequence set to be tested is transferred to the original Android application testing machine to run, the original Android application error is successfully triggered, and the simplification attempt is successful. Then, the number of nodes in the node set is {18, 21, 22 } is 3, greater than 1; to regroup and try to simplify again;

将新的节点集合{18,21,22}重新按节点数进行分组,分组数N=2,基于贪心策略分为序列块{18,21}和序列块{22};依次获取序列块生成待测事件序列分别为:第一个序列块对应的待测事件序列{1,18,19-20,21}因不包含最后一个节点22被跳过;第二个序列块对应的待测事件序列{1,22,23-36}包含最后一个节点22,且没有出现在失败测试用例集合中;随后将该待测事件序列集合对应的脚本传入原Android应用程序测试机运行,执行事件序列结果为成功触发原Android应用程序错误,精简尝试成功;截止目前,第1层的节点集合仅有一个节点{22},不能在继续精简,所以第1层已经达到最简状态;得到的最小配置单元为{22};The new node set {18, 21, 22} is regrouped by the number of nodes, the number of groups is N=2, and is divided into sequence blocks {18, 21} and sequence blocks {22} based on the greedy strategy; sequentially obtain the sequence blocks to generate pending The sequence of events to be tested is: the sequence of events to be tested {1, 18, 19-20, 21} corresponding to the first sequence block is skipped because it does not contain the last node 22; the sequence of events to be tested corresponding to the second sequence block {1, 22, 23-36} includes the last node 22 and does not appear in the set of failed test cases; then the script corresponding to the set of events to be tested is transferred to the original Android application testing machine to run, and the result of the event sequence is executed In order to successfully trigger the original Android application error, the simplification attempt was successful; so far, the node set of the first layer has only one node {22}, which cannot be further reduced, so the first layer has reached the simplest state; the obtained minimum configuration unit is {22};

然后,根据最小配置单元裁剪子树,继续遍历层次增至2后,获取当前遍历层次的所有事件的节点集合,开始重复。Then, cut the subtree according to the minimum configuration unit, continue to traverse the level to 2, obtain the node set of all events of the current traversal level, and start repeating.

第2层的节点集合包括{23-36};根据节点数分2组,获取序列块{23-29}和序列块{30-36},第一个序列块{1,22,23-29}对应的待测事件序列因不包含最后一个节点36而被跳过;第二个待测事件序列集合为序列{1,22,30-36},包含最后一个节点36且出现在失败测试用例集合中是未处理的,将对应的脚本传入原Android应用程序测试机运行,执行结果为并未成功触发原Android应用程序错误。The node set of the second layer includes {23-36}; according to the number of nodes, it is divided into 2 groups to obtain sequence blocks {23-29} and sequence blocks {30-36}, the first sequence block {1, 22, 23-29 } The corresponding test event sequence is skipped because it does not contain the last node 36; the second test event sequence set is the sequence {1, 22, 30-36}, which includes the last node 36 and appears in the failed test case The collection is unprocessed, and the corresponding script is passed to the original Android application testing machine to run, and the execution result is that the original Android application error was not successfully triggered.

此时,将{1,22,30-36}存储在失败测试用例集合中,判断所有序列块{23-29}和序列块{30-36}对应的待测事件序列,以及所有补集对应的待测事件序列,均未能触发原Android应用程序错误,且N=2,小于节点集合中的节点数,需要对当前遍历层次的节点集合{23-36}重新设置分组数N=4后再次尝试精简。At this time, {1, 22, 30-36} is stored in the failed test case set, and the sequence of events to be tested corresponding to all sequence blocks {23-29} and sequence blocks {30-36}, as well as the corresponding The sequence of events to be tested fails to trigger the original Android application error, and N=2, which is less than the number of nodes in the node set, it is necessary to reset the grouping number N=4 for the node set {23-36} of the current traversal level. Try parsing again.

第2层的节点集合包括{23-36},分为4组{23-26},{27-29},{30-33}和{34-36};The node set of layer 2 includes {23-36}, which is divided into 4 groups {23-26}, {27-29}, {30-33} and {34-36};

然后,依次获取序列块或其补集,生成待测事件序列,分别为序列块4的事件序列{1,22,34-36},序列块4的补集,序列块3的事件序列{1,22,30-33},序列块3的补集的事件序列{1,22,23-29,34-36}等。实际测试过程中,从最后一个待测试事件序列{1,22,34-36}开始选取,依次进行测试;Then, sequentially acquire sequence blocks or their complements to generate the sequence of events to be tested, which are the event sequence {1, 22, 34-36} of sequence block 4, the complement of sequence block 4, and the event sequence {1 of sequence block 3, respectively , 22, 30-33}, the sequence of events for the complement of sequence block 3 {1, 22, 23-29, 34-36}, etc. In the actual test process, select from the last sequence of events to be tested {1, 22, 34-36}, and test in sequence;

待测事件序列集合为序列{1,22,34-36},包含最后一个节点36且未出现在失败测试用例集合中,将对应的脚本传入原Android应用程序测试机运行,执行结果为并未成功触发原Android应用程序错误;将待测事件序列集合为序列{1,22,34-36}存储在失败测试用例集合中;序列块4的补集未包含最后一个节点36被跳过,序列块3{1,22,30-33}未包含最后一个节点36被跳过;待测事件序列为序列块3的补集的事件序列{1,22,23-29,34-36}时,包含节点集合中的最后一个节点36,且未出现在失败测试用例集合中,将对应的脚本传入原Android应用程序测试机执行测试时,并成功触发原Android应用程序错误;The sequence set of events to be tested is the sequence {1, 22, 34-36}, which includes the last node 36 and does not appear in the set of failed test cases. The corresponding script is passed to the original Android application test machine to run, and the execution result is parallel. The original Android application error was not successfully triggered; the sequence of events to be tested is set as the sequence {1, 22, 34-36} and stored in the set of failed test cases; the complement of sequence block 4 does not contain the last node 36 is skipped, Sequence block 3 {1, 22, 30-33} does not contain the last node 36 and is skipped; when the event sequence to be tested is the complement of sequence block 3, the event sequence {1, 22, 23-29, 34-36} , including the last node 36 in the node set, and does not appear in the failed test case set, when the corresponding script is passed to the original Android application test machine to execute the test, and the original Android application error is successfully triggered;

将序列块3的补集的节点集合{23-29,34-36}节点数大于1,重新作为新的节点集合进行精简,因为触发原Android应用程序错误成功的待测事件序列为补集序列,所以新一轮的分组数应该在原数值N=4上减1,变成N=3;新的节点集合{23-29,34-36}分成3个序列块{23-26},{27-29}和{34-36};The number of nodes in the complement set {23-29, 34-36} of sequence block 3 is greater than 1, and it is re-reduced as a new node set, because the sequence of events to be tested that triggers the error of the original Android application successfully is the complement sequence , so the number of groups in a new round should be reduced by 1 from the original value N=4 to become N=3; the new node set {23-29, 34-36} is divided into 3 sequence blocks {23-26}, {27 -29} and {34-36};

同理,待测事件序列集合为序列{1,22,34-36},包含最后一个节点36且出现在失败测试用例集合中,选择序列块{34-36}的补集,未包含最后一个节点36被跳过,序列块{1,22,27-29}未包含最后一个节点36被跳过;待测事件序列为序列块{27-29}的补集的事件序列{1,22,23-26,34-36}时,包含节点集合中的最后一个节点36,且未出现在失败测试用例集合中,将对应的脚本传入原Android应用程序测试机执行测试时,并成功触发原Android应用程序错误;Similarly, the sequence set of events to be tested is the sequence {1, 22, 34-36}, including the last node 36 and appearing in the set of failed test cases, select the complement of the sequence block {34-36}, excluding the last one The node 36 is skipped, and the sequence block {1, 22, 27-29} does not contain the last node 36 to be skipped; the event sequence to be tested is the complement of the sequence block {27-29}. 23-26, 34-36}, including the last node 36 in the node set, and does not appear in the failed test case set, the corresponding script is passed to the original Android application test machine to execute the test, and the original Android application test machine is successfully triggered. Android application bug;

则将补集序列块{23-26}和{34-36}中的节点合并作为一个节点集合进行精简,因为触发原Android应用程序错误成功的待测事件序列为补集序列,所以新一轮的分组数应该在原数值N=3上减1,变成N=2;序列块{23-26}和{34-36}分别生成对应的待测事件序列{1,22,23-26} 和{1,22,34-36};Then, the nodes in the complement sequence blocks {23-26} and {34-36} are combined as a node set for streamlining, because the sequence of events to be tested that triggers the original Android application error and success is the complement sequence, so a new round The number of groups should be reduced by 1 from the original value N=3 to become N=2; the sequence blocks {23-26} and {34-36} generate the corresponding test event sequences {1, 22, 23-26} and {1, 22, 34-36};

同理,待测事件序列集合为序列{1,22,34-36},出现在失败测试用例集合中,序列块{1,22,23-26}未包含最后一个节点36被跳过;所以,所有序列块{23-26}和{34-36}对应的待测事件序列均未能触发原Android应用程序错误,分组值2小于节点集合中的节点数,则重新设置分组数2N=4;Similarly, the sequence set of events to be tested is the sequence {1, 22, 34-36}, which appears in the set of failed test cases, and the sequence block {1, 22, 23-26} does not contain the last node 36 and is skipped; so , the sequence of events to be tested corresponding to all sequence blocks {23-26} and {34-36} failed to trigger the original Android application error, and the grouping value 2 is less than the number of nodes in the node set, then reset the grouping number 2N=4 ;

则将第2层的节点集合中的节点数{23-26,34-36}分组,分组数N=4;分成4个序列块{23-24},{25-26},{34-35}和{36};Then the number of nodes {23-26, 34-36} in the node set of the second layer is grouped, and the number of groups is N=4; it is divided into 4 sequence blocks {23-24}, {25-26}, {34-35 } and {36};

依次获取序列块或其补集,生成待测事件序列,分别为序列块4的事件序列{1,22,36},不能成功触发原Android应用程序错误;序列块4的补集被跳过,序列块3被跳过,序列块3的补集的事件序列{1,22,23-26,36},包含节点集合中的最后一个节点36,且未出现在失败测试用例集合中,对应的脚本传入原Android应用程序测试机运行,成功触发原Android应用程序错误;Obtain the sequence blocks or their complements in turn, and generate the sequence of events to be tested, which are the event sequences {1, 22, 36} of sequence block 4, which cannot successfully trigger the original Android application error; the complement of sequence block 4 is skipped, Sequence block 3 is skipped, and the event sequence {1, 22, 23-26, 36} of the complement of sequence block 3, including the last node 36 in the node set, and does not appear in the set of failed test cases, the corresponding The script is passed to the original Android application test machine to run, and the original Android application error is successfully triggered;

将序列块{34-35}的补集的节点集合{23-26,36}大于1,需要合并为新的节点集合,并重新分组进行精简。因为是补集序列触发原Android应用程序错误,所以新一轮的分组数N=3;{23,24},{25,26}和{36};If the node set {23-26, 36} of the complement of the sequence block {34-35} is greater than 1, it needs to be merged into a new node set and regrouped for simplification. Because it is the complement sequence that triggers the error of the original Android application, the number of groups in a new round is N=3; {23, 24}, {25, 26} and {36};

依次获取序列块或其补集,生成待测事件序列,分别为序列块{36}的事件序列{1,22,36}在失败测试用例集合中,序列块{36}的补集被跳过,序列块{25,26}未包含最后节点36被跳过,序列块{25,26}的补集的事件序列{1,22,23-24,36},包含最后节点36,未出现在失败测试用例集合中,将{1,22,23-24,36}对应的脚本传入原Android应用程序测试机运行,成功触发原Android应用程序错误;Obtain sequence blocks or their complements in turn, and generate a sequence of events to be tested, which are event sequences {1, 22, 36} of sequence block {36}. In the set of failed test cases, the complement of sequence block {36} is skipped , the sequence block {25, 26} does not contain the last node 36 is skipped, the sequence of events {1, 22, 23-24, 36} of the complement of the sequence block {25, 26}, containing the last node 36, does not appear in In the failed test case set, the script corresponding to {1, 22, 23-24, 36} is passed to the original Android application test machine to run, and the original Android application error is successfully triggered;

序列块{25,26}的补集的节点集合{23-24,36}节点数大于1,重新作为新的节点集合,分组进行精简。因为是补集序列触发原Android应用程序错误,所以新一轮的分组数N=2;{23,24}和{36};If the number of nodes in the node set {23-24, 36} of the complement of the sequence block {25, 26} is greater than 1, it is re-used as a new node set, and the grouping is simplified. Because it is the complement sequence that triggers an error in the original Android application, the number of groups in a new round is N=2; {23, 24} and {36};

从最后一个序列块{36}开始选取,当所有的待测试事件{1,22,36}在失败测试用例集合中,{1,22,23-24}未包含最后一个节点36;故所有序列块均没有成功触发原Android应用程序错误,且N此时为2小于节点集合中的节点数,则重新设置N的值等于:4和节点集合中节点数两者的较小值,因为此时{23-24,36}中的元素为3,所以将N设置为3;对第2层的节点集合中的节点数进一步更细粒度的精简划分;Starting from the last sequence block {36}, when all the events to be tested {1, 22, 36} are in the set of failed test cases, {1, 22, 23-24} does not contain the last node 36; therefore, all sequences If the block fails to trigger the original Android application error, and N is 2 at this time less than the number of nodes in the node set, then reset the value of N equal to the smaller value of 4 and the number of nodes in the node set, because at this time The element in {23-24, 36} is 3, so N is set to 3; the number of nodes in the node set of the second layer is further fine-grained and simplified;

第2层的节点集合为{23,24,36},分成3组,则形成3个序列块:{23},{24}和{36}对应生成的待测事件序列为{1,22,36}和补集{1,22,23,24},{1,22,24}和补集{1,22,23,36};{1,22,23}和补集{1,22,24,36};The node set of the second layer is {23, 24, 36}, which are divided into 3 groups to form 3 sequence blocks: {23}, {24} and {36} correspond to the generated sequence of events to be tested as {1, 22, 36} and complement {1, 22, 23, 24}, {1, 22, 24} and complement {1, 22, 23, 36}; {1, 22, 23} and complement {1, 22, 24, 36};

待测事件序列为{1,22,36}存在失败的测试用例集合中,补集{1,22,23,24}未包含最后一个节点36跳过;{1,22,24}未包含最后一个节点36跳过;补集{1,22,23,36}包含最后一个节点36未出现在失败的测试用例集合中,将对应的脚本传入原Android应用程序测试机运行,成功触发原Android应用程序错误;所以,将序列块{24}的补集的节点集合{23,36}作为新的节点集合,大于1重新分组进行精简。The sequence of events to be tested is {1, 22, 36} in the set of failed test cases, the complement {1, 22, 23, 24} does not include the last node 36 to skip; {1, 22, 24} does not include the last One node 36 is skipped; the complement {1, 22, 23, 36} contains the last node 36 that does not appear in the failed test case set, and the corresponding script is passed to the original Android application test machine to run, and the original Android application is successfully triggered. Application error; therefore, the node set {23, 36} of the complement of the sequence block {24} is used as a new node set, which is greater than 1 and regrouped for reduction.

因为是补集序列触发原Android应用程序错误,所以新一轮的分组数N=2;序列块{23}和序列块{36};Because it is the complement sequence that triggers the error of the original Android application, the number of groups in a new round is N=2; sequence block {23} and sequence block {36};

从最后一个序列块{36}开始选取,序列块{36}的待测事件序列{1,22,36}已经出现在失败集合中,将序列块{23}的待测事件序列{1,22,36}对应的脚本传入原Android应用程序测试机运行,没有成功触发原Android应用程序错误,此时N的值为2,等于节点集合中的节点数,表明该层次已没有更细粒度精简的可能,所以第2层已经达到最简状态,得到的最小配置单元为{23,36}。Starting from the last sequence block {36}, the sequence of events to be tested {1, 22, 36} of sequence block {36} has already appeared in the failure set, and the sequence of events to be tested {1, 22 of sequence block {23} , 36} The corresponding script is passed to the original Android application test machine to run, and the original Android application error is not successfully triggered. At this time, the value of N is 2, which is equal to the number of nodes in the node set, indicating that the level has not been more fine-grained and simplified is possible, so the second layer has reached the simplest state, and the obtained minimum configuration unit is {23, 36}.

然后,根据最小配置单元裁剪子树,继续遍历层次增至3后开始重复,因为树中没有第三层节点,化简过程结束,得到成功触发原Android应用程序错误的最小测试用例的事件序列树{1,22,23,36};Then, cut the subtree according to the minimum configuration unit, continue to traverse the level to 3 and start repeating, because there is no third-level node in the tree, the simplification process ends, and the event sequence tree of the minimum test case that successfully triggers the original Android application error is obtained. {1, 22, 23, 36};

按将最小测试用例的事件序列树生成事件序列脚本,进行保存。Generate an event sequence script from the event sequence tree of the smallest test case and save it.

按照本发明的自动化精简方法,将原长度36的事件序列精简到了长度仅为4的结果,并保证这一精简后的事件序列仍能触发与原序列相同的程序错误。这一精简方法是普遍适用的,对于长度达到1000以上的事件序列,也可以达到很好的效果,得到仅保留个位数个事件的可以触发同样错误的事件序列。According to the automatic reduction method of the present invention, the event sequence with the original length of 36 is reduced to a result with a length of only 4, and it is ensured that the reduced event sequence can still trigger the same program error as the original sequence. This simplification method is generally applicable. For event sequences with a length of more than 1000, it can also achieve good results, and obtain event sequences that only retain single-digit events and can trigger the same error.

与其他领域的测试用例相比,Android应用程序的测试用例具有其特殊性,它是有序事件的集合,每一个事件代表一次用户操作。本发明通过有策略地删除原测试用例中的一个事件或多个连续的事件来产生一系列变异体测试用例。在变异体程序集合中,包含未定义行为的或不能触发原有错误的变异体测试用例被认为是不成功的变异体,标记后将会被丢弃;能够触发原有错误的成功的变异体将会被作为新的输入进行下一次的精简。Compared with the test cases in other fields, the test cases of Android applications have its particularity, it is a collection of ordered events, each event represents a user operation. The present invention generates a series of variant test cases by strategically deleting one event or a plurality of consecutive events in the original test case. In the variant program set, variant test cases that contain undefined behavior or cannot trigger the original error are considered as unsuccessful variants and will be discarded after being marked; successful variants that can trigger the original error will be considered as unsuccessful variants. will be used as a new input for the next reduction.

本发明的层次精简算法是对层次化增量调试在Android应用测试用例领域的应用与改进。由于Android应用测试用例是基于时间顺序的事件序列,无明显层次结构,而其用户界面具有一定的层次性。层次精简算法通过记录的每个事件的执行后的用户界面状态来构建事件序列的树形层次结构,然后按层次使用层内精简算法,通过删除待精简的测试用例中的一个事件或多个连续的事件子树来产生一系列变异体测试用例。The hierarchical reduction algorithm of the present invention is the application and improvement of hierarchical incremental debugging in the field of Android application test cases. Because the Android application test case is a sequence of events based on time sequence, there is no obvious hierarchical structure, and its user interface has a certain level of hierarchy. The hierarchical reduction algorithm builds a tree-like hierarchy of event sequences by recording the user interface state after the execution of each event, and then uses the intra-layer reduction algorithm hierarchically to delete one event or multiple consecutive events in the test case to be reduced. event subtree to generate a series of variant test cases.

通过对Android应用DalvikExplorer一历史版本的测试,测试对象为11个由Monkey随机生成的能触发程序崩溃的事件序列;如图6所示,触发崩溃的错误类型如第三列,精简前测试用例中的事件数如第四列,使用本发明精简方法精简后结果中的事件数如第五列,两者事件数之比如第六列,可以看出精简过程对序列的长度有极大的缩短。第七八、九十、十一十二列分别为作为对照的传统增量调试方法、本方法中均匀分组即按节点数进行分组方案、本方法中非均匀分组即按事件数进行分组方案的用时情况。为方便对比,对于用时信息另绘制折线图如图7所示,横轴为11个测试事件序列,纵轴为三种方法的处理用时(单位秒)。可以看出本方法中的均匀分组方案与非均匀分组方案均在用时上相较传统方法有较大的缩短,使用本方法对测试用例进行精简,可以大幅提升处理效率。Through the test of a historical version of the Android application DalvikExplorer, the test object is 11 event sequences randomly generated by Monkey that can trigger the program crash; as shown in Figure 6, the error type that triggers the crash is shown in the third column. The number of events is shown in the fourth column, the number of events in the result after the reduction method of the present invention is reduced, such as the fifth column, and the number of events between the two is shown in the sixth column. It can be seen that the reduction process greatly shortens the length of the sequence. The seventh, eighth, ninetieth, eleventh and twelve columns are respectively the traditional incremental debugging method as a comparison, the uniform grouping in this method is the grouping scheme according to the number of nodes, and the non-uniform grouping in this method is the grouping scheme according to the number of events. time usage. For the convenience of comparison, another line graph is drawn for the time information, as shown in Figure 7. The horizontal axis is the 11 test event sequences, and the vertical axis is the processing time (unit: second) of the three methods. It can be seen that both the uniform grouping scheme and the non-uniform grouping scheme in this method can greatly shorten the time compared with the traditional method. Using this method to simplify the test cases can greatly improve the processing efficiency.

Claims (4)

1.一种Android应用自动化测试用例精简方法,其特征在于,具体步骤如下:1. an Android application automation test case reduction method, is characterized in that, concrete steps are as follows: 步骤一、针对某Android应用程序,根据能触发该应用程序错误的某个测试用例的状态日志,状态信息及迁移关系构建该测试用例的事件序列树;Step 1. For an Android application, build the event sequence tree of the test case according to the state log, state information and migration relationship of a test case that can trigger the application error; 步骤二、事件序列树构建完成后,从事件序列树的根节点的下一层开始遍历,获取事件序列树的当前遍历层次的所有事件的节点集合;Step 2: After the construction of the event sequence tree is completed, start traversing from the next layer of the root node of the event sequence tree, and obtain the node set of all events of the current traversed level of the event sequence tree; 当前遍历层次初始设置为1;The current traversal level is initially set to 1; 步骤三、判断当前遍历层次的节点集合是否为空,如果是,进入步骤六;否则,进入步骤四;Step 3: Determine whether the node set of the current traversal level is empty, if so, go to Step 6; otherwise, go to Step 4; 步骤四、使用层内精简算法对当前遍历层次的节点集合进行精简,获得能触发原Android应用程序错误的最小配置单元;Step 4: Use the in-layer simplification algorithm to simplify the node set of the current traversed layer to obtain the smallest configuration unit that can trigger the error of the original Android application; 步骤五、根据最小配置单元对事件序列树进行子树裁剪,裁剪后的事件序列树作为新的待精简事件序列树,将当前遍历层次自增1,并返回步骤二;Step 5: Perform subtree clipping on the event sequence tree according to the minimum configuration unit, and use the clipped event sequence tree as a new event sequence tree to be simplified, increment the current traversal level by 1, and return to step two; 步骤六、当前层中获得的节点集合均为空,得到成功触发原Android应用程序错误的最小测试用例的事件序列树。Step 6: The node sets obtained in the current layer are all empty, and the event sequence tree of the smallest test case that successfully triggers the error of the original Android application is obtained. 2.根据权利要求1所述的一种Android应用自动化测试用例精简方法,其特征在于,所述的步骤一中,事件序列树的构建过程如下:2. a kind of Android application automation test case reduction method according to claim 1, is characterized in that, in described step 1, the construction process of event sequence tree is as follows: 首先、从树的虚拟根节点i=0开始,每有一个新的事件,则建立对应的树节点;First, starting from the virtual root node i=0 of the tree, each time there is a new event, the corresponding tree node is established; 新的事件对应的树节点集合为{i1,i2,i3,...,in,...};The set of tree nodes corresponding to the new event is {i 1 ,i 2 , i 3 ,...,in ,...}; 然后,确定新的事件对应的树节点在树中的位置:Then, determine the position of the tree node corresponding to the new event in the tree: 针对新的事件的树节点in,若节点in的状态信息与上一个节点in-1的状态信息相同,则节点in为节点in-1的兄弟节点,两个节点的状态等价;For the tree node in of the new event, if the state information of the node in is the same as the state information of the previous node in -1 , then the node in is the sibling node of the node in -1 , the state of the two nodes, etc. price; 若节点in的状态信息与从根节点i=0到上一个节点in-1的路径中的某一节点im的状态信息相同,则节点in为节点im的兄弟节点;If the state information of the node in is the same as the state information of a certain node im in the path from the root node i = 0 to the previous node in -1 , then the node in is the sibling node of the node im; 若节点in的状态信息与从根节点i=0到上一个节点in-1的路径中的任一节点的状态信息均不相同,则节点in为节点in-1的子节点。If the state information of the node in is different from the state information of any node in the path from the root node i = 0 to the previous node in -1 , the node in is a child node of the node in -1 . 3.根据权利要求1所述的一种Android应用自动化测试用例精简方法,其特征在于,所述的步骤四具体如下:3. a kind of Android application automation test case reduction method according to claim 1, is characterized in that, described step 4 is as follows: 步骤401、针对当前遍历层次的节点集合中的每个节点,统计每个节点对应的子序列块的事件数,并生成公用事件序列;Step 401, for each node in the node set of the current traversal level, count the number of events of the subsequence blocks corresponding to each node, and generate a public event sequence; 子序列块是以该节点为根的整个子树中的所有节点形成的块;A subsequence block is a block formed by all nodes in the entire subtree rooted at this node; 公用事件序列是指当前遍历层次向上的所有层次中所有节点对应的事件进行组合;Common event sequence refers to the combination of events corresponding to all nodes in all levels up to the current traversal level; 步骤402、根据当前遍历层次的节点集合中的节点数,或者每个节点的子序列块的事件数,对当前节点集合中的节点分组,每组作为一个序列块;Step 402, according to the number of nodes in the node set of the current traversal level, or the number of events of the sub-sequence blocks of each node, group the nodes in the current node set, and each group is used as a sequence block; 分组值初始为N=2;The grouping value is initially N=2; 当按节点数进行分组时,让每个序列块中包含的子序列块数接近;When grouping by the number of nodes, make the number of subsequence blocks contained in each sequence block close; 当按事件数进行分组时,每个序列块中各自包含的总事件数接近;When grouped by the number of events, the total number of events contained in each sequence block is close to each other; 步骤403、依次获取每个序列块,将当前序列块中所有节点对应的事件,或将当前序列块的补集序列块中所有节点对应的事件,分别与公用事件序列中的事件按序合并,作为待测事件序列集合;Step 403: Acquire each sequence block in turn, and merge the events corresponding to all nodes in the current sequence block, or the events corresponding to all nodes in the complement sequence block of the current sequence block, respectively, and the events in the public event sequence are merged in order, as a set of event sequences to be tested; 初始选择第一个待测事件序列作为当前待测事件序列,且待测事件序列集合有两种:不包含当前遍历层次的节点集合中最后一个节点的集合,以及包括当前遍历层次的节点集合中最后一个节点的集合;The first sequence of events to be tested is initially selected as the current sequence of events to be tested, and there are two types of sequence of events to be tested: the set of the last node in the node set that does not include the current traversal level, and the set of nodes that include the current traversal level. The collection of the last node; 步骤404、判断当前待测事件序列中是否包含节点集合中的最后一个节点,如果包含,进入步骤405;否则,进入步骤406;Step 404, determine whether the current sequence of events to be tested includes the last node in the node set, if so, go to step 405; otherwise, go to step 406; 步骤405、判断当前待测事件序列是否出现在失败测试用例集合中,如果未出现,进入步骤407;否则,进入步骤406;Step 405, determine whether the current sequence of events to be tested appears in the set of failed test cases, if not, go to step 407; otherwise, go to step 406; 失败测试用例集合中存储的是在之前的运行中,证明了无法触发原Android应用程序错误的待测事件序列;失败测试用例集合初始为空;The failed test case collection stores the sequence of events to be tested that proved that the original Android application error could not be triggered in the previous operation; the failed test case collection is initially empty; 步骤406、将当前待测事件序列集合直接跳过不执行测试,选择下一个待测事件序列集合,返回步骤404;Step 406, skip the current event sequence set to be tested without executing the test, select the next event sequence set to be tested, and return to step 404; 步骤407、将当前待测事件序列集合对应的脚本传入原Android应用程序测试机运行,判断是否成功触发原Android应用程序错误,如果是,进入步骤408;否则,进入步骤409;Step 407: Transfer the script corresponding to the current event sequence set to be tested to the original Android application testing machine to run, and determine whether the original Android application error is successfully triggered. If so, go to step 408; otherwise, go to step 409; 步骤408、判断当前待测事件序列集合对应的当前遍历层次的节点集合中节点数是否大于1,如果是,重新分组并返回步骤403;否则,当前遍历层次的节点集合不能再分组,得到的节点集合即为最小配置单元;Step 408: Determine whether the number of nodes in the node set of the current traversal level corresponding to the current event sequence set to be tested is greater than 1, if so, regroup and return to step 403; otherwise, the node set of the current traversal level cannot be grouped again, and the obtained node A collection is the smallest configuration unit; 当前待测事件序列集合为补集序列块时,将该待测事件序列对应的当前序列块中的节点合并到一个节点集合;且新一轮的分组数应该在原数值N上减1;否则N的值置为默认值2;When the current sequence of events to be tested is a complementary sequence block, the nodes in the current sequence block corresponding to the sequence of events to be tested are merged into a node set; and the number of groups in a new round should be decremented by 1 from the original value N; otherwise, N The value is set to the default value of 2; 步骤409、将当前待测事件序列存储在失败测试用例集合中,并选择下一个待测事件序列集合,返回步骤404;Step 409: Store the current sequence of events to be tested in the set of failed test cases, select the next sequence of events to be tested, and return to step 404; 步骤410、判断所有序列块对应的待测事件序列,以及所有补集序列块对应的待测事件序列,是否均未能触发原Android应用程序错误,且分组值N是否小于节点集合中的节点数,如果是,需要重新设置当前节点集合的分组数N等于:2N与节点集合中节点数两者的较小值;返回步骤403;否则,分组值N等于节点集合中的节点数,得到最小配置单元。Step 410: Determine whether the sequence of events to be tested corresponding to all sequence blocks and the sequence of events to be tested corresponding to all complementary sequence blocks fail to trigger the original Android application error, and whether the grouping value N is less than the number of nodes in the node set , if yes, the grouping number N of the current node set needs to be reset equal to: 2N and the smaller value of the number of nodes in the node set; return to step 403; otherwise, the grouping value N is equal to the number of nodes in the node set, and the minimum configuration is obtained unit. 4.根据权利要求1所述的一种Android应用自动化测试用例精简方法,其特征在于,所述的步骤402中,针对当前遍历层次中的子序列块中节点分布均匀的情况,选用按节点数进行分组或者按事件数进行分组;4. a kind of Android application automation test case simplification method according to claim 1, is characterized in that, in described step 402, for the situation that the nodes in the subsequence blocks in the current traversal hierarchy are evenly distributed, select according to the number of nodes Grouping or grouping by the number of events; 针对当前遍历层次中的子序列块中节点分布,明显后边的子序列块中节点多而前边子序列块中节点少的情况,选用按事件数进行分组。According to the distribution of nodes in the subsequence blocks in the current traversal level, it is obvious that there are many nodes in the subsequence blocks in the back and few nodes in the subsequence blocks in the front.
CN201710034953.3A 2017-01-17 2017-01-17 A simplified method of automated test cases for Android applications Active CN106909503B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710034953.3A CN106909503B (en) 2017-01-17 2017-01-17 A simplified method of automated test cases for Android applications

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710034953.3A CN106909503B (en) 2017-01-17 2017-01-17 A simplified method of automated test cases for Android applications

Publications (2)

Publication Number Publication Date
CN106909503A CN106909503A (en) 2017-06-30
CN106909503B true CN106909503B (en) 2020-08-18

Family

ID=59207160

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710034953.3A Active CN106909503B (en) 2017-01-17 2017-01-17 A simplified method of automated test cases for Android applications

Country Status (1)

Country Link
CN (1) CN106909503B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11093379B2 (en) 2019-07-22 2021-08-17 Health Care Service Corporation Testing of complex data processing systems

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101788907A (en) * 2010-01-04 2010-07-28 北京航空航天大学 Automatic generation method for combination service simplified test case and device therefor
CN102193858A (en) * 2010-03-02 2011-09-21 中国科学院软件研究所 Test case set generation method

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101788907A (en) * 2010-01-04 2010-07-28 北京航空航天大学 Automatic generation method for combination service simplified test case and device therefor
CN102193858A (en) * 2010-03-02 2011-09-21 中国科学院软件研究所 Test case set generation method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
Minimizing GUI Event Traces;LAZARO,Clapp 等;《FSE 2016: Proceedings of the 2016 24th ACM SIGSOFT International Symposium on Foundations of Software》;20161118;全文 *

Also Published As

Publication number Publication date
CN106909503A (en) 2017-06-30

Similar Documents

Publication Publication Date Title
Kwiatkowska et al. Probabilistic symbolic model checking with PRISM: A hybrid approach
US11461195B2 (en) Query fault processing method and processing apparatus
US9367428B2 (en) Transparent performance inference of whole software layers and context-sensitive performance debugging
EP2609501B1 (en) Dynamic calculation of sample profile reports
CN105512036A (en) Test template for automatically generating test case according to preset rules and test method
CN105824746A (en) Method and device for automatically generating test scheduling based on use case dependencies
CN106909503B (en) A simplified method of automated test cases for Android applications
CN113269530A (en) Method, device and equipment for reversely generating WBS structure and summarizing construction cost
CN103077080B (en) Based on parallel program performance collecting method and the device of high performance platform
CN112612597B (en) Method and device for generating linear task queue
CN109783274A (en) A kind of management method of disk snapshot, device and readable storage medium storing program for executing
CN114327495A (en) AST-based abnormal acquisition code injection method, device and application thereof
CN108897569A (en) The method for cleaning and computer readable storage medium of iOS engineering discarded record
CN113420520A (en) Integrated circuit device design simulation method, device, apparatus and readable storage medium
CN105824758A (en) Heap area object comparison method based on execution index and access path
US9934035B2 (en) Device and method for tracing updated predicate values
CN113886342A (en) File format conversion method and device, storage medium and processor
CN115328865A (en) Batch import method of CSV files and related equipment
CN102799517B (en) Rapid circulating expansion detection method
CN112131209A (en) Hive-based Flume data verification statistical method and device
CN113157266B (en) Script operation implementation method of Jmeter tool
CN114896095B (en) Abnormal impact analysis method, device, computer equipment and storage medium
Berg An Algorithm for k-insertion into a Binary Heap
CN112329281B (en) File error checking method and device, electronic equipment and storage medium
CN112395682B (en) Cell inheritance method and device of grid model, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant