Android自动化测试之Athrun<二>:用例分析
如果大家配置好了athrun的测试环境,那么开始吧(这里只介绍有源码的情况,没有源码也是可以做的)
被测应用下载:http://download.csdn.net/detail/wirelessqa/4487252
1. 导入被测试应用-- 新建测试工程-- 依赖被测试应用
测试工程的Manifest.xml
package org.athrun.android.test;import org.athrun.android.framework.AthrunTestCase;import org.athrun.android.framework.Test;import org.athrun.android.framework.viewelement.ScrollViewElement;import android.view.View;import android.widget.ScrollView;/** * TestCases for ScrollViewElement */public class ScrollViewActivityTest extends AthrunTestCase {private static final String LOG_TAG = "ScrollViewActivityTest";public ScrollViewActivityTest() throws Exception {super("org.athrun.android.app", "org.athrun.android.app.MainActivity");}@Testpublic void testFullScroll() throws Exception {findElementById("btn_scrollview_activity").doClick();ScrollViewElement tmtsScrollView = findElementById("ScrollView",ScrollViewElement.class);tmtsScrollView.fullScroll(View.FOCUS_DOWN);}@Testpublic void testScrollTo() throws Exception {findElementById("btn_scrollview_activity").doClick();ScrollViewElement tmtsScrollView = findElementById("ScrollView",ScrollViewElement.class);tmtsScrollView.scrollTo(480, 400);}@Testpublic void testScrollBy() throws Exception {findElementById("btn_scrollview_activity").doClick();ScrollViewElement tmtsScrollView = findElementById("ScrollView",ScrollViewElement.class);tmtsScrollView.scrollBy(480, 400);}@Testpublic void testFullScrollUp() throws Exception {findElementById("btn_scrollview_activity").doClick();findElementById("scroll_button2").doClick();Thread.sleep(10000);}@Testpublic void testFindScrollViewByIndex() throws Exception {findElementByText("ScrollView").doClick();findElementByIndex(0, ScrollView.class, ScrollViewElement.class).scrollBy(0, 400);Thread.sleep(3000);}@Testpublic void testScrollToNextScreen() throws Exception {findElementById("btn_scrollview_activity").doClick();findElementById("ScrollView", ScrollViewElement.class).scrollToNextScreen();Thread.sleep(5000);}}