Ellen Spertus
03/23/2020, 8:56 PMActivityInfo.exported with Mockito. Here’s the relevant part of my code:
private fun makeResolveInfo(appName: String, packageName: String, exported: Boolean = true) : ResolveInfo {
val activityInfo = mock(ActivityInfo::class.java)
`when`(activityInfo.exported).thenReturn(exported)
// code omitted
}
The error is:
org.mockito.exceptions.misusing.MissingMethodInvocationException:
when() requires an argument which has to be 'a method call on a mock'.
For example:
when(mock.getArticles()).thenReturn(articles);
Also, this error might show up because:
1. you stub either of: final/private/equals()/hashCode() methods.
Those methods *cannot* be stubbed/verified.
Mocking methods declared on non-public parent classes is not supported.
2. inside when() you don't call method on mock but on some other object.
Here is the javadoc for the exported getter (which is in ComponentInfo, which ActivityInfo extends): https://developer.android.com/reference/android/content/pm/ComponentInfo#exportedmattinger
03/23/2020, 11:56 PMwhenever instead of having to escape whenEllen Spertus
03/24/2020, 1:04 AMwhen.mattinger
03/24/2020, 3:46 AMmattinger
03/24/2020, 3:51 AMEllen Spertus
03/24/2020, 5:59 PMEllen Spertus
03/24/2020, 5:59 PMmattinger
03/24/2020, 6:01 PMEllen Spertus
03/24/2020, 6:09 PMmattinger
03/24/2020, 6:15 PMEllen Spertus
03/24/2020, 8:36 PM