在scalajs项目的build.sbt中设置'testFrameworks'会在运行test时导致java.lang.NullPointerException

时间:2018-01-18 00:30:13

标签: scala testing sbt scala.js

我是 scala scalajs 的新手。我正在尝试使用minitest将单元测试添加到我的 scalajs 项目中。我按照https://github.com/monix/minitest#usage-in-sbt的说明操作,这就是我的 build.sbt 的样子:

enablePlugins(ScalaJSPlugin, WorkbenchPlugin)
name := "Test"
version := "0.1-SNAPSHOT"
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
  "org.scala-js" %%% "scalajs-dom" % "0.9.1",
  "com.lihaoyi" %%% "scalatags" % "0.6.1",
  "io.monix" %%% "minitest" % "2.0.0" % "test"
)
testFrameworks += new TestFramework("minitest.runner.Framework")

我还有一个 project / build.sbt ,如下所示:

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.17")
addSbtPlugin("com.lihaoyi" % "workbench" % "0.3.0")

当我跑步时:

> sbt test

我看到了这个错误:

java.lang.NullPointerException
at scala.collection.convert.Wrappers$JMapWrapperLike$$anon$2.<init>(Wrappers.scala:265)
at scala.collection.convert.Wrappers$JMapWrapperLike$class.iterator(Wrappers.scala:264)
at scala.collection.convert.Wrappers$JMapWrapper.iterator(Wrappers.scala:275)
at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
at scala.collection.TraversableOnce$class.toMap(TraversableOnce.scala:279)
at scala.collection.AbstractTraversable.toMap(Traversable.scala:105)
at org.scalajs.core.tools.json.Impl$.toMap(Impl.scala:26)
at org.scalajs.core.tools.json.JSONObjExtractor.<init>(JSONObjExtractor.scala:6)
at org.scalajs.testadapter.FrameworkInfo$Deserializer$.deserialize(FrameworkInfo.scala:24)
at org.scalajs.testadapter.FrameworkInfo$Deserializer$.deserialize(FrameworkInfo.scala:22)
at org.scalajs.core.tools.json.package$.fromJSON(package.scala:19)
at org.scalajs.testadapter.ScalaJSFramework.fetchFrameworkInfo(ScalaJSFramework.scala:66)
at org.scalajs.testadapter.ScalaJSFramework.<init>(ScalaJSFramework.scala:37)
at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$76$$anonfun$apply$52.apply(ScalaJSPluginInternal.scala:873)
at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$76$$anonfun$apply$52.apply(ScalaJSPluginInternal.scala:872)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.immutable.Map$Map1.foreach(Map.scala:109)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
at scala.collection.AbstractTraversable.map(Traversable.scala:105)
at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$76.apply(ScalaJSPluginInternal.scala:872)
at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$76.apply(ScalaJSPluginInternal.scala:849)
...

如果我从 build.sbt 中删除此行,我看不到崩溃,但当然我的测试无法运行:

testFrameworks += new TestFramework("minitest.runner.Framework")

这个问题似乎并不特定于 minitest ,因为我也看到了otest。我不确定接下来我应该尝试解决这个问题,所以我很感激任何帮助。

0 个答案:

没有答案