I am learning how to test from this section in the tutorial. In the tutorial they say to write the following code in the test's class:
@RunWith(AndroidJUnit4.class)
public class ActivityInputOutputTest {
@Rule
public ActivityTestRule mActivityRule = new ActivityTestRule<>(
MainActivity.class);
}
After I couldn't import ActivityTestRule
properly, I researched and found out here that I should use ActivityScenarioRule
instead of ActivityTestRule
. So the code that I currently have is this:
@RunWith(AndroidJUnit4.class)
public class SpinnerSelectionTest {
@Rule
public ActivityScenarioRule mActivityRule = new ActivityScenarioRule<>(
MainActivity.class);
}
Then, in the tutorial (section 3.2) they say to add this code:
public void iterateSpinnerItems() {
String[] myArray =
mActivityRule.getActivity().getResources()
.getStringArray(R.array.labels_array);
}
Obviusely it doesn't work because my mActivityRule
' type is different from the type in the tutorial.
How can I implement their code where I use
ActivityScenarioRule
as a type tomActivityRule
. Is there equivalent code in my type that can help me?
Aucun commentaire:
Enregistrer un commentaire