I have simple Android application with some espresso tests. I want to write some base class so all of my test classes will inherit its @beforeClass and @afterClass methods, but the problem is when I do it like code example below, JUnit doesn't see any tests at al. I got Empty test suite.
message. What's the problem?
Code example:
public class RealmTest {
protected static Realm realm;
@BeforeClass
public static void beforeClass() {
realm = Realm.getDefaultInstance();
realm.setAutoRefresh(true);
}
@AfterClass
public static void afterClass() {
realm.close();
}
}
@RunWith(AndroidJUnit4.class)
public class MainActivityTest extends RealmTest {
@Rule
public IntentsTestRule<MainActivity> activityTestRule = new IntentsTestRule<>(MainActivity.class);
@Test
public void startedFine() {
assertNotNull(realm);
onView(withId(R.id.button)).perform(click());
intended(hasComponent(new ComponentName(getTargetContext(), EducationActivity.class)));
}
}
If I'll run all tests, tests from MainActivityTest won't run. Thanks for your help, pls say if some additional info is needed.
Aucun commentaire:
Enregistrer un commentaire