CN102841845B - Automatic testing method of Android device software - Google Patents
Automatic testing method of Android device software Download PDFInfo
- Publication number
- CN102841845B CN102841845B CN201210265962.0A CN201210265962A CN102841845B CN 102841845 B CN102841845 B CN 102841845B CN 201210265962 A CN201210265962 A CN 201210265962A CN 102841845 B CN102841845 B CN 102841845B
- Authority
- CN
- China
- Prior art keywords
- automatic test
- tested program
- device software
- script
- android device
- 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.)
- Expired - Fee Related
Links
Abstract
The invention relates to an automatic testing method of Android device software, and the automatic testing method comprises steps of automatic recording, replaying and verification of scripts, wherein the recording comprises following steps of (101) starting a tested program, and creating a layer of transparent View layer covering the tested program, wherein the transparent View layer is a subclass of android view View; (102) operating a screen or keys according to a test requirement; in the operation process, the transparent View layer captures and records a corresponding touch control/keystroke event, and an operation instruction is transmitted to the tested program through an analog touch control/keystroke event; and the tested program executing the operation instruction. The automatic testing method is based on an Android system and unnecessary for utilizing a shell order and a high-performance personal computer (pc), so that the test safety, reliability, universality and easiness in implementation can be enhanced.
Description
Technical field
The present invention relates to software Black-box Testing technology, be specifically related to a kind of Android (Android) device software automatic test approach, be especially applied to smart mobile phone.
Background technology
Existing, three kinds are roughly divided in android system software automated testing instrument, the first is the pre-designed testing tool of certain test path (the such as popular at present Juit (java unit testing) and Robotium (a kind of black box automated test frame based on Android) of certain program by test developer, be used for automatic test again, such benefit is omitted the workload of test man, but substantially increase the workload of test developer, first there are many test paths in a program, test developer just must carry out design test instrument according to different test paths, if just do not accomplish the comprehensive of program test so yet.So do the problems referred to above well also just do automatic test well, product also can be caused to there is serious risk and defect simultaneously.Perhaps you could say and adopt artificial mode to test! Institute of Shi Ge manufacturer is unacceptable again for the problems such as so really can solve the problem of automatic test, but traditional manual testing's coverage rate is narrow, the cycle is long, and cost of labor is high.
It two is adopt computing machine (pc) to connect the mode of Android terminal, it realizes being that the Android carried by being equipped with Android on pc machine drives (ADB) instrument or realizes being connected with peripherals and configuring socket (Socket) communications parameter by USB (universal serial bus) (USB), on interface by standard wicket tool box (swt)/jface tool display out, the information then obtaining equipment tested program by shell (shell) order at bottom generates corresponding test script, though can solve the problem like this, but it does not depart from computer, do not accomplish automatic test whenever and wherever possible, the convenience of instrument and the non-constant of practicality, such as application number is: the patent of 201110446674.0.
It three is authorities at the highest level by open equipment, the information being obtained equipment tested program by the shell-command that could use during the highest rights of using that obtain this equipment generates corresponding test script, which is connected closely with android system bottom, be unfavorable for the safety of Android device, easily become the instrument/technology of hacker attacks, such as application number is: the safety problem of the patent of 201010616361.0 is just troubling.
Thus existing measuring technology also in be all not enough to the automatic test carrying out android system, urgently improve.
Summary of the invention
The technical issues that need to address of the present invention are, how to provide a kind of Android device software automatic test approach, and shell-command and high-performance pc need not be used to carry out automatic test, thus promote test safety, reliable, extensive and easy implementation.
Above-mentioned technical matters of the present invention solves like this: build a kind of Android device software automatic test approach, comprises following automatic script and records step:
101) start tested program, and create layer of transparent visual (View) layer; Described View layer is the subclass of android.view.View;
102) by test request function screen or button;
In operation, described transparent View layer intercepts and records corresponding touch-control/key-press event, then transmits operational order by sending corresponding consistent simulation touch-control/key-press event to tested program; Tested program performs described operational order.
According to Android device software automatic test approach provided by the invention, step 102) in send simulation touch-control/key-press event by call back function HandleEvent and auto-testing-framework Instrumention to tested program.
According to Android device software automatic test approach provided by the invention, step 102) in tested program perform described operational order and comprise renewal screen interface.
According to Android device software automatic test approach provided by the invention, first temporarily remove itself when transparent View has listened to UP action and transmit recorded information in call back function HandleEvent, call back function HandleEvent then sends simulation touch-control/key-press event according to the information recorded in conjunction with automated test frame Instrumention and upgrades tested program interface, step 102) in intercept record and comprise and record corresponding screen interface.
According to Android device software automatic test approach provided by the invention, described automatic script is recorded step and is comprised striding course recording, and this cannot accomplish in based on the mode of shell and pc.
According to Android device software automatic test approach provided by the invention, described recording step also comprise by predefined interactive mode notify transparent View layer terminate record, generate and record script, specifically: described recording step also comprises end after transparent View has listened to end recording request and records and notify that background service RecordService extracts recorded information, generates and records script.
According to Android device software automatic test approach provided by the invention, this automatic test approach also comprises script replay procedure: send a series of simulation touch-control/key-press event corresponding with recording script according to recording script to tested program.
According to Android device software automatic test approach provided by the invention, described script replay procedure repeatedly repeats.
According to Android device software automatic test approach provided by the invention, described replay procedure also comprises script and resolves and validation checking sub-step.
According to Android device software automatic test approach provided by the invention, this automatic test approach also comprises result verification step.
According to Android device software automatic test approach provided by the invention, result verification step includes, but are not limited to under type:
(1) described result verification step comprises the screen output of intercepting tested program and automatically/artificial image's comparison;
(2) described result verification step comprises the data output of record tested program and automatic numeric ratio pair.
Android device software automatic test approach provided by the invention, be especially applied to smart mobile phone, comparatively prior art has the following advantages:
1, tested program can record the test script of different test path by the present invention, and do not need to write any code or amendment test script, avoid the script manually recording different test path to solve program test Path diversity and testing tool developer design tool is difficult, workload is large problem;
2, do not need by pc machine to realize automatic recording, and do not need the authority at the highest level of Android device; Utilize technology to simulate human-computer interaction function completely, the test script of the program test Path diversity of more than 90% can be recorded, thus reduce the exploitation amount of automated test tool and the input of human capital, greatly increase automatic test efficiency;
3, automatic test is carried out, due to only recordings test script can be carried out according to the switching at interface when recording, so the script that can carry out striding course records and script playback is tested by gathering element coordinate;
4, can be used for regression test, smoke test and functional test, more practical, safer, more convenient and more reliable.
Accompanying drawing explanation
Below in conjunction with the drawings and specific embodiments, the present invention is described in detail further:
Fig. 1 is the program circuit schematic diagram of the automatic test software on the present invention's preferred specific embodiment touch-screen smart mobile phone.
Embodiment
First, illustrate that the present invention is basic and crucial:
(1) basic thought
In recording process, the View simultaneously creating layer of transparent when tested program starts is positioned in tested program.When event occurs, monitor method that this View realizes can operation of recording tested program tap the coordinate at element place or the key value of this equipment and generate test script and be stored on mobile phone memory card.During playback, then realize the playback test of striding course in conjunction with Instrumentation (a kind of automated test frame of Android platform) according to corresponding script analytical algorithm.
(2) self-defined View layer
This self-defining transparent View inherits from android.view.View, by making carbon copies its key-press event onKeyDown (), onKeyUp (), several methods of more than the onTouchEvent () of onKeyLong () and touch-control event carry out audiomonitor action event, this step also can when starting this tested program the Target Package of tested program simultaneously, the information (self-defined code name is 0) of Activity Name (the Bao Mingyu main classes name of tested program) and current device be packaged into a special character string (form is: " self-defined code name "+", "+" TargetPackage "+", "+" Activity Name "+", "+" XX ") adds in StringBuffer (in java, is similar to the character string buffer zone of String)).
The second, describe specific implementation of the present invention in detail in conjunction with the preferred embodiments:
As shown in Figure 1, the automatic test software program on the present invention's preferred specific embodiment touch-screen smart mobile phone specifically comprises the following steps:
301) start-up routine, selection starts to record (realization of this step be obtain current device all visible exercisable program and enumerate out and be presented on screen, click select a certain after can start this program, simultaneously also can create the self-defining transparent View of one deck covers on it; A special character string is become to add in StringBuffer with the Information encapsulation of current device the Target Package of tested program, Activity Name when starting tested program;
302) in the recording, random touch screen (realization of this step is by listening to current test man to after some simulating keyboards/touch screen event of this transparent View, rule as follows:
If key-press event then gets the code name (self-defined code name is 1) of event, with type of action, (type is divided into: UP (upspringing), DOWN (pressing), LONG (length is pressed)) and key value (key assignments of " return key " of such as equipment is 4).
If touch-control event then gets event code name (self-defined code name is 2), with type of action, (type is divided into: UP (upspringing), DOWN (pressing), MOVE (movement)) and the coordinate (note a: action clicked is made up of with a UP two actions a DOWN of this X-axis Y-axis residing for interface control element; And the action of a movement is made up of with a multiple MOVE and UP action a DOWN) and its value be packaged into a special character string (one form is: " self-defined code name "+"; " + " type of action "+"; " + " X-axis coordinate "+"; " + " Y-axis coordinate ") add in StringBuffer and List set (in java a kind of orderly sequence) respectively, judge the type of action of this event, rule is as follows simultaneously:
If type of action is up type, temporarily remove this transparent view, then after converting character string dimension to, judge the value of this character string dimension first element when every bar character string is taken out in circulation from List set, if value is for " 1 ", then get the value of all elements thereafter and the sendKeySync () method in conjunction with Instrumentation sends simulating keyboard event.If value is for " 2 ", then get the value of all elements thereafter and the sendPointerSync () method in conjunction with Instrumentation sends touch-control event.And (such as under transparent view, we are some controls seen on tested program interface to thus achieve the various action event of touch action on transparent view/press device keys, when you click, (this action is made up of with up type down, that is this action first presses to unclamp again) certain control time it is no reaction, because click to as if transparent view, when background program monitor just now include UP type of action in click action time, program can be temporary transient remove this transparent view, then the event information be just saved in List set is taken out, click action is sent in conjunction with the sendPointerSync () method of Instrumentation () after resolving, so just realize redirect or the renewal at interface), again this transparent view covered on it after this action is complete and empty all values of List class, so just achieved the recording of step by the mode of going round and beginning again like this, until program listens is to exiting command),
303) X clicked when exiting recording below screen monitors icon (realization of this step is written to be kept at public temporary area information on local storage card, also just recorded through this automatic test script);
304) when step 303) complete after program can turn back to main interface, at this moment select start test (mechanism of this step is by realizing a simple file manager, its objective is for management the present invention record test script);
305) find the script just recorded and click, program starts to detect automatically (realization of this step is by after finding test script file, and then whether effective, if effectively, directly enter step 307 if detecting test script);
306) if when detecting that test script is invalid, program can point out test man again to record or cancel (realization of this step is again recorded if test man have selected, and directly enters step 302), otherwise then cancels);
307) program enters resolution phase, resolved rear prompting test man arrange testing time and test time delay or click " cancellations " (if the realization of this step is by step 305) redirect then directly resolve this test script file and the character string that every bar parses add to List gather in);
308) after setting, click " determination " afterwards program can carry out according to the information arranged resolving in automatic test (realization of this step obtains step 307) after after List class, by the method for circulation value take out each band have event information character string and by the spit (" of String; ") method migration becomes a character string dimension and judge according to the value of the first element of this character string, rule is as follows:
If value is " 0 ", then get the value of its second element with the 3rd element to start tested program;
If value is for " 1 ", then get the value of all elements thereafter and send the KeySync () method in conjunction with Instrumentation sends simulating keyboard event;
If value is for " 2 ", then get the value of all elements thereafter and send the PointerSync () method in conjunction with Instrumentation sends touch-control event;
309) when automatic test, program can show testing progress on screen, and midway also manually can stop test;
310) after test execution, whether program can eject dialog box inquiry test man and continue;
311) continue if click, then automatic test restarts, and stop if clicking, automatic test then exits;
312) terminate.
Finally, the foregoing is only preferred embodiment of the present invention, all equalizations done according to the claims in the present invention scope change and modify, and all should belong to the covering scope of the claims in the present invention.
Claims (9)
1. an Android device software automatic test approach, is characterized in that, comprises following automatic script and records step:
101) start tested program, and create one deck and cover transparent View layer in tested program; Described View layer is the subclass of android.view.view;
102) by test request function screen or by strong;
In operation, described transparent View layer intercepts and records corresponding touch-control/key-press event, then transmits operational order by sending corresponding consistent simulation touch-control/key-press event to tested program; Tested program performs described operational order;
Described transparent View layer intercepting is recorded corresponding touch-control/key-press event and is comprised:
Got code name, type of action, the key value of touch-control event by View layer, and be packaged into a character string add to StringBuffer and List set in; Get the coordinate of the code name of key-press event, type of action and the X-axis Y-axis residing for interface control element, and be packaged into a character string add to StringBuffer and List set in.
2. Android device software automatic test approach according to claim 1, is characterized in that, step 102) in send simulation touch-control/key-press event in conjunction with auto-testing-framework to tested program by resolving the test script recorded.
3. Android device software automatic test approach according to claim 2, it is characterized in that, first temporarily remove itself when transparent View has listened to UP action and transmit recorded information in call back function HandleEvent, call back function HandleEvent then sends simulation touch-control/key-press event according to the information recorded in conjunction with automated test frame Instrumention and upgrades tested program interface, step 102) in intercept record and comprise and record corresponding screen interface.
4. Android device software automatic test approach according to claim 3, is characterized in that, automatic script is recorded step and comprised striding course and record.
5. Android device software automatic test approach according to any one of claim 1-4, it is characterized in that, described recording step also comprises end after transparent View has listened to end recording request and records and notify that background service RecordService extracts recorded information, generates and records script.
6. Android device software automatic test approach according to claim 5, it is characterized in that, this automatic test approach also comprises script replay procedure: send a series of simulation touch-control/key-press event corresponding with recording script according to recording script to tested program.
7. Android device software automatic test approach according to claim 6, is characterized in that, described replay procedure also comprises script and resolves and validation checking sub-step.
8. Android device software automatic test approach according to claim 6, it is characterized in that, this automatic test approach also comprises result verification step, and described result verification step comprises and intercepts tested program screen and export and automatically/artificial image's comparison.
9. Android device software automatic test approach according to claim 6, it is characterized in that, this automatic test approach also comprises result verification step, and described result verification step comprises record tested program data and exports and automatic numeric ratio pair.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210265962.0A CN102841845B (en) | 2012-07-30 | 2012-07-30 | Automatic testing method of Android device software |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210265962.0A CN102841845B (en) | 2012-07-30 | 2012-07-30 | Automatic testing method of Android device software |
Publications (2)
Publication Number | Publication Date |
---|---|
CN102841845A CN102841845A (en) | 2012-12-26 |
CN102841845B true CN102841845B (en) | 2015-02-11 |
Family
ID=47369235
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201210265962.0A Expired - Fee Related CN102841845B (en) | 2012-07-30 | 2012-07-30 | Automatic testing method of Android device software |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN102841845B (en) |
Families Citing this family (30)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104008047A (en) * | 2013-02-27 | 2014-08-27 | 腾讯科技(深圳)有限公司 | Intelligent terminal program testing method and system |
CN103226445A (en) * | 2013-05-10 | 2013-07-31 | 广东国笔科技股份有限公司 | Handwriting input method, system and terminal |
CN104239202A (en) * | 2013-06-09 | 2014-12-24 | 刘伟 | Non-Root testing method and system of interactive intelligent equipment |
CN103365779B (en) * | 2013-07-09 | 2016-11-09 | 广东欧珀移动通信有限公司 | Method for testing software and system |
CN104346276B (en) * | 2013-08-08 | 2018-12-11 | 腾讯科技(深圳)有限公司 | The method and device of software test |
CN104424089A (en) * | 2013-08-21 | 2015-03-18 | 中兴通讯股份有限公司 | Terminal testing method and device |
TWI510913B (en) | 2013-11-12 | 2015-12-01 | Inst Information Industry | Testing device and testing method thereof |
TWI510918B (en) * | 2014-02-20 | 2015-12-01 | Wistron Corp | Method and system for quick testing and detectiing mobile devices |
CN104899132B (en) * | 2014-03-05 | 2018-09-25 | 腾讯科技(深圳)有限公司 | Application software testing method, apparatus and system |
CN103928038B (en) * | 2014-04-29 | 2017-06-30 | 广东欧珀移动通信有限公司 | The test recording of electronic equipment and back method |
CN103995718B (en) * | 2014-05-08 | 2017-05-10 | 百度在线网络技术(北京)有限公司 | Method and device for collecting program information |
CN105320595A (en) * | 2014-07-31 | 2016-02-10 | 腾讯科技(深圳)有限公司 | Application test method and device |
CN105335283B (en) * | 2014-08-01 | 2018-07-06 | 阿里巴巴集团控股有限公司 | application testing method and device in terminal device |
CN105653438B (en) * | 2014-11-12 | 2018-11-09 | 成都鼎桥通信技术有限公司 | The striding course automated testing method and device of Android device |
CN104407980B (en) * | 2014-12-17 | 2017-07-11 | 用友网络科技股份有限公司 | Mobile solution automatic test device and method |
CN105868083A (en) * | 2015-01-21 | 2016-08-17 | 中兴通讯股份有限公司 | User operation playback method and apparatus |
CN104699607A (en) * | 2015-03-06 | 2015-06-10 | 惠州Tcl移动通信有限公司 | Automation testing method and system for mobile terminal |
CN104679631B (en) * | 2015-03-23 | 2018-02-23 | 重庆蓝岸通讯技术有限公司 | Method of testing and system for the equipment based on android system |
CN106354482A (en) * | 2015-07-13 | 2017-01-25 | 西安中兴新软件有限责任公司 | Method and device for acquiring automated scripts and application method and device of automated scripts |
CN105183654A (en) * | 2015-09-18 | 2015-12-23 | 厦门美图移动科技有限公司 | Android automatic testing screen recording mechanism and system disengaged from PC |
CN105451077B (en) * | 2015-12-02 | 2019-01-29 | Tcl集团股份有限公司 | A kind of button processing method and system based on module TV |
CN105930265A (en) * | 2016-04-11 | 2016-09-07 | 武汉卡比特信息有限公司 | Image recognition based software test method |
CN107491386A (en) * | 2016-06-13 | 2017-12-19 | 富士通株式会社 | The method and apparatus for recording test script |
CN106980575A (en) * | 2017-04-01 | 2017-07-25 | 深圳天珑无线科技有限公司 | A kind of event-handling method and device |
CN108733555A (en) * | 2017-04-25 | 2018-11-02 | 中移信息技术有限公司 | A kind of application testing method and device |
CN108182131B (en) * | 2017-12-13 | 2021-11-26 | 东软集团股份有限公司 | Method and device for monitoring application running state, storage medium and electronic equipment |
CN109550232A (en) * | 2018-11-02 | 2019-04-02 | 北京硬壳科技有限公司 | Touch control device and its response method, device |
CN111143200A (en) * | 2019-12-12 | 2020-05-12 | 广州华多网络科技有限公司 | Method and device for recording and playing back touch event, storage medium and equipment |
CN111881054B (en) * | 2020-08-04 | 2023-12-22 | 携程计算机技术(上海)有限公司 | User interface automatic test method, system, equipment and storage medium |
CN113157186A (en) * | 2021-05-20 | 2021-07-23 | 读书郎教育科技有限公司 | Method and equipment for generating long graphs of operation steps by Android terminal |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6067639A (en) * | 1995-11-09 | 2000-05-23 | Microsoft Corporation | Method for integrating automated software testing with software development |
CN101242621A (en) * | 2008-01-21 | 2008-08-13 | 中兴通讯股份有限公司 | An automatic testing method and system based on interface |
CN102314386A (en) * | 2011-09-05 | 2012-01-11 | 百度在线网络技术(北京)有限公司 | Method and equipment for testing mobile terminal |
JP2012103869A (en) * | 2010-11-09 | 2012-05-31 | Internatl Business Mach Corp <Ibm> | Software development support method, software development support device and software development support program |
-
2012
- 2012-07-30 CN CN201210265962.0A patent/CN102841845B/en not_active Expired - Fee Related
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6067639A (en) * | 1995-11-09 | 2000-05-23 | Microsoft Corporation | Method for integrating automated software testing with software development |
CN101242621A (en) * | 2008-01-21 | 2008-08-13 | 中兴通讯股份有限公司 | An automatic testing method and system based on interface |
JP2012103869A (en) * | 2010-11-09 | 2012-05-31 | Internatl Business Mach Corp <Ibm> | Software development support method, software development support device and software development support program |
CN102314386A (en) * | 2011-09-05 | 2012-01-11 | 百度在线网络技术(北京)有限公司 | Method and equipment for testing mobile terminal |
Also Published As
Publication number | Publication date |
---|---|
CN102841845A (en) | 2012-12-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN102841845B (en) | Automatic testing method of Android device software | |
Halpern et al. | Mosaic: cross-platform user-interaction record and replay for the fragmented android ecosystem | |
US11023363B2 (en) | Performance test application sequence script | |
US9747191B1 (en) | Tool to replicate actions across devices in real time for improved efficiency during manual application testing | |
CN102419732B (en) | Android-platform-based automated testing method and testing tool | |
US8988087B2 (en) | Touchscreen testing | |
CN109960642B (en) | Automatic test method and device | |
US20150058826A1 (en) | Systems and methods for efficiently and effectively detecting mobile app bugs | |
US20190227917A1 (en) | Adaptive system for mobile device testing | |
CN104699591A (en) | Reappearing method and device of test scenes | |
WO2019035610A1 (en) | Game test automation device and method | |
CN102053911A (en) | Automated testing method and system based on Android and mobile terminal | |
CN105335283A (en) | Application testing method and device in terminal equipment | |
CN103995769A (en) | Method for collecting error status information of an electronic device | |
EP2517101A1 (en) | A method, apparatuses and a system for compilation | |
US20130138381A1 (en) | Handheld electronic device testing method | |
CN102147756B (en) | Methods and systems for testing terminal | |
CN101272422A (en) | Mobile phone automatized test method | |
TW201518933A (en) | Testing device and testing method thereof | |
CN109086606B (en) | Program vulnerability mining method, device, terminal and storage medium | |
CN101751329B (en) | Method and system for realizing automatic testing | |
CN112115038A (en) | Application testing method and device and storage medium | |
CN102999419A (en) | Android test incident record and playback methods and device | |
CN105453033A (en) | Program testing service | |
CN106341731A (en) | Method and device for responding to remote-control key of intelligent television |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CP01 | Change in the name or title of a patent holder | ||
CP01 | Change in the name or title of a patent holder |
Address after: Changan town in Guangdong province Dongguan 523860 usha Beach Road No. 18 Patentee after: GUANGDONG OPPO MOBILE TELECOMMUNICATIONS Corp.,Ltd. Address before: Changan town in Guangdong province Dongguan 523860 usha Beach Road No. 18 Patentee before: GUANGDONG OPPO MOBILE TELECOMMUNICATIONS Corp.,Ltd. |
|
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20150211 |