I want to test Fragment.I am able to test Instrumentation test only. I want to perform click and set values for the textview. How can it is possible. Here is my code.Please any one help me to resolve this issue.
@RunWith(AndroidJUnit4.class)
public class LearnFactAdditionTest extends
ActivityInstrumentationTestCase2<MainActivity> {
private MainActivity testingActivity;
private Learn_FactsFragment testFragment;
public LearnFactAdditionTest() {
super(MainActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
testingActivity = getActivity();
testFragment = new Learn_FactsFragment();
testingActivity.getFragmentManager().beginTransaction().add(R.id.frag,testFragment,null).commit();
getInstrumentation().waitForIdleSync();
}
@Test
public void testGameFragmentsTextViews() {
String empty = "";
TextView textView = (TextView)testFragment.getView().findViewById(R.id.txt_first_num_add);
assertTrue("Empty stuff", (textView.getText().equals(empty)));
}
public void testMainThread_operations() {
Espresso.onView(ViewMatchers.withId(R.id.txt_first_num_add))
.perform(ViewActions.typeText("Hi"));
}
}
I am getting error like this No instrumentation registered! Must run under a registering instrumentation.
Aucun commentaire:
Enregistrer un commentaire