下面是测试代码的例子: package com.yourcompany.yourtestname; iimport android.test.ActivityInstrumentationTestCase2; import com.jayway.android.robotium.solo.Solo; public class testcase extends ActivityInstrumentationTestCase2 { private static final String TARGET_PACKAGE_ID = "cn.test.filldata"; private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "cn.test.filldata.FillData"; private static Class launcherActivityClass; static { try { launcherActivityClass = Class .forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } public testcase() throws ClassNotFoundException{ super(TARGET_PACKAGE_ID, launcherActivityClass); } private Solo solo; protected void setUp() throws Exception { solo = new Solo(getInstrumentation(), getActivity()); solo.sleep(5000); // super.setUp(); } public void teststartfill(){ solo.clickOnScreen(78, 450); solo.sleep(5000); } protected void tearDown() throws Exception { try { solo.finalize(); //Robotium will finish all the activities that have been open } catch (Throwable e) { e.printStackTrace(); } getActivity().finish(); super.tearDown(); } }
robotium在无APK源码时的测试代码
最新推荐文章于 2023-02-16 11:42:16 发布