I know this question is asked so many times, but I still didn't find any solution,
I have used below solution but it still does not help me
How to mock a final class with mockito
in that suggested that you will use mockito 2+ verison, and I am using latest version but stiill nothing same problem is arising, I am using Java not Kotlin
Code is below
@Test
public void isCorrect() {
LoginActivity summaryActivity = mock(LoginActivity.class);
Assert.assertEquals(summaryActivity.getPackageName(), "com.revel.application");
}
I am using Android Studio 3.1.3,
org.mockito:mockito-core:2.9.0,
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "${baseApplicationId}"
minSdkVersion 22
targetSdkVersion 27
still I am getting an error like
Mockito cannot mock/spy because :
- final class
at com.lifescan.reveal.ExampleUnitTest.isCorrect(ExampleUnitTest.java:15)