An exception or error caused a run to abort: org.mockito.internal.progress.ThreadSafeMockingProgress.mockingProgress()L

做~自己de王妃 提交于 2021-01-28 09:02:01

问题


My environment is Intellij, SBT, Scala and Play.

What might be causing the following exception? It doesn't happen all the time. At times I am unable to run my test cases due to the following exception.

I am using "org.mockito" % "mockito-core" % "2.24.5" % "test",

I suspect there might be some library mismatch or inconsistency but I can't figure out what it is? I have tried to clean/recompile the project (sbt) but haven't been able to solve the issue.

An exception or error caused a run to abort: org.mockito.internal.progress.ThreadSafeMockingProgress.mockingProgress()Lorg/mockito/internal/progress/MockingProgress; 
java.lang.NoSuchMethodError: org.mockito.internal.progress.ThreadSafeMockingProgress.mockingProgress()Lorg/mockito/internal/progress/MockingProgress;
    at org.mockito.ArgumentMatchers.reportMatcher(ArgumentMatchers.java:1329)
    at org.mockito.ArgumentMatchers.anyObject(ArgumentMatchers.java:165)
    at org.mockito.ArgumentMatchers.any(ArgumentMatchers.java:145)
    at UnitSpecs.TestEnv.<init>(TestEnv.scala:77)
    at UnitSpecs.ServiceSpecs.ServicesTestEnv.<init>(ServicesTestEnv.scala:17)
    at UnitSpecs.ServiceSpecs.CassandraConnectionServiceSpecs.<init>(CassandraConnectionServiceSpecs.scala:76)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at org.scalatest.tools.Runner$.genSuiteConfig(Runner.scala:1422)
    at org.scalatest.tools.Runner$.$anonfun$doRunRunRunDaDoRunRun$8(Runner.scala:1236)
    at scala.collection.immutable.List.map(List.scala:283)
    at org.scalatest.tools.Runner$.doRunRunRunDaDoRunRun(Runner.scala:1235)
    at org.scalatest.tools.Runner$.$anonfun$runOptionallyWithPassFailReporter$24(Runner.scala:1031)
    at org.scalatest.tools.Runner$.$anonfun$runOptionallyWithPassFailReporter$24$adapted(Runner.scala:1010)
    at org.scalatest.tools.Runner$.withClassLoaderAndDispatchReporter(Runner.scala:1500)
    at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:1010)
    at org.scalatest.tools.Runner$.run(Runner.scala:850)
    at org.scalatest.tools.Runner.run(Runner.scala)
    at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.runScalaTest2(ScalaTestRunner.java:133)
    at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.main(ScalaTestRunner.java:27)

The call chain is my test case calls

  val servicesTestEnv = new ServicesTestEnv(Some(cqlStartupStatements),components)

which calls

val testEnv = new TestEnv(components=components)

which calls

  when(mockHelperMethods.bucketIDFromEmail(ArgumentMatchers.any[String]())).thenReturn(1)

and then the exception

java.lang.NoSuchMethodError: org.mockito.internal.progress.ThreadSafeMockingProgress.mockingProgress()Lorg/mockito/internal/progress/MockingProgress;
    at org.mockito.ArgumentMatchers.reportMatcher(ArgumentMatchers.java:1329)
    at org.mockito.ArgumentMatchers.anyObject(ArgumentMatchers.java:165)
    at org.mockito.ArgumentMatchers.any(ArgumentMatchers.java:145)

The method mockingProgress is defined in ThreadSafeMockingProgress.java at C:\Users\manuc\.ivy2\cache\org.mockito\mockito-core\srcs\mockito-core-2.24.5-sources.jar!\org\mockito\internal\progress\ThreadSafeMockingProgress.java


回答1:


I don't know what was the issue but there were two Mockito libraries (1.1. and 2.45., not exact versions. I think the 1.1 was getting picked. I deleted that by going to File -> Project Structure and removed the 1.1 version. Image below.



来源:https://stackoverflow.com/questions/62750154/an-exception-or-error-caused-a-run-to-abort-org-mockito-internal-progress-threa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!