Reputation: 4262
I want to integrate powermock to test firebase logic. I tried to run a test and got this:
java.lang.NoClassDefFoundError: org/mockito/cglib/proxy/MethodInterceptor
Here is my app.gradle:
testCompile 'junit:junit:4.12'
testCompile "org.powermock:powermock-module-junit4:1.7.0"
testCompile "org.powermock:powermock-module-junit4-rule:1.7.0"
testCompile "org.powermock:powermock-api-mockito:1.7.0"
testCompile "org.powermock:powermock-classloading-xstream:1.7.0"
testCompile "org.robolectric:robolectric:3.4.2"
testCompile 'org.mockito:mockito-core:2.1.0'
Here is my test:
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class)
@PowerMockIgnore({ "org.mockito.*", "org.robolectric.*", "android.*" })
@PrepareForTest({FirebaseAuth.class, FirebaseDatabase.class})
public class LoginTest {
@Before
public void setUp() {
PowerMockito.mockStatic(FirebaseAuth.class);
Mockito.when(FirebaseAuth.getInstance()).thenReturn(Mockito.mock(FirebaseAuth.class));
}
@Test
public void test() {
}
}
Upvotes: 0
Views: 674
Reputation: 2064
You are using 'org.mockito:mockito-core:2.1.0'
with "org.powermock:powermock-api-mockito:1.7.0"
.
To use PowerMock with Mockito 2 the "org.powermock:powermock-api-mockito2:1.7.0"
should be used.
Upvotes: 2