Espresso + Junit4 - Login Once Before Running All Test
I want to write some automated test for one of my application. All of the functionality requires login. So, i have written test, but for each test, it is doing login and testing th
Solution 1:
You can use methods with @BeforeClass and @AfterClass annotations.
@RunWith(AndroidJUnit4.class)publicclassAllDisabledTest {
publicstaticfinalStringUSER_NAME="all_disabled";
publicstaticfinalStringDISPLAY_NAME="All Disabled";
publicstaticfinalStringPASSWORD="1234";
@Rulepublic ActivityTestRule<LoginActivity> mActivityRule = newActivityTestRule<>(
LoginActivity.class);
}
@BeforeClasspublicstaticvoidsetUpBeforeClass() {
// do login stuff here
}
@AfterClasspublicstaticvoidtearDownAfterClass() {
// ...
}
// ...
}
Note: @BeforeClass and @AfterClass methods must be static.
Post a Comment for "Espresso + Junit4 - Login Once Before Running All Test"