Android Automation Business Layer test interface

Source: Internet
Author: User

Android Automation Business Layer test interface

Basic knowledge Before you read:

1. The execution of the Uiautomator script is performed by a shell command, and passing parameters to the executing method is also through the shell command

2 the class to which the execution method is to be adjusted must inherit the Uiatestcasel class

3. Within the method, the function obtains externally passed parameters through the bundle, rather than passing them through the function arguments.

Throw the question:

In the new automated testing framework, the business layer is at the API level and is not inherited from the Uiatestcasel class (Com.android.uiautomator.testrunner.UiAutomatorTestCase)

1. The business API does not support external execution of business APIs through commands or other means, and if each time a case is constructed to test the business API, the test development efficiency of the business API is severely impacted

2. Uiautomator execution only supports passing parameters and obtaining parameters through the shell through the bundle, and does not support the direct parameter mode of the business API.

3. Shell executes uiautomator, passing parameters can only pass strings, while the parameters of the business API are changeable, including int boolean string string[], etc.

Solution:

1. For the first issue, the business API cannot be directly tuned externally, using the Java reflection mechanism to externally tune the business API:

Create a new unified business API to access the class agent, inheriting the Uiatestcasel class so that it can be picked up by an external shell command

Pass the object and method parameters to the bundle externally through the command, get the bundle in the Agent class entry method and parse out the classpath and methods name of the API to be tested

Called locally by reflection, based on the Classpath and the method name

2. For uiautomator execution, pass-through parameters can only pass strings, not the number of parameters and types of Business API, the use of adding a middle layer, processed and passed to the business Layer API

First, the list of parameter types is obtained based on the business API method.

Converts the value of ' P{index} ' in the bundle to the corresponding type according to the type of each parameter and the ordinal of the parameter ({index})

Put all the converted parameters into one object and then load them into the business API by reflection

demo:adb Shell uiautomator runtest iqiyiappautomatedtest.jar-c com.qiyi.library.base.agent#entry-e Object ReaderB Usiness-e method Runtest0-e P0 [0,1,3]-e p1 [Rer,re,re]

3. The values in the bundle are passed through the shell command, and some characters in the shell command are used to resolve the list characters by building the escape character.

Bundles are preprocessed before use, replacing the custom escape characters in them; now some escape characters are shown in the table below

character the corresponding escape character
Space {{SPACE}}
Null character {{EMPTY}}
Single quotation marks {{Singlequotes}}
Double quotes {{Doublequotes}}
Opening parenthesis {{Leftparenthesis}}
Closing parenthesis {{Rightparenthesis}}

demo:adb Shell uiautomator runtest iqiyiappautomatedtest.jar-c Com.qiyi.library.base.agent#entry-e Object Readerbusiness-e Method Runtest1-e P0 {{leftparenthesis}}who{{leftparenthesis}}

CODE Link:http://files.cnblogs.com/files/udld/agent_uiautomator.rar

Android Automation Business Layer test interface

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.