I am developing an Android application using Kotlin. I am adding instrumented tests into my project. Now, I am looking for a way to enable/disable the logic for launching activity because it can make my test behaving in unexpected ways.
This is my test class
@RunWith(AndroidJUnit4::class)
class LoginFormTest {
@Rule @JvmField
val loginActivityRule: ActivityTestRule<LoginActivity> = ActivityTestRule<LoginActivity>(LoginActivity::class.java)
@Before
fun setUp() {
}
@Test
fun loginFormRendersErrorMessageWhenRequestThrowsError() {
//logic
}
}
That is just the signature of the test class. As you can see in the code, I am testing LoginActivity. LoginAcitivy is starting another activity when a button is clicked. Is there a way to disable activity from being started in the test. Then in another test method, I might enable it again. Is there a way to do that?