Reputation: 774
This question is about android unit test MVP
In test class i need to call openactivity method which is in presenter class
and that method will open an activity using view.openCheckoutShippingActivity() method .
How to check is it opened or not using mockito
Upvotes: 0
Views: 190
Reputation: 8371
You cannot perform unit tests on Android specific elements. You should use instrumented tests. These tests run on a device or emulator. Android's official instrumented test framework is Espresso. It's pretty easy actually. An example:
@Test
fun greeterSaysHello() {
onView(withId(R.id.name_field)).perform(typeText("Steve"))
onView(withId(R.id.greet_button)).perform(click())
onView(withText("Hello Steve!")).check(matches(isDisplayed()))
}
That's from the official documentation.
As for your specific question, please refer tho this link.
And also be careful, this tests run under the androidtest
package and not in the test
package.
Edit
i need to call openactivity method which is in presenter class and that method will open an activity
I'm not sure if you are doing it right. The activity should open from the View
and not from the Presenter
.
Upvotes: 1