gpt4 book ai didi

scala - 如何在 Scala 原生应用程序中运行 Scala 测试?

转载 作者:行者123 更新时间:2023-12-04 15:59:47 24 4
gpt4 key购买 nike

我有 hello world scala native 应用程序,想对此应用程序运行小型 scala 测试我使用通常的测试命令,但它抛出异常:

NativeMain.scala

object NativeMain {
val p = new Person("xxxx")

def main(args: Array[String]): Unit = {
println("Hello world")
}
}
class Person(var name: String)
}

NativeTest.scala

import org.scalatest.{FlatSpec, Matchers}

class NativeTest extends FlatSpec with Matchers {

"name" should "the name is set correctly in constructor" in {
assert(NativeMain.p.name == "xxxx")
}
}

我在 sbt shell 中运行 test 命令并得到这个错误

[IJ]> test
[info] Compiling 1 Scala source to /home/****/Documents/ScalaNativeFresh/target/scala-2.11/classes...
[info] Compiling 1 Scala source to /home/****/Documents/ScalaNativeFresh/target/scala-2.11/test-classes...
[info] Compiling 1 Scala source to /home/****/Documents/ScalaNativeFresh/target/scala-2.11/test-classes...
[info] Linking (28516 ms)
[error] cannot link: @java.lang.Thread::getStackTrace_scala.scalanative.runtime.ObjectArray
[error] unable to link
[error] (nativetest:nativeLink) unable to link
[error] Total time: 117 s, completed Apr 2, 2019 3:04:24 PM

任何帮助或建议,谢谢 :)?

最佳答案

有一个 Unresolved 问题要添加Add support for Scala Native #111 2 并根据 cheeseng :

3.1.0-SNAP6 and 3.2.0-SNAP10 are the only 2 versions (as of the time of writing) that supports scala-native

像这样尝试导入 scalatest_native0.3_2.11

libraryDependencies += "org.scalatest" % "scalatest_native0.3_2.11" % "3.2.0-SNAP10"

scalatest-native-example是一个工作示例,展示了如何将 scalatest 与 scala-native 结合使用。

关于scala - 如何在 Scala 原生应用程序中运行 Scala 测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55474515/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com