Top popular android test automation tools introduction
来源:互联网 发布:京瓷打印机扫描软件 编辑:程序博客网 时间:2024/05/19 12:12
Test Automation Mode
Test Frameworks on Android from Google
•Android
•Instrumentation
•ActivityTesting
•Contentprovider Testing
•ServiceTesting
•Monkey and Monkeyrunner
•The UI/ApplicationExerciser Monkey, usually called "monkey", is a command-linetool that sends pseudo-random streams of keystrokes, touches, and gestures to adevice.
•The monkeyrunner tool is an API and execution environment for testprograms written in Python.
•UI Testing–uiautomator
•A Java library containing APIs to create customizedfunctional UI tests, and an execution engine to automate and run the tests
•Espresso
•Fresh start to Android UI test framework fromgoogle
Other Popular Test Frameworks(open source)
•Robotium
•Most popular test framework for android, it supportshybrid application
•Largest users and community
•Instrumentation-based
•UI based
•Athrun
•From Taobao
•For Android andiOS
•Instrumentation-based
•UI based
•Appium
•For Android andiOS
•BDD
•Webdriver
•Android Uiautomator based
•UI based
•Calabash
•BDD
•Similaras S
•Monkeytalk
•UI based functional test tool
•For Android andiOS
•Record and playback
•Agent for app under test
•Instrumentation-based
•Robolectric
•Unit test framework without android DVM
•Mock almost everything
Comparison Matrix
Some popular details
Instrumentation
•InstrumentationTestRunner – the primaryplumbing for running tests on Android
•InstrumentationTestRunner – the primaryplumbing for running tests on Android
•Android Instrumentation Framework isbuilt on top ofJUnit – a standardtest framework on for any Java development
•Mock objects – methods for creatingmock system objects such as content, service and intent.
Android: Uiautomator
•Google’s test framework for testing native Androidapps across device
•Works only on Android API level >=16
•Runs JUnit test cases with specialprivileges(test cases can span across different processes)
•No support for web view (only handleto web view elements as canvas object)
•
code example:// Public void for the operationpublic void testSignInAndTweet() throws Exception { // Starting application: getUiDevice().wakeUp(); // Press Home button to ensure we're on homescreen getUiDevice().pressHome(); // Select 'Apps' and click button new UiObject(new UiSelector().description("Apps")).click(); // Select 'Twitter' and click new UiObject(new UiSelector().text("Twitter")).click(); // Locate and select 'Sign in' UiSelector signIn = new UiSelector().text("Sign In"); // If button is available, click UiObject signInButton = new UiObject(signIn); if (signInButton.exists()) { signInButton.click(); // Set the username new UiObject(newUiSelector().className("android.widget.EditText").instance(0)).setText("username"); new UiObject(new UiSelector().className("android.widget.EditText").instance(1)).setText("password"); new UiObject(new UiSelector().className("android.widget.Button").text("Sign In").instance(0)).click(); // Wait Sign in progress window getUiDevice().waitForWindowUpdate(null, 2000); // Wait for main window getUiDevice().waitForWindowUpdate(null, 30000); } new UiObject(new UiSelector().description("New tweet")).click(); // Typing text for a tweet new UiObject(new UiSelector().className("android.widget.LinearLayout").instance(8)).setText(“Helloworld!"); // Tweeting! new UiObject(new UiSelector().text("Tweet")).click();}Robotium
•Open source library extendingJUnit with plentyof useful methods for Android UI testing
•Powerful and robust automaticblack-box test cases for Android apps
•Supports native, hybrid and mobileweb testing
•Semi-active open source communitywith monthly releases
•Code example:
Google Espresso
// Public void for the operation public void testRobotium() throws Exception { // Wait for the text 'Hello!' to be shown for newbie if (solo.waitForText("Hello!")) { // R class ID identifier for 'Sign in' - and click it solo.clickOnView(solo.findViewById("com.twitter.android.R.id.sign_in")); // R class ID identifier for entering username solo.enterText((EditText) solo.findViewById("com.twitter.android.R.id.login_username"),"username"); // R class ID identifier for entering password solo.enterText((EditText) solo.findViewById("com.twitter.android.R.id.login_password"),"password"); // R class ID identifier for clicking log in solo.clickOnView(solo.findViewById("com.twitter.android.R.id.login_login")); // Wait until log in is done solo.waitForActivity("HomeTabActivity"); } // Activate the text field to compose a tweet solo.clickOnView(solo.findViewById("com.twitter.android.R.id.menu_compose_tweet")); // Type the tweet solo.enterText((EditText) solo.findViewById("com.twitter.android.R.id.edit"), “hello"); // Tweeting! solo.clickOnView(solo.findViewById("com.twitter.android.R.id.composer_post")); }
Google Espresso
•The latest Android test automationframework from Google
•A custom InstrumentationTestrunner with specialprivileges
•Thin layer on top of AndroidInstrumentation Framework
•Easy API for extending theframework:
•You can write new matchers:onView(Matcher<View>)
•You can write new actions: perform(ViewAction)
•You can write new checks: check(ViewAssertion)
•Reliable: Synchronizes with the UIthread
•It’s fast because there is no needfor any sleeps (tests run on same millisecond when the app becomes idle)
•No support for web views
Code example:public void testSayHello() { onView(withId(R.id.name_field)).perform(typeText("Steve")); onView(withId(R.id.greet_button)).perform(click()); onView(withText("Hello Steve!")) .check(matches(isDisplayed()));}
Appium
•Uses Selenium Webdriver (W3C standard) as ascripting framework
•Supports native Android, native iOS and mobile web:
•Android via uiautomator (API level >=16) and Selendroid(API level <16)
•iOS via UI Automation
•Mobile web as Selenium driver for Android and iOS
•You can write your Appium scripts on almost anyprogramming language (Haskell/Go/Clojure/Java/Ruby)
•code example:
# wait for hellosleep(3)textFields = driver.find_elements_by_tag_name('textField')assertEqual(textFields[0].get_attribute("value"), "Hello")# click sign-in buttondriver.find_elements_by_name('Sign in')[0].click()# find the text fields again, and enter username and passwordtextFields = driver.find_elements_by_tag_name('textField')textFields[0].send_keys("twitter_username")textFields[1].send_keys("passw0rd")# click the Login button (the first button in the view)driver.find_elements_by_tag_name('button')[0].click()# sleep sleep(3)# click the first button with name "Compose"driver.find_elements_by_name('Compose')[0].click()# type in the tweet messagedriver.find_elements_by_tag_name('textField')[0].send_keys(”Helloworld!")# press the Send buttondriver.find_elements_by_name('Send')[0].click()# exitdriver.quit()
0 0
- Top popular android test automation tools introduction
- Test Automation tools: trends
- Test Automation Tools
- Future of Test Automation Tools & Infrastructure
- Agile-Friendly Test Automation Tools/Frameworks
- My top ten list for a successful test automation strategy
- Automation Test
- Automation Test
- Android automation test without target application src
- Android Test Automation Robotium VS. UIAutomator
- 构建android UI automation test测试环境
- UI Automation Introduction.
- Several Popular VoIP Tools
- Android CTS (Compatibility Test Suite) introduction
- Android CTS (Compatibility Test Suite) introduction
- Mobile Automation testing Tools
- Xamarin.Android + Build/Test Cloud TFS Automation - Issues and Workground
- 转 Test Automation Frameworks
- U3D开发点滴-延迟物体消失
- UFLDL部分函数用法
- 汉明码与交织技术
- 控制器模块和操作
- cas client入门之二:web.xml 配置
- Top popular android test automation tools introduction
- 集合Map常用取值方法:
- crm2011查询表的关联关系
- 那年花开,徒惹是非
- 康托展开与其逆运算
- CISCO Configuration Examples and TechNotes
- Arcgis Add-In开发入门实例
- Oracle常见面试题
- 如何规范自己的技术博客