Java 当存在对mockito核心的依赖项时,测试不会运行

Java 当存在对mockito核心的依赖项时,测试不会运行,java,maven,mockito,powermockito,Java,Maven,Mockito,Powermockito,我已经将mockito-core添加到依赖项中,但我似乎无法运行测试(运行时出现错误),除非我还将powermock-api-mockito添加到依赖项中。我在放入mockito核心依赖项后立即开始出现错误-无需进行其他更改(例如,我不需要添加使用mockito开始看到错误的代码) 我要添加的依赖项: <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-

我已经将
mockito-core
添加到依赖项中,但我似乎无法运行测试(运行时出现错误),除非我还将
powermock-api-mockito
添加到依赖项中。我在放入
mockito核心
依赖项后立即开始出现错误-无需进行其他更改(例如,我不需要添加使用mockito开始看到错误的代码)

我要添加的依赖项:

  <dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-core</artifactId>
    <version>1.10.19</version>
    <scope>test</scope>
  </dependency>
这是:

java.lang.NoClassDefFoundError: org/junit/internal/matchers/StacktracePrintingMatcher

    at org.junit.matchers.JUnitMatchers.isThrowable(JUnitMatchers.java:103)
    at org.junit.rules.ExpectedExceptionMatcherBuilder.build(ExpectedExceptionMatcherBuilder.java:27)
    at org.junit.rules.ExpectedException.handleException(ExpectedException.java:252)
    at org.junit.rules.ExpectedException.access$000(ExpectedException.java:106)
    at org.junit.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:241)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

这应该通过使用mockito all而不是mockito core来解决。它将具有mockito所需的所有依赖项。hamcrest和junit是其中的一部分。

这应该通过使用mockito all而不是mockito core来解决。它将具有mockito所需的所有依赖项。hamcrest和junit是它的一部分。

Mockito核心1.10.19与powermock api Mockito没有依赖关系。它唯一的依赖项是以下运行时依赖项:

  • org.hamcrest»hamcrest核心1.1
  • org.objeness»objeness 2.1
这些可能与依赖关系树中的另一个库冲突。尝试使用以下方法分析依赖关系树:

mvn dependency:tree

Mockito核心1.10.19与powermock api Mockito没有依赖关系。它唯一的依赖项是以下运行时依赖项:

  • org.hamcrest»hamcrest核心1.1
  • org.objeness»objeness 2.1
这些可能与依赖关系树中的另一个库冲突。尝试使用以下方法分析依赖关系树:

mvn dependency:tree

正如您在此处所读的“获取Mockito的推荐方法是使用您喜爱的生成系统声明对“Mockito core”库的依赖关系。”正如您在此处所读的“获取Mockito的推荐方法是使用您喜爱的生成系统声明对“Mockito core”库的依赖关系。”
mvn dependency:tree