首先AndroidManifest.xml
View Code
添加
编写单元测试代码:
View Code
package com.travelsky.test;import android.app.Activity;import android.test.ActivityInstrumentationTestCase2;import android.widget.TextView;public class Testa extends ActivityInstrumentationTestCase2 { Activity mActivity = null; TextView mView = null; public Testa() { super("com.travelsky.test", AndroidTestActivity.class); // TODO Auto-generated constructor stub } @Override protected void setUp() throws Exception { super.setUp(); mActivity = this.getActivity(); mView = (TextView) mActivity.findViewById(com.travelsky.test.R.id.tv); } public void testPreconditions() { assertNotNull(mView); } @Override protected void tearDown() throws Exception { // TODO Auto-generated method stub super.tearDown(); }}
run