开发者

Launching app and executing some test cases with Robotium

开发者 https://www.devze.com 2023-04-12 10:45 出处:网络
I am new to Robotium and tried to execute following code to launch an app and perform some functions.

I am new to Robotium and tried to execute following code to launch an app and perform some functions.

An example would be, launch messaging app on android emulator and send a text message "Hi" to a user "test".

     package com.example.android.test;


     import com.example.android.NewUserActivity;
     import com.jayway.android.robotium.solo.Solo;
     import android.test.ActivityInstrumentationTestCase2;

public class NewUserActivityTest extends ActivityInstrumentationTestCase2<NewUserActivity> {

private Solo solo;

public NewUserActivityTest() {

super("com.example.android", NewUserActivity.class);
}

public void setUp() throws Exception {
    super.setUp();
    solo = new Solo(getInstrumentation(), getActivity()); 
    }
    @Override
    public void tearDown() throws Exception {
    try {
    solo.finalize();
    } catch (Throwable e) {
    e.printStackTrace();
    }
    getActivity().finish();
    super.tearDown();
    }

 public void sms() throws Exception{
        assertTrue(solo.searchText("Messaging"));
        solo.clickOnText("Messaging");
        assertTrue(solo.searchText("New message"));
        solo.clickOnButton("New message");
        solo.enterText(0, "Test");
         开发者_高级运维solo.enterText(1, "Hi");

    }
    }

With this code, Eclipse runs the test cases but I don't see it on emulator. I understand the package here is a dummy one, I want to know If I am doing it wrong?


Test methods that you want to be executed must have the prefix "test", e.g. "testSms".

0

精彩评论

暂无评论...
验证码 换一张
取 消