CN106649103B - A kind of method and system of Android application program Automated Black Box Testing - Google Patents

A kind of method and system of Android application program Automated Black Box Testing Download PDF

Info

Publication number
CN106649103B
CN106649103B CN201611056866.XA CN201611056866A CN106649103B CN 106649103 B CN106649103 B CN 106649103B CN 201611056866 A CN201611056866 A CN 201611056866A CN 106649103 B CN106649103 B CN 106649103B
Authority
CN
China
Prior art keywords
window
task
control
android application
node
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
CN201611056866.XA
Other languages
Chinese (zh)
Other versions
CN106649103A (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.)
Shenzhen University
Original Assignee
Shenzhen 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 Shenzhen University filed Critical Shenzhen University
Priority to CN201611056866.XA priority Critical patent/CN106649103B/en
Publication of CN106649103A publication Critical patent/CN106649103A/en
Application granted granted Critical
Publication of CN106649103B publication Critical patent/CN106649103B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

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

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)
  • Stored Programmes (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a kind of method and system of Android application program Automated Black Box Testing, when identifying all control informations and target window information in target window, it need to only be parsed when obtaining control information and all control informations can be obtained by the control information document that ADB order obtains, and window information can be directly acquired by ADB order, process is simple;It, can be during automatically generating test case, to Android application widget all standing when automatically generating test case;When automatically generating test script, by being encapsulated to Robotium automated test frame, keyword and test data only need to be added in test case document, can be realized and automatically generate test script, when test data changes, the test data in test case document need to be only modified;The present invention improves the reusability of the degree of automation of test, the coverage rate at interface and test script in the case where not needing program source code.

Description

A kind of method and system of Android application program Automated Black Box Testing
Technical field
The invention belongs to Android application program the field of test technology more particularly to a kind of Android application program to automate black box The method and system of test.
Background technique
Window (window) is that application program is shown in the whole figure interface on device screen, and unique identification works as prezone Face.The factor for causing window to change includes mutual switching between different Activity, difference cloth in the same Activity component Office control display and hide etc..
ADB (Android Debug Bridge) i.e. Android debugs bridge, is one of android system order line Tool can use the connection that ADB realizes Android phone and PC.
APK (Android Package) i.e. Android installation kit.
With the fast development of development of Mobile Internet technology, the exploitation quantity of Android application program is also more and more.To protect The quality of Android application program is demonstrate,proved, application program needs to test it before being formally published to application market.But It is that developer only provides APK application packet to application market, Black-box Testing can only be carried out.Meanwhile Automated Black Box Testing nor Often meet mobile cloud testing service popular recently.Developer need to only upload the APK file of tested application program, so that it may benefit It is tested with the resource of cloud service platform.Therefore, it realizes and Android application program is carried out automatically in the case where passive coding Changing test is significantly.However, in terms of existing methods and techniques still cannot sufficiently meet automation and coverage rate Requirement, the problem of being primarily present includes: to lead to oneself of test first, need to write manually or record test script manually Dynamicization degree is not high;Second, Static Analysis Technology building Activity transition diagram need to be first passed through, not only process is complicated, Er Qiejie Face coverage rate is not high.
Tanzirul Azim et al. propose using the mode analog subscriber of target and depth-first traversal operation with Android application program interacts, and tests to realize application program, concrete implementation process are as follows:
(1) static analysis is carried out to tested application program, constructs the traversal model based on Activity component;
(2) by way of target and depth-first traversal, analog subscriber operation is handed over Android application program Mutually;
(3) test result is generated during traversal.
The shortcomings that technical solution: due to using the traversal model based on Activity component, due to one Activity may include multiple and different window, and the window in the same Activity can mutually switch, be based on There is no the handoff relations really established between display interface in fact for the traversal model of Activity, so that its traversal to GUI It is not enough, to influence interface coverage rate.
Summary of the invention
The purpose of the present invention is to provide a kind of method and system of Android application program Automated Black Box Testing, it is intended to solve The method for the Android application program that certainly prior art provides, needs to write manually or records test script manually, cause to test The degree of automation it is not high, while Static Analysis Technology building Activity transition diagram need to be first passed through, process is complicated, interface covering The not high problem of rate.
The invention is realized in this way a kind of method of Android application program Automated Black Box Testing, the Android application journey The method of sequence Automated Black Box Testing the following steps are included:
Step 1 is identified all in target window by the Android application widget control recognition methods based on ADB order Control information and target window information;
Step 2 automatically generates test case with Android application widget all standing automatic example generation method;
Step 3 reuses test script automatic generation method with RobotiumEx high and automatically generates test script.
Further, step 1 is identified in target window by the Android application widget control recognition methods based on ADB order All control informations and target window information when, control information includes control type, control title and control property, window letter Breath includes Activity title and window Hash codes where window;
All control informations in target window are identified by the Android application widget control recognition methods based on ADB order With target window information the following steps are included:
Step (1) sends dump and adb shell dumpsys window w by ADB respectively to equipment | findstr MCurrent order;
Step (2) obtains the xml text of the window control information on preservation current device screen by executing dump order Part, by executing adb shell dumpsys window w | findstr mCurrent order obtains belonging to current window Activity and window Hash codes;
Step (3), the xml document of acquisition is grabbed on local host, is parsed to it, and front window is worked as in acquisition Activity name and window Hash information belonging to mouthful are added in control information, generate control node listing;
Step (4) re-writes the control node listing of generation in one xml document.
Further, step 2 automatically generates test with Android application widget all standing automatic example generation method When use-case, need to construct the traversal model based on Android application widget, traversal model is a digraph, and node of graph indicates One window node, and the side of figure indicates a simulated action, in the traversal model based on window, window ID (Window Flag it) is used for one window of unique identification, Activity title and window Hash information are saved in window ID, can be led to It crosses and Activity title and window Hash codes is compared respectively to judge whether two windows are identical;Task (Task) can table It is shown as (window ID, movement, control node) such a triple, wherein window ID indicates a movement under this window It executes, movement indicates an operation to be simulated, and control node is indicated to the affiliated control of simulated operation, only when application program is transported After row is performed to the movement on this window and this window, a task is just performed;In window node (Window Node) All information relevant to window are saved, it is all pending including include in corresponding window ID, current window Task formed task list, father node, child list, from starting window node to the path of current window node on hold Translation lists in capable all task lists and current window;Conversion (Transition) is used to indicate one in model Transformational relation, it saves task and window node information, wherein a task in task presentation current window node, and saves Point indicates generated child node after task execution;
Automatically generating test case with Android application widget all standing automatic example generation method includes following step It is rapid:
Step (1) is identified all in target window by the Android application widget control recognition methods based on ADB order Control information and target window information are that each control generates a task according to control type, task list are formed, according to window Message breath generates window ID, and window ID is added in window node;
Step (2) successively takes out a task if the task list of window node is not sky from task list, and Judge whether current window is the window for executing required by task and wanting according to window ID, if it is required window, then directly executes Task is then first restored to window required for current task, then executes task if not required window;
Step (3) judges to execute whether this task rear hatch switches;
Step (4) then judges whether to jump in the window of other application, if jumped to other in case of switching In the window of application, then re-launching applications, circulation step (1), step (2), step (3) are otherwise added to current task In task execution path list, circulation step (1) obtains the window node information after jumping, new window nodal information and works as The task of preceding execution is added in current conversion, current conversion is added in the translation lists of current window node, while handle Previous window node is added to the parent window node of new window node;
Step (5), if there is no switching, circulation step (2), step (3);
Step (6) judges whether current window is to terminate window, that is, any control clicked on this window will not all be cut New window is changed to, a test case is then generated according to task execution path list if it is window is terminated, while deleting and appointing The last one task in business execution route list;
Step (7) judges whether complete application program of traversal, if having stepped through complete application program, entirely Traversing result returns to a window if not traversing complete application program, and recurrence executes the step of front six, from And it realizes and entire application is traversed.
In step (2), it is restored to the process of required window are as follows:
First from the mark of target window required for task execution is obtained in task, application program current window mark is then obtained Knowledge is not processed if target window mark is identical with current window mark, before return operation return is simulated if different One window, then judge whether the window ID after returning is target window mark;It repeats the above process, until finding target window Until mouthful;If the starting window for returning to application program finds target window not yet, obtained from target window node Since the task list executed saved successively execute the task in task list, until running to mesh originating window Mark window.
In step (6), the test case of generation is stored in Excel document, and the content of test case includes that test is used Example title, operating procedure, current Activity title, target Activity title, the relevant information of tested control, operation are crucial Word, result check keyword, input data and anticipated output data field.
Further, it in step 2, is automatically generated with Android application widget all standing automatic example generation method <Activity title, current window screenshot>substitution<Activity title, window Hash codes>when test case, can be used to come only One one Android application widget of mark.
Further, in step 3, test script automatic generation method is reused with RobotiumEx high and automatically generates survey This when of training, the common method for including to Solo class in Robotium frame first is packaged, then by Excel document The middle corresponding keyword of input calls packaged test script generation method, automatically generates test script;
With RobotiumEx high reuse test script automatic generation method automatically generate test script the following steps are included:
Step (1), the common method for including to Solo class in Robotium frame are packaged, and obtain commonly testing foot This generation method;
Step (2) binds corresponding keyword to packaged test script generation method, it is automatic to form RobotiumEx Change test frame;
Step (3) generates Excel test case text with Android application widget all standing automatic example generation method Shelves;
Step (4) adds corresponding test data and keyword in the test case document of generation;
It is related to obtain the corresponding institute of test case for step (5), the test case after reading addition keyword and test data Key word passes sequentially through keyword and calls corresponding test script generation method, is automatic generating test case test script.
Another object of the present invention is to provide a kind of system of Android application program Automated Black Box Testing, which is answered System with programming automation Black-box Testing includes:
Android application widget control identification module based on ADB order, for obtaining the control information and window of current window Message breath, control information include control type, control title and control property, and window information includes Activity where window Claim and window Hash codes;
Android application widget all standing automatic generating test case module, with the Android application window based on ADB order Mouth control identification module is connected, and is used for according to depth-first traversal mode, to peace during automatically generating test case Tall and erect application widget carries out all standing;
RobotiumEx high reuses test script automatically-generating module, with the Android application widget all standing test case Automatically-generating module is connected, and the common method for including to Solo class in Robotium frame is packaged, and by Corresponding keyword is inputted in Excel document and calls packaged test script generation method, automatically generates test script.
The method and system of Android application program Automated Black Box Testing provided by the invention, first by being ordered based on ADB The Android application widget control recognition methods of order identifies all control informations and target window information in target window;Then With Android application widget all standing automatic example generation method, test case is automatically generated;Finally use RobotiumEx high reuses test script automatic generation method, automatically generates test script;Passing through the Android based on ADB order Application widget control recognition methods when identifying all control informations and target window information in target window, is obtaining control Need to only parse when information can be obtained all control informations by the control information document that ADB order obtains, and be ordered by ADB Order can directly acquire window information, and process is simple and saves the time;Using Android application widget all standing test case When automatic generation method automatically generates test case, can during automatically generating test case, to Android application widget into Row all standing;Test script automatic generation method is being reused with RobotiumEx high, when automatically generating test script, by right Robotium automated test frame is packaged, and keyword and test data need to be only added in test case document Realization automatically generates test script, and when test data changes, and need to only modify the test number in test case document According to without modifying test script, to improve the reusability of test script;Invention achieves do not needing journey In the case where sequence source code, improve the degree of automation of test, interface coverage rate and improve test script reusability purpose.
Detailed description of the invention
Fig. 1 is the implementation flow chart of the method for Android application program Automated Black Box Testing provided in an embodiment of the present invention;
Fig. 2 is the implementation flow chart of the Android application widget control identification provided in an embodiment of the present invention based on ADB order;
Fig. 3 is the implementation process of Android application widget all standing automatic generating test case provided in an embodiment of the present invention Figure;
Fig. 4 is the implementation flow chart of SCLICK keyword encapsulation provided in an embodiment of the present invention;
Fig. 5 is the structural block diagram of the system of Android application program Automated Black Box Testing provided in an embodiment of the present invention.
In figure: 51, the Android application widget control identification module based on ADB order;52, all standing of Android application widget is surveyed Example automatically-generating module on probation;53, RobotiumEx high reuses test script automatically-generating module.
Specific embodiment
In order to make the objectives, technical solutions, and advantages of the present invention clearer, with reference to embodiments, to the present invention It is further elaborated.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, it is not used to Limit the present invention.
As shown in Figure 1, the invention is realized in this way, a kind of method of Android application program Automated Black Box Testing should The method of Android application program Automated Black Box Testing the following steps are included:
Step S101 identifies the institute in target window by the Android application widget control recognition methods based on ADB order There are control information and target window information;
Step S102 automatically generates test case with Android application widget all standing automatic example generation method;
Step S103 reuses test script automatic generation method with RobotiumEx high and automatically generates test script.
In embodiments of the present invention, step S101 is known by the Android application widget control recognition methods based on ADB order When all control informations and target window information in other target window, control information includes control type, control title and control Part attribute, window information include Activity title and window Hash codes where window;
As shown in Fig. 2, identifying the institute in target window by the Android application widget control recognition methods based on ADB order Have control information and target window information the following steps are included:
Step (1) sends dump and adb shell dumpsys window w by ADB respectively to equipment | findstr MCurrent order;
Step (2) obtains the xml text of the window control information on preservation current device screen by executing dump order Part, by executing adb shell dumpsys window w | findstr mCurrent order obtains belonging to current window Activity and window Hash codes;
Step (3), the xml document of acquisition is grabbed on local host, is parsed to it, and front window is worked as in acquisition Activity name and window Hash information belonging to mouthful are added in control information, generate control node listing;
Step (4) re-writes the control node listing of generation in one xml document.
In embodiments of the present invention, step S102, with Android application widget all standing automatic example generation method When automatically generating test case, need to construct the traversal model based on Android application widget, traversal model is one oriented Figure, node of graph indicates a window node, and the side of figure indicates a simulated action, in the traversal model based on window, window Mouth mark (Window Flag) is used for one window of unique identification, and Activity title and window are saved in window ID Hash information, can be judged by being compared respectively to Activity title and window Hash codes two windows whether phase Together;Task (Task) is represented by (window ID, movement, control node) such a triple, and wherein window ID indicates One movement executes under this window, and movement indicates an operation to be simulated, and control node is indicated to control belonging to simulated operation Part, only after the movement that application program is run on this window and this window is performed, a task is just performed;Window All information relevant to window are saved in node (Window Node), including corresponding window ID, current window In include all pending tasks formed task list, father node, child list, from starting window node to current The translation lists in all task lists and current window executed on the path of window node;(Transition) is converted to use In indicating a transformational relation in model, it saves task and window node information, wherein task presentation current window section A task in point, and node indicates generated child node after task execution;
As shown in figure 3, automatically generating test case with Android application widget all standing automatic example generation method The following steps are included:
Step (1) is identified all in target window by the Android application widget control recognition methods based on ADB order Control information and target window information are that each control generates a task according to control type, task list are formed, according to window Message breath generates window ID, and window ID is added in window node;
Step (2) successively takes out a task if the task list of window node is not sky from task list, and Judge whether current window is the window for executing required by task and wanting according to window ID, if it is required window, then directly executes Task is then first restored to window required for current task, then executes task if not required window;
Step (3) judges to execute whether this task rear hatch switches;
Step (4) then judges whether to jump in the window of other application, if jumped to other in case of switching In the window of application, then re-launching applications, circulation step (1), step (2), step (3) are otherwise added to current task In task execution path list, circulation step (1) obtains the window node information after jumping, new window nodal information and works as The task of preceding execution is added in current conversion, current conversion is added in the translation lists of current window node, while handle Previous window node is added to the parent window node of new window node;
Step (5), if there is no switching, circulation step (2), step (3);
Step (6) judges whether current window is to terminate window, that is, any control clicked on this window will not all be cut New window is changed to, a test case is then generated according to task execution path list if it is window is terminated, while deleting and appointing The last one task in business execution route list;
Step (7) judges whether complete application program of traversal, if having stepped through complete application program, entirely Traversing result returns to a window if not traversing complete application program, and recurrence executes the step of front six, from And it realizes and entire application is traversed.
In step (2), it is restored to the process of required window are as follows:
First from the mark of target window required for task execution is obtained in task, application program current window mark is then obtained Knowledge is not processed if target window mark is identical with current window mark, before return operation return is simulated if different One window, then judge whether the window ID after returning is target window mark;It repeats the above process, until finding target window Until mouthful;If the starting window for returning to application program finds target window not yet, obtained from target window node Since the task list executed saved successively execute the task in task list, until running to mesh originating window Mark window.
In step (6), the test case of generation is stored in Excel document, and the content of test case includes that test is used Example title, operating procedure, current Activity title, target Activity title, the relevant information of tested control, operation are crucial Word, result check keyword, input data and anticipated output data field.
In embodiments of the present invention, in step s 102, with Android application widget all standing automatic generating test case When method automatically generates test case,<Activity title, current window screenshot>substitution<Activity title, window can be used Mouth Hash codes > carry out one Android application widget of unique identification.
In embodiments of the present invention, in step s 103, the test script side of automatically generating is reused with RobotiumEx high When method automatically generates test script, the common method for including to Solo class in Robotium frame first is packaged, and is then led to It crosses and inputs corresponding keyword in Excel document and call packaged test script generation method, automatically generate test script;
With RobotiumEx high reuse test script automatic generation method automatically generate test script the following steps are included:
Step (1), the common method for including to Solo class in Robotium frame are packaged, and obtain commonly testing foot This generation method;
Step (2) binds corresponding keyword to packaged test script generation method, it is automatic to form RobotiumEx Change test frame;
Step (3) generates Excel test case text with Android application widget all standing automatic example generation method Shelves;
Step (4) adds corresponding test data and keyword in the test case document of generation;
It is related to obtain the corresponding institute of test case for step (5), the test case after reading addition keyword and test data Key word passes sequentially through keyword and calls corresponding test script generation method, is automatic generating test case test script.
As shown in figure 5, being another object of the present invention is to provide a kind of Android application program Automated Black Box Testing System, the system of the Android application program Automated Black Box Testing include:
Android application widget control identification module 51 based on ADB order, for obtain current window control information and Window information, control information include control type, control title and control property, and window information includes Activity where window Title and window Hash codes;
Android application widget all standing automatic generating test case module 52, with the Android application widget based on ADB order Control identification module 51 is connected, and is used for according to depth-first traversal mode, to peace during automatically generating test case Tall and erect application widget carries out all standing;
RobotiumEx high reuses test script automatically-generating module 53, certainly with Android application widget all standing test case Dynamic generation module 52 is connected, and the common method for including to Solo class in Robotium frame is packaged, and by Corresponding keyword is inputted in Excel document and calls packaged test script generation method, automatically generates test script.
With reference to the accompanying drawing and specific embodiment is further described application principle of the invention.
The method of Android application program Automated Black Box Testing provided in an embodiment of the present invention includes: based on ADB order The recognition methods of Android application widget control, Android application widget all standing automatic example generation method and RobotiumEx high Test script automatic generation method three parts are reused, pass through the Android application widget control identification side based on ADB order first Method identifies all control informations and target window information in target window;Then it is used with Android application widget all standing test Case automatic generating method automatically generates test case;Finally test script automatic generation method is reused certainly with RobotiumEx high It is dynamic to generate test script.To reach the degree of automation for improving test in the case where not needing program source code, interface covering The purpose of rate and the reusability of raising test script.
The invention proposes a kind of Android application widget all standing automatic generating test cases and RobotiumEx high to reuse The Automated Black Box Testing Method that test script automatically generates, this method include the Android application widget control based on ADB order Identification, Android application widget all standing automatic generating test case and RobotiumEx high reuse test script and automatically generate three Point.
1) the Android application widget control identification based on ADB order
The part is used to obtain the control information and window information of current window, and control information includes control type, control Title and control property etc., window information include Activity title and window Hash codes where window.Peace based on ADB order Tall and erect application widget control identification process is as shown in Figure 2.
Key step is as follows:
(1) dump and adb shell dumpsys window w is sent to equipment by ADB respectively | findstr MCurrent order;
(2) xml document that the window control information on preservation current device screen is obtained by executing dump order, passes through Executing adb shell dumpsys window w | findstr mCurrent order obtains Activity belonging to current window Name and window Hash codes;
(3) xml document of acquisition is grabbed on local host, it is parsed, and the current window of acquisition institute The Activity name and window Hash information of category are added in control information, generate control node listing;
(4) the control node listing of generation is re-write in an xml document.
2) Android application widget all standing automatic generating test case
According to depth-first traversal thought, the invention proposes a kind of Android application widget all standing test cases to give birth to automatically At method, the feature of this method is that can be covered full during automatically generating test case to Android application widget Lid.Wherein need to construct time based on Android application widget during fortune automatically generates test case in this way Model is gone through, this traversal model is a digraph, and node of graph indicates a window node, and the side of figure indicates that a simulation is dynamic Make.
In order to better describe the traversal model based on window, following concept is defined in the present invention:
Definition: window ID (Window Flag) is used for one window of unique identification, saves in window ID Activity title and window Hash information, can by respectively to Activity title and window Hash codes compare come Judge whether two windows are identical.
Definition: task (Task) is represented by (window ID, movement, control node) such a triple, wherein window Mouth mark indicates that a movement executes under this window, and movement indicates an operation to be simulated, and control node is indicated wait simulate Control belonging to operating, only after the movement that application program is run on this window and this window is performed, a task is just calculated It is performed.
Definition: all information relevant to window are saved in window node (Window Node), including corresponding Task list that all pending tasks for including in window ID, current window are formed, father node, child list, from The translation lists in all task lists and current window executed in starting window node to the path of current window node.
Definition: for indicating a transformational relation in model, it saves task and window for conversion (Transition) Nodal information, a wherein task in task presentation current window node, and node indicates generated son after task execution Node.
Android application widget all standing automatic generating test case process is as shown in Figure 3.
Key step is as follows:
(1) all controls in target window are identified by the Android application widget control recognition methods based on ADB order Information and target window information are that each control generates a task according to control type, form task list, believed according to window Breath generates window ID, and they are added in window node;
(2) if the task list of window node is not sky, a task is successively taken out from task list, and according to window Mouth mark judges whether current window is the window for executing required by task and wanting, and if it is required window, then directly executes task, such as Fruit is not required window, then is first restored to window required for current task, then executes task;
It is restored to the process of required window are as follows: first from the mark of target window required for task execution is obtained in task, so Application program current window mark is obtained afterwards, is not processed if target window mark is identical with current window mark, if It is different then simulate return operation and return to previous window, then judge whether the window ID after returning is target window mark.Weight The multiple above process, until finding target window.If the starting window for returning to application program finds target window not yet Mouthful, then the task list executed saved is obtained from target window node successively executes task since originating window Task in list, until running to target window.
(3) judge to execute whether this task rear hatch switches;
(4) in case of switching, then judge whether to jump in the window of other application, if jumping to other application In window, then re-launching applications, circulation step (1), (2), (3).Otherwise current task is added to task execution path column In table, circulation step (1) obtains the window node information after jumping, new window nodal information and currently performed task is added Enter into current conversion, current conversion is added in the translation lists of current window node, while previous window node It is added to the parent window node of new window node;
(5) if there is no switching, circulation step (2) (3);
(6) judge whether current window is to terminate window, that is, any control clicked on this window will not be all switched to New window then generates a test case according to task execution path list if it is window is terminated, while the task of deleting is held The last one task in row path list;
(7) judge whether complete application program of traversal, if having stepped through complete application program, entire traversal knot Fruit.If not traversing complete application program, a window is returned to, recurrence executes the step of front six, to realize Entire application is traversed.
The test case of generation is stored in Excel document, and the content of test case includes test case title, operation step Suddenly, currently Activity title, target Activity title, the relevant information of tested control, operation keyword, result inspection are closed The fields such as key word, input data and anticipated output data.
(3) RobotiumEx high reuses test script and automatically generates
RobotiumEx high reuses test script automatic generation method Common method is packaged;Then call packaged test script raw by inputting corresponding keyword in Excel document At method, test script is automatically generated.
Key step is as follows:
(1) common method for including to Solo class in Robotium frame is packaged, and it is raw to obtain common test script At method;
(2) corresponding keyword is bound to packaged test script generation method, forms RobotiumEx automation and surveys Try frame;
(3) Excel test case document is generated with Android application widget all standing automatic example generation method;
(4) corresponding test data and keyword are added in the test case document of generation;
(5) test case after addition keyword and test data is read, the corresponding all keywords of test case are obtained, It passes sequentially through keyword and calls corresponding test script generation method, be automatic generating test case test script.
RobotiumEx automated test frame encapsulates operation keyword and result checks two kinds of keywords of keyword, table 1 is packaged partial key table.
1 partial key table of table
It describes in detail by taking SCLICK keyword as an example to the encapsulation process of keyword below, the envelope of SCLICK keyword Dress process is as shown in Figure 4.
Technical solution of the present invention bring beneficial effect
(1) since an Activity may include multiple and different window, the window in the same Activity can be with Mutually switching, there is no the handoff relations really established between display interface in fact for the traversal model based on Activity, therefore The interface coverage rate of test can be improved in Android application widget all standing automatic example generation method.
(2) since when writing test script using Robotium, test data is included in script, work as survey When examination data change, it is necessary to modify test script, code reusability is not high.And RobotiumEx high reuses test foot This automatic generation method need to only modify the test data in test case document when test data changes, from And improve the reusability of test script.
The step for automatically generating test case with Android application widget all standing automatic example generation method In,<Activity title, current window screenshot>substitution<Activity title, window Hash codes>carry out unique identification can be used One Android application widget.
The present invention proposes a kind of Android application widget all standing test case and gives birth to automatically according to depth-first traversal thought At method, this method can carry out all standing to Android application widget during automatically generating test case;The present invention Improvement to entire technical solution: target window is identified by the Android application widget control recognition methods based on ADB order first All control informations and target window information in mouthful, this method need to only be parsed when obtaining control information through ADB order All control informations can be obtained in the control information document of acquisition, and can directly acquire window information, mistake by ADB order Journey is simple and saves the time;Then test is automatically generated with Android application widget all standing automatic example generation method Use-case, this method can carry out all standing to Android application widget during automatically generating test case;Finally use RobotiumEx high reuses test script automatic generation method and automatically generates test script, this method by Robotium from Dynamicization test frame is packaged, and only need to add keyword and test data in test case document, automatic life can be realized At test script, and when test data changes, the test data in test case document need to be only modified, without Test script need to be modified, to improve the reusability of test script.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the invention, all in essence of the invention Made any modifications, equivalent replacements, and improvements etc., should all be included in the protection scope of the present invention within mind and principle.

Claims (8)

1. a kind of method of Android application program Automated Black Box Testing, which is characterized in that Android application program automation is black The method of box test is the following steps are included: step 1, is known by the Android application widget control recognition methods based on ADB order All control informations and target window information in other target window;Step 2 is tested with Android application widget all standing Test case is automatically generated with case automatic generating method;Step 3 reuses test script with RobotiumEx high and automatically generates Method automatically generates test script;
Step 1 identifies all controls in target window by the Android application widget control recognition methods based on ADB order Information and target window information send dump and adb shell to equipment by ADB the following steps are included: step (1) respectively Dumpsys window w | findstr mCurrent order;Step (2) is currently set by executing dump order acquisition preservation The xml document of window control information on standby screen, by executing adb shell dumpsys window w | findstr MCurrent order obtains Activity and window Hash codes belonging to current window;Step (3), the xml text of acquisition Part grabs on local host, parses to it, and Activity belonging to the current window acquisition and window Hash Code information is added in control information, generates control node listing;The control node listing of generation is re-write one by step (4) In a xml document.
2. the method for Android application program Automated Black Box Testing as described in claim 1, which is characterized in that step 1 is led to Cross all control informations and target window in the Android application widget control recognition methods identification target window based on ADB order When information, control information includes control type, control title and control property, and window information includes Activity where window Claim and window Hash codes.
3. the method for Android application program Automated Black Box Testing as described in claim 1, which is characterized in that step 2, fortune When automatically generating test case with Android application widget all standing automatic example generation method, need to construct one based on peace The traversal model of tall and erect application widget, traversal model are a digraph, and node of graph indicates a window node, and the side of figure indicates One simulated action, in the traversal model based on window, window ID (Window Flag) is used for one window of unique identification Mouthful, Activity title and window Hash information are saved in window ID, can by respectively to Activity title and Window Hash codes compare judge whether two windows are identical;Task (Task) is represented by window ID, acts, control Such a triple of part node, wherein window ID indicates that a movement executes under this window, and movement expression one is to mould Quasi- operation, control node are indicated to the affiliated control of simulated operation, only when application program is run on this window and this window Movement be performed after, a task is just performed;Institute relevant to window is saved in window node (Window Node) There is information, the task list that is formed including all pending tasks for including in corresponding window ID, current window, Father node, child list, from all task lists for executing in starting window node to the path of current window node and Translation lists in current window;For indicating a transformational relation in model, it, which is saved, appoints for conversion (Transition) It is engaged in and window node information, wherein a task in task presentation current window node, and node indicates institute after task execution The child node of generation;Automatically generating test case with Android application widget all standing automatic example generation method includes Following steps: step (1) identifies the institute in target window by the Android application widget control recognition methods based on ADB order There are control information and target window information, is that each control generates a task according to control type, forms task list, root Window ID is generated according to window information, and window ID is added in window node;Step (2), if window node is appointed Business list is not sky, a task is successively taken out from task list, and judge whether current window is to hold according to window ID The window that row required by task is wanted then directly executes task and is then first restored to if not required window if it is required window Window required for current task, then executes task;Step (3) judges to execute whether this task rear hatch is cut It changes;Step (4) then judges whether to jump in the window of other application, if jumping to other application in case of switching Window in, then otherwise current task is added to task by re-launching applications, circulation step (1), step (2), step (3) In execution route list, circulation step (1) obtains the window node information after jumping, new window nodal information with currently hold Capable task is added in current conversion, current conversion is added in the translation lists of current window node, while previous A window node is added to the parent window node of new window node;Step (5), if there is no switching, circulation step (2), Step (3);Step (6) judges whether current window is to terminate window, that is, any control clicked on this window all will not It is switched to new window, a test case is then generated according to task execution path list if it is window is terminated, is deleted simultaneously The last one task in task execution path list;Step (7) judges whether complete application program of traversal, if Complete application program of traversal, then save entire traversing result, if not traversing complete application program, returns to upper one A window, recurrence execute the step of front six, traverse to realize to entire application.
4. the method for Android application program Automated Black Box Testing as claimed in claim 3, which is characterized in that in step (2) In, it is restored to the process of window needed for current task are as follows: first from target window mark required for acquisition task execution in task Know, then obtain application program current window mark, does not do and locate if target window mark is identical with current window mark Reason simulates return operation if different and returns to previous window, then judges whether the window ID after returning is target window Mark;It repeats the above process, until finding target window;If the starting window for returning to application program is looked for not yet To target window, then the task list executed saved is obtained from target window node, since originating window, according to Task in secondary execution task list, until running to target window.
5. the method for Android application program Automated Black Box Testing as claimed in claim 3, which is characterized in that in step (6) In, the test case of generation is stored in Excel document, the content of test case include test case title, operating procedure, when Preceding Activity title, target Activity title, the relevant information of tested control, operation keyword, result check keyword, Input data and anticipated output data field.
6. the method for Android application program Automated Black Box Testing as described in claim 1, which is characterized in that in step 2 In, when automatically generating test case with Android application widget all standing automatic example generation method, can be used < Activity title, current window screenshot>substitution<Activity title, window Hash codes>carry out one Android application of unique identification Window.
7. the method for Android application program Automated Black Box Testing as described in claim 1, which is characterized in that in step 3 In, when automatically generating test script with RobotiumEx high reuse test script automatic generation method, first to Robotium The common method that Solo class includes in frame is packaged, and is then called by inputting corresponding keyword in Excel document Packaged test script generation method, automatically generates test script;Test script is reused with RobotiumEx high to give birth to automatically Test script is automatically generated at method the following steps are included: step (1), is commonly used to what Solo class in Robotium frame included Method is packaged, and obtains common test script generation method;Step (2), to packaged test script generation method Corresponding keyword is bound, RobotiumEx automated test frame is formed;Step (3), with Android application widget all standing Automatic example generation method generates Excel test case document;Step (4) is added in the test case document of generation Corresponding test data and keyword;Step (5), the test case after reading addition keyword and test data, obtains and surveys The corresponding all keywords of example on probation pass sequentially through keyword and call corresponding test script generation method, certainly for test case It is dynamic to generate test script.
8. a kind of system of Android application program Automated Black Box Testing, which is characterized in that Android application program automation is black The system of box test includes: the Android application widget control identification module based on ADB order, for obtaining the control of current window Part information and window information, control information include control type, control title and control property, and window information includes window institute In Activity title and window Hash codes;Android application widget all standing automatic generating test case module, with the base It is connected in the Android application widget control identification module of ADB order, for being given birth to automatically according to depth-first traversal mode All standing is carried out to Android application widget during at test case;RobotiumEx high reuses test script and automatically generates Module is connected with the Android application widget all standing automatic generating test case module, for in Robotium frame The common method that Solo class includes is packaged, and by inputted in Excel document corresponding keyword call it is packaged Test script generation method, automatically generates test script.
CN201611056866.XA 2016-11-25 2016-11-25 A kind of method and system of Android application program Automated Black Box Testing Active CN106649103B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611056866.XA CN106649103B (en) 2016-11-25 2016-11-25 A kind of method and system of Android application program Automated Black Box Testing

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611056866.XA CN106649103B (en) 2016-11-25 2016-11-25 A kind of method and system of Android application program Automated Black Box Testing

Publications (2)

Publication Number Publication Date
CN106649103A CN106649103A (en) 2017-05-10
CN106649103B true CN106649103B (en) 2019-04-16

Family

ID=58812646

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611056866.XA Active CN106649103B (en) 2016-11-25 2016-11-25 A kind of method and system of Android application program Automated Black Box Testing

Country Status (1)

Country Link
CN (1) CN106649103B (en)

Families Citing this family (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107368418B (en) * 2017-07-26 2020-12-04 网易有道信息技术(北京)有限公司 Traversal test method, device and medium
CN107368421A (en) * 2017-07-28 2017-11-21 北京深思数盾科技股份有限公司 The method and system of automatic test interface program
CN107729243B (en) * 2017-10-12 2020-06-16 上海携程金融信息服务有限公司 Application programming interface automatic test method, system, equipment and storage medium
CN108399131A (en) * 2018-03-13 2018-08-14 百度在线网络技术(北京)有限公司 Automatic test cases generation method and device
CN109144856A (en) * 2018-07-27 2019-01-04 北京皮尔布莱尼软件有限公司 A kind of UI automated testing method calculates equipment and storage medium
CN109857636A (en) * 2018-12-25 2019-06-07 杭州茂财网络技术有限公司 A kind of methods and applications positioning App homepage in Android client UI automation process
CN111459774B (en) * 2019-01-21 2023-05-12 中国移动通信有限公司研究院 Method, device, equipment and storage medium for acquiring flow of application program
CN112306846B (en) * 2019-07-31 2022-02-11 北京大学 Mobile application black box testing method based on deep learning
CN110581885A (en) * 2019-08-23 2019-12-17 华云数据(厦门)网络有限公司 Method, device and equipment for determining equipment synchronization and storage medium
CN110825622A (en) * 2019-10-16 2020-02-21 中国建设银行股份有限公司 Software testing method, device, equipment and computer readable medium
CN112306857A (en) * 2020-02-24 2021-02-02 北京字节跳动网络技术有限公司 Method and apparatus for testing applications
CN111708699A (en) * 2020-06-16 2020-09-25 荆门汇易佳信息科技有限公司 Intelligent integrated detection system for Android application program
CN112148608B (en) * 2020-09-24 2021-11-05 上海交通大学 Mobile terminal automated software testing method based on control function labeling
CN112363923B (en) * 2020-11-09 2024-05-14 中国平安人寿保险股份有限公司 Testing method and device based on questionnaire system, computer equipment and medium
CN114020648B (en) * 2022-01-04 2022-04-12 广东拓思软件科学园有限公司 Application control testing method and device, electronic equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103336742A (en) * 2013-07-18 2013-10-02 北京航空航天大学 Automation software black box testing system and method based on Android
CN104679644A (en) * 2013-11-28 2015-06-03 比亚迪股份有限公司 Testing method and system for application program in mobile terminal
CN106021102A (en) * 2016-05-16 2016-10-12 北京奇虎科技有限公司 Automated test file generation method and apparatus

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20140095882A (en) * 2013-01-25 2014-08-04 삼성전자주식회사 Test system for evaluating mobile device and driving method thereof

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103336742A (en) * 2013-07-18 2013-10-02 北京航空航天大学 Automation software black box testing system and method based on Android
CN104679644A (en) * 2013-11-28 2015-06-03 比亚迪股份有限公司 Testing method and system for application program in mobile terminal
CN106021102A (en) * 2016-05-16 2016-10-12 北京奇虎科技有限公司 Automated test file generation method and apparatus

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
一种Web系统性能测试框架及其混合建模过程;明仲,尹剑飞,杨巍等;《计算机研究与发展》;20100715;第47卷(第7期);全文

Also Published As

Publication number Publication date
CN106649103A (en) 2017-05-10

Similar Documents

Publication Publication Date Title
CN106649103B (en) A kind of method and system of Android application program Automated Black Box Testing
Umar et al. A study of automated software testing: Automation tools and frameworks
CN110008113B (en) Test method and device and electronic equipment
CN106502896B (en) A kind of generation method and device of function test code
CN104503917B (en) Change domain of influence analysis method and system based on data flow function call path
US20180239692A1 (en) Electronic technology resource evaluation system
US7895575B2 (en) Apparatus and method for generating test driver
Griebe et al. A model-based approach to test automation for context-aware mobile applications
CN108491319A (en) Web automated testing methods and system based on this method
US10067859B2 (en) Constructing test-centric model of application
CN110162457A (en) Test method, device, equipment and the storage medium of user interface
CN109408372A (en) Common component test method, device, computer equipment and storage medium
CN104834600A (en) Method for testing Android application controls
CN105760300B (en) A kind of automated testing method and test macro of STK/UTK business
CN107622017B (en) Analysis method for universal automation software test
Binamungu et al. Detecting duplicate examples in behaviour driven development specifications
CN111752841A (en) Single test simulation method, device, equipment and computer readable storage medium
Bures et al. SmartDriver: Extension of selenium WebDriver to create more efficient automated tests
US10733075B2 (en) Data-driven synthesis of fix patterns
CN113064811B (en) Automatic testing method and device based on workflow and electronic equipment
CN109815126A (en) Method for testing software, device, computer equipment and storage medium
CN106095663B (en) Program based on hierarchical model returns location of mistake method
Ateşoğulları et al. White Box Test Tools: A Comparative View
CN104536880A (en) GUI program testing case augmentation method based on symbolic execution
CN111143228A (en) Test code generation method and device based on decision table method

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