CN112463613A - Test driving system and method based on adb and storage medium - Google Patents

Test driving system and method based on adb and storage medium Download PDF

Info

Publication number
CN112463613A
CN112463613A CN202011392334.XA CN202011392334A CN112463613A CN 112463613 A CN112463613 A CN 112463613A CN 202011392334 A CN202011392334 A CN 202011392334A CN 112463613 A CN112463613 A CN 112463613A
Authority
CN
China
Prior art keywords
module
test
adb
test driving
api
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.)
Granted
Application number
CN202011392334.XA
Other languages
Chinese (zh)
Other versions
CN112463613B (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.)
Guangzhou Lango Electronic Science and Technology Co Ltd
Original Assignee
Guangzhou Lango Electronic Science and Technology Co Ltd
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 Guangzhou Lango Electronic Science and Technology Co Ltd filed Critical Guangzhou Lango Electronic Science and Technology Co Ltd
Priority to CN202011392334.XA priority Critical patent/CN112463613B/en
Publication of CN112463613A publication Critical patent/CN112463613A/en
Application granted granted Critical
Publication of CN112463613B publication Critical patent/CN112463613B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • 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/368Test management for test version control, e.g. updating test cases to a new software version
    • 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/3692Test management for test results analysis
    • 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/3696Methods or tools to render software testable

Abstract

The invention provides a test driving system, a method and a storage medium based on adb, wherein the method comprises the following steps: searching a target control; carrying out user operation simulation by using a method corresponding to the element; the Python unit test framework is used for realizing case management and result assertion. According to the test driving system based on the adb, the test framework is a library developed based on python, the test script can be directly compiled for test operation only by one python, the complex environment is not required to be installed and configured, the test driving system can be well connected with an android system, and the test driving system has good applicability.

Description

Test driving system and method based on adb and storage medium
Technical Field
The invention relates to the technical field of Android (Android system) testing, in particular to an adb-based test driving system, method and storage medium.
Background
The existing testing framework for the android system cannot test the android system completely, or the existing testing framework for the android system is very dependent, heavy and inflexible. For example, Robotium is a foreign Android automatic test framework, mainly performs black box automatic test on applications of an Android platform, provides an API for simulating various gesture operations (clicking, long pressing, sliding and the like), searching and asserting mechanisms, and can operate various controls. Robotium requires test code to be written inside the application, and is integrated inside the application. For example, the Appium is an open source, cross-platform testing framework that can be used to test native and hybrid mobile-end applications. The Appium configuration environment is very complicated and requires installation of android SDKs, JDKs. In summary, the existing testing framework for the android system cannot be well connected with the android system, and the system operation capability is weak.
Disclosure of Invention
The invention aims to provide a test driving system, a test driving method and a storage medium based on adb, which can solve the problems that the existing test framework has high dependency on an android system and can not be well connected with the android system.
The purpose of the invention is realized by the following technical scheme:
in a first aspect, the present invention provides an adb-based test driving system, including an element control search module, a user event input module, a test auxiliary module, and a system operation module, where:
the element control searching module is connected with the android system to be tested through the element control searching API, and is mainly used for calling uiautomator, screencap and adb pull commands through a pop method of the packaging and using os module to realize element tree acquisition and screenshot acquisition, and then packaging the element tree and screenshot into a required interface function through Python to provide services for the outside;
the user event input module is connected with the android system to be tested through a user event input API (application program interface), and an input command and a self-defined command tool are called mainly through a pop method packaged and used by the os module to realize a user event input interface function;
the test auxiliary module is connected with the android system to be tested through a test auxiliary API (application programming interface), mainly calls commands such as logcat, am and pm through a pop method of packaging and using an os module, and searches the API by combining element controls to realize corresponding interface functions;
and the system operation module is connected with the android system to be tested through a system operation API, and is mainly used for calling svc, getprop, setprop, settings, ime, wm, screencap and a custom command by packaging a pop method using an os module to realize a corresponding interface function.
In a second aspect, the present invention provides an adb-based test driving method, including the following steps:
step 1, searching a target control;
step 2, carrying out user operation simulation by using a method corresponding to the element;
and 3, using a Python unit test framework to realize case management and result assertion.
Further, the implementation method of the result assertion is as follows: and quoting built-in alert of python to realize result judgment, and realizing the judgment by judging whether a certain control exists or not or whether a control text exists or not.
Further, the method for searching the target control comprises the following steps: instantiating a test driver class as a device instance, element location is performed using the method below the device instance.
In a third aspect, the present invention provides a storage medium, where a computer program is stored, and the computer program is executed to execute the adb-based test driving method.
According to the test driving system based on the adb, the test framework is a library developed based on python, the test script can be directly compiled for test operation only by one python, the complex environment is not required to be installed and configured, the test driving system can be well connected with an android system, and the test driving system has good applicability.
Drawings
FIG. 1 is a schematic diagram of a frame structure of an adb-based test driving system according to the present invention;
FIG. 2 is a step diagram of an adb-based test driving method according to the present invention.
Detailed Description
The embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
The embodiments of the present disclosure are described below with specific examples, and other advantages and effects of the present disclosure will be readily apparent to those skilled in the art from the disclosure in the specification. It is to be understood that the described embodiments are merely illustrative of some, and not restrictive, of the embodiments of the disclosure. The disclosure may be embodied or carried out in various other specific embodiments, and various modifications and changes may be made in the details within the description without departing from the spirit of the disclosure. It is to be noted that the features in the following embodiments and examples may be combined with each other without conflict. All other embodiments, which can be derived by a person skilled in the art from the embodiments disclosed herein without making any creative effort, shall fall within the protection scope of the present disclosure.
The adb-based test driving system is a library developed based on Python, which is a cross-platform computer programming language and is a high-level script language combining interpretability, compilation, interactivity and object-oriented.
The test driving system based on adb comprises an element control searching module, a user event input module, a test auxiliary module and a system operation module, wherein:
the element control searching module is connected with an android System to be tested through an element control searching API (Application Programming Interface), calls a uiautomator, a screen capture instruction and an adb pull (from a mobile phone to a computer) to realize element tree acquisition and screen capture acquisition mainly through a pop method (process I/O function) of an encapsulation use os (Operating System) module, and then encapsulates the element tree and the screen capture acquisition into a required Interface function through Python to provide services for the outside.
The uiautomator is a UI test framework written in Java and released by Google at Andriod version 4.1, and is based on the Accessibility service. The method has the greatest characteristic of cross-process operation, and can use some convenient APIs provided by the UiAutomator framework to carry out a series of automatic test operations on the android application, such as clicking, sliding, keyboard input, long pressing, a common assertion method and the like.
adb pull command: and transmitting the file from the mobile phone to the computer.
And the user event input module is connected with the android system to be tested through a user event input API (application program interface), and realizes a common user event input interface function mainly by packaging a pop method calling input (input) command using the os module and a self-defined command tool.
The test auxiliary module is connected with the android system to be tested through the test auxiliary API, commands such as logcat (log capture command), am and pm are called mainly through a pop method of packaging and using the os module, and corresponding interface functions are realized by searching the API similarly through combining element controls.
am is called activity manager in full and is a very practical command under Android.
The pm tool is called package manager (package manager) for short, and can be used for executing installation of applications, querying information of application treasures, system authority and control applications.
And the system operation module is connected with the android system to be tested through a system operation API, and is mainly used for calling commands such as svc, getprop, setprop, settings, ime, wm, screencap, custom commands and the like by packaging a pop method using the os module to realize corresponding interface functions.
The WIFI switch is a wireless fidelity (WIFI) switch of the svc command line and the GPRS mobile data switch are used for managing power supply control and wireless data.
getprop, the principle of this command is simple, namely to read information from various configuration files of the system.
setprop, sets the attribute value of the specified key.
settings, look at settings cmd.
ime, input method settings.
wm, resolution dependent setting.
The above 4 types of functions are designed in a Python object-oriented manner, are all contained in the TestDriver class, and provide various operation methods to the outside.
An adb-based test driving method, comprising the steps of:
step 1, searching a target control.
Further, the method for searching the target control comprises the following steps:
instantiating a test driver class as a device instance, element location is performed using the method below the device instance. The method refers to all methods under the element control positioning classification, namely all methods included in the element control searching module, the user event input module, the test auxiliary module and the system operation module.
Step 2, carrying out user operation simulation by using a method corresponding to the element;
the positioning mode is selected according to a unique unchanged principle.
And 3, implementing case management and result assertion by using a Python unit test framework.
The case management directly integrates the Testcase under the unit test class, and rewrites the setup, teardown and testXX methods to realize the process description of case precondition, test steps, expected result judgment and the like.
And (4) result assertion: and quoting built-in alert implementation result judgment of python, wherein the judgment is realized by judging whether a certain control exists or not or whether a control text exists or not, and the judgment is determined according to a unique unchanged principle.
The following describes the testing method process in detail by taking the login of the WeChat program for testing the android system as an example:
the use case is divided into 3 parts, setUp, test and teaDown.
setUp:
Initializing a test driver class instance and opening the WeChat application.
Test:
Finding a user name input box by testing a control searching method of a drive class example;
inputting a user name into a user name input box by a text input method of a test drive class example;
finding a password input box by testing a control searching method of a drive class example;
inputting a password into a password input box by testing a text input method of a drive class example;
finding a login button by a control searching method for testing a drive class example;
clicking a login button through a click method of a test drive class instance;
and judging whether the login is successful or not by testing whether the search control method of the drive class instance can find the 'I' button or not.
tearDown:
And closing the WeChat application through an application exit method of the test driving class instance.
A storage medium, in which a computer program is stored, and which is executed, may perform the above-described adb-based test driving method.
In the present invention, unless otherwise expressly stated or limited, the terms "mounted," "connected," "secured," and the like are to be construed broadly and can, for example, be fixedly connected, detachably connected, or integrally formed; may be mechanically coupled, may be electrically coupled or may be in communication with each other; they may be directly connected or indirectly connected through intervening media, or they may be connected internally or in any other suitable relationship, unless expressly stated otherwise. The specific meanings of the above terms in the present invention can be understood by those skilled in the art according to specific situations.
The above description is for the purpose of illustrating embodiments of the invention and is not intended to limit the invention, and it will be apparent to those skilled in the art that any modification, equivalent replacement, or improvement made without departing from the spirit and principle of the invention shall fall within the protection scope of the invention.

Claims (5)

1. The test driving system based on the adb is characterized by comprising an element control searching module, a user event input module, a test auxiliary module and a system operation module, wherein:
the element control searching module is connected with the android system to be tested through the element control searching API, and is mainly used for calling uiautomator, screencap and adb pull commands through a pop method of the packaging and using os module to realize element tree acquisition and screenshot acquisition, and then packaging the element tree and screenshot into a required interface function through Python to provide services for the outside;
the user event input module is connected with the android system to be tested through a user event input API (application program interface), and an input command and a self-defined command tool are called mainly through a pop method packaged and used by the os module to realize a user event input interface function;
the test auxiliary module is connected with the android system to be tested through a test auxiliary API (application programming interface), mainly calls commands such as logcat, am and pm through a pop method of packaging and using an os module, and searches the API by combining element controls to realize corresponding interface functions;
and the system operation module is connected with the android system to be tested through a system operation API, and is mainly used for calling svc, getprop, setprop, settings, ime, wm, screencap and a custom command by packaging a pop method using an os module to realize a corresponding interface function.
2. An adb-based test driving method is characterized by comprising the following steps:
step 1, searching a target control;
step 2, carrying out user operation simulation by using a method corresponding to the element;
and 3, using a Python unit test framework to realize case management and result assertion.
3. The adb-based test driving method of claim 2, wherein the result assertion is implemented by: and quoting built-in alert of python to realize result judgment, and realizing the judgment by judging whether a certain control exists or not or whether a control text exists or not.
4. The adb-based test driving method according to claim 2, wherein the method for finding the target control is as follows: instantiating a test driver class as a device instance, element location is performed using the method below the device instance.
5. A storage medium having a computer program stored therein, wherein the computer program is operable to execute the adb-based test driving method of any one of claims 2 to 4.
CN202011392334.XA 2020-12-01 2020-12-01 Test driving system and method based on adb and storage medium Active CN112463613B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011392334.XA CN112463613B (en) 2020-12-01 2020-12-01 Test driving system and method based on adb and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011392334.XA CN112463613B (en) 2020-12-01 2020-12-01 Test driving system and method based on adb and storage medium

Publications (2)

Publication Number Publication Date
CN112463613A true CN112463613A (en) 2021-03-09
CN112463613B CN112463613B (en) 2023-09-15

Family

ID=74806504

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011392334.XA Active CN112463613B (en) 2020-12-01 2020-12-01 Test driving system and method based on adb and storage medium

Country Status (1)

Country Link
CN (1) CN112463613B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113672519A (en) * 2021-09-08 2021-11-19 湖南惠农科技有限公司 UI automation test method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104331363A (en) * 2014-10-17 2015-02-04 上海斐讯数据通信技术有限公司 Automatic testing method for Android device
CN104834600A (en) * 2015-04-28 2015-08-12 南京邮电大学 Method for testing Android application controls
CN106649107A (en) * 2016-12-09 2017-05-10 武汉斗鱼网络科技有限公司 Automated testing method and device for stability of Android system
CN106776344A (en) * 2017-01-16 2017-05-31 上海聚宝网络科技股份有限公司 A kind of automated testing method of the intelligent express delivery cabinet based on APPIUM
CN108427646A (en) * 2018-04-13 2018-08-21 中国民航信息网络股份有限公司 Android App automated test frames construction method based on Appium and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104331363A (en) * 2014-10-17 2015-02-04 上海斐讯数据通信技术有限公司 Automatic testing method for Android device
CN104834600A (en) * 2015-04-28 2015-08-12 南京邮电大学 Method for testing Android application controls
CN106649107A (en) * 2016-12-09 2017-05-10 武汉斗鱼网络科技有限公司 Automated testing method and device for stability of Android system
CN106776344A (en) * 2017-01-16 2017-05-31 上海聚宝网络科技股份有限公司 A kind of automated testing method of the intelligent express delivery cabinet based on APPIUM
CN108427646A (en) * 2018-04-13 2018-08-21 中国民航信息网络股份有限公司 Android App automated test frames construction method based on Appium and device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113672519A (en) * 2021-09-08 2021-11-19 湖南惠农科技有限公司 UI automation test method and device

Also Published As

Publication number Publication date
CN112463613B (en) 2023-09-15

Similar Documents

Publication Publication Date Title
CN110716715B (en) Application program development method, device, equipment and medium
US20160357519A1 (en) Natural Language Engine for Coding and Debugging
CN108984174B (en) Cross-platform application creation method, device, server and storage medium
EP3971706A2 (en) Method, apparatus and electronic device for deploying operator in deep learning frame work
US9952837B1 (en) Reusable component in a modeling environment
US10078510B1 (en) Late-stage software feature reduction tool for security and performance
US10614227B2 (en) Method and system for identifying functional attributes that change the intended operation of a compiled binary extracted from a target system
US20160321055A1 (en) Mapping between local and remote for seamless build and design time experience
CN112650487B (en) Hybrid application development method, system, computer device and storage medium
CN115437684A (en) File-level clipping method and system for Linux kernel source code
CN115658529A (en) Automatic testing method for user page and related equipment
CN112463613A (en) Test driving system and method based on adb and storage medium
US9817671B2 (en) Rule-based activation of behaviors in an extensible software application
US20060100975A1 (en) Strongly-typed object oriented GUI automation framework
US20230297348A1 (en) Method for operating second system application on first system, terminal device and storage medium
CN114968192A (en) Project creation method and device, computer equipment and storage medium
CN106610845B (en) Information management method, device, server and system
US7428737B1 (en) Method for using header files to call a shared library from a dynamic environment
CN116820811B (en) RPA component variable rapid deriving and assigning method and system based on shear plate
CN104063306A (en) Automatic login method, device and system in intelligent terminal software testing
CN115544518A (en) Vulnerability scanning engine implementation method and device, vulnerability scanning method and electronic equipment
CN115437608A (en) Intelligent research and development assisting method and device
CN113031964B (en) Big data application management method, device, equipment and storage medium
US20110321009A1 (en) Implementing encryption via aspect oriented programming
CN112506519A (en) Compiling method of application program, mobile terminal and server

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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: Room 238, room 406, No.1, Yichuang street, Huangpu District, Guangzhou, Guangdong 510000

Applicant after: Guangzhou langguo Electronic Technology Co.,Ltd.

Address before: Room 238, room 406, No.1, Yichuang street, Huangpu District, Guangzhou, Guangdong 510000

Applicant before: GUANGZHOU LANGO ELECTRONIC SCIENCE & TECHNOLOGY Co.,Ltd.

GR01 Patent grant
GR01 Patent grant