@Override protected void setUp() throws Exception { super.setUp(); myMainActivity = getActivity(); Bundle args = new Bundle(); Fragment fragment = new AboutFragment(); fragment.setArguments(args); // Insert the fragment by replacing any existing fragment myMainActivity .getSupportFragmentManager() .beginTransaction() .replace(R.id.container, fragment) .commit(); // wait for it to load Thread.sleep(5000); aboutText = (TextView) myMainActivity.findViewById(R.id.textView2); }
/** Test that the about text is what we set it to be.... */ public void testAboutText() { final String expected = myMainActivity.getString(R.string.about_description); final String actual = aboutText.getText().toString(); assertEquals(expected, actual); }