读书人

android junit入门(2)Activity测试

发布时间: 2012-07-15 20:11:40 作者: rapoo

android junit入门(二)Activity测试
测试ACTIVITY

直接上类了

public class TestActivity extendsActivityInstrumentationTestCase2<Test1Activity> {private Test1Activity mActivity; // the activity under testprivate TextView mView; // the activity's TextView (the only view)private String resourceString;public TestActivity() {super("rod.fasdf", Test1Activity.class);}@Overrideprotected void setUp() throws Exception {super.setUp();mActivity = getActivity();mView = (TextView) mActivity.findViewById(R.id.test_id);resourceString = mActivity.getString(R.string.hello);}public void testPreconditions() {assertNotNull(mView);}public void testText() {assertEquals(resourceString, (String) mView.getText());}}

读书人网 >Android

热点推荐