PowerMockito 给出 NoClassDefFoundError [英] PowerMockito gives NoClassDefFoundError

查看:156
本文介绍了PowerMockito 给出 NoClassDefFoundError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Mockito 和 PowerMockito 设置单元测试,但它抛出:

I'm trying to set up a unit test with Mockito and PowerMockito, but it throws:

线程main"中的异常java.lang.NoClassDefFoundError:org/mockito/exceptions/Reporter

Exception in thread "main" java.lang.NoClassDefFoundError: org/mockito/exceptions/Reporter

每当我尝试运行测试时.这些是我的依赖项:

whenever I try to run a test. These are my dependencies:

testCompile 'org.mockito:mockito-core:2.8.9'
testCompile 'org.powermock:powermock-api-mockito2:1.6.5'
testCompile 'org.powermock:powermock-module-junit4:1.7.4'

有人知道怎么解决吗?

推荐答案

您似乎正在尝试使用不兼容的版本.

It seems you are trying to use incompatible versions.

根据这个,你需要使用版本1.7.x 的 Powermock,以便与您的 Mockito 版本 2.8.9 兼容.

According to this table, you need to use version 1.7.x of Powermock in order to be compatible with your Mockito version 2.8.9.

这篇关于PowerMockito 给出 NoClassDefFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆