android junit入门(二)Activity测试

测试ACTIVITY

直接上类了

public class TestActivity extends
		ActivityInstrumentationTestCase2<Test1Activity> {
	private Test1Activity mActivity; // the activity under test
	private TextView mView; // the activity's TextView (the only view)
	private String resourceString;

	public TestActivity() {
		super("rod.fasdf", Test1Activity.class);
	}

	@Override
	protected 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());
	}
}

相关推荐