在IntelliJ中运行Specs2失败。通过SBT任务手动运行相同的测试工作正常,没有任何问题。
这是一种常见的错误响应,但看起来很多其他人的根本原因是不同的。我之前已对此问题进行了问题排查,并通过将以下内容添加到build.sbt
:
fork in Test := false
parallelExecution in Test := false
现在测试再次失败。我查看了build.sbt
文件的修订历史记录,但是我没有注意到会引发这种回归的任何重大事件,而且我没有任何线索。
在步骤调试崩溃后,我找到了以下根本原因:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.specs2.reflect.Classes$class.createInstanceFor(Classes.scala:154)
at org.specs2.reflect.Classes$.createInstanceFor(Classes.scala:207)
at org.specs2.reflect.Classes$$anonfun$createInstanceOfEither$1.apply(Classes.scala:145)
at org.specs2.reflect.Classes$$anonfun$createInstanceOfEither$1.apply(Classes.scala:145)
at scala.Option.map(Option.scala:146)
at org.specs2.reflect.Classes$class.createInstanceOfEither(Classes.scala:145)
at org.specs2.reflect.Classes$.createInstanceOfEither(Classes.scala:207)
at org.specs2.reflect.Classes$class.org$specs2$reflect$Classes$$createInstanceForConstructor(Classes.scala:118)
at org.specs2.reflect.Classes$$anonfun$4.apply(Classes.scala:98)
at org.specs2.reflect.Classes$$anonfun$4.apply(Classes.scala:98)
at scala.collection.immutable.List.map(List.scala:273)
at org.specs2.reflect.Classes$class.tryToCreateObjectEither(Classes.scala:98)
at org.specs2.reflect.Classes$.tryToCreateObjectEither(Classes.scala:207)
at org.specs2.reflect.Classes$class.tryToCreateObject(Classes.scala:70)
at org.specs2.reflect.Classes$.tryToCreateObject(Classes.scala:207)
at org.specs2.specification.SpecificationStructure$.createSpecificationFromClassOrObject(BaseSpecification.scala:126)
at org.specs2.specification.SpecificationStructure$.createSpecificationOption(BaseSpecification.scala:107)
at org.specs2.specification.SpecificationStructure$.createSpecification(BaseSpecification.scala:95)
at org.specs2.runner.ClassRunner.createSpecification(ClassRunner.scala:60)
at org.specs2.runner.ClassRunner.start(ClassRunner.scala:31)
at org.specs2.runner.NotifierRunner.start(NotifierRunner.scala:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.jetbrains.plugins.scala.testingSupport.specs2.JavaSpecs2Runner.runSpecs2_old(JavaSpecs2Runner.java:133)
at org.jetbrains.plugins.scala.testingSupport.specs2.JavaSpecs2Runner.runSingleTest(JavaSpecs2Runner.java:204)
at org.jetbrains.plugins.scala.testingSupport.specs2.JavaSpecs2Runner.main(JavaSpecs2Runner.java:85)
Caused by: java.lang.IncompatibleClassChangeError: Found class scalaz.Tree, but interface was expected
at org.specs2.mutable.SideEffectingCreationPaths$class.$init$(FragmentsBuilder.scala:245)
at org.specs2.mutable.Specification.<init>(Specification.scala:12)
at controllers.VerificationApiSpec.<init>(VerificationApiSpec.scala:26)
... 32 more
scalaz.Tree
是我项目中许多其他依赖项的传递依赖项,它们请求的版本包括7.1.1
,7.1.2
,7.1.3
,7.0.6
{{1} }}。值得注意的是,在scalaz
7.0.x
中有一个特征(Java俗语中的界面),但是scalaz.Tree
中的抽象类,所以这可能构成了根本原因。
是否可以解决此问题,因为传递依赖项与scalaz 7.1.x
和7.1.x
存在明显不兼容的冲突?
答案 0 :(得分:3)
Specs2 2.4.17
使用Scalaz 7.1.0
。构建中的其他依赖项可能会拖动Scalaz 7.2.x
依赖项。我建议您将specs2
版本更新为3.8.4
,这会将更新版本的Scalaz纳入范围。