E006 Not Found Error: in scala sbt jacoco
E006 Not Found Error: in scala sbt jacoco
我正在尝试在 Scala 中为我的代码编写一些测试
问题是每次我尝试 运行 jacoco with sbt 我都会遇到各种错误。
我正在使用 VSCode 如果这与它有任何关系
这是测试的代码片段
package model
import org.scalatest.Wordspec
import org.scalatest.matchers.should.Matchers._
import model._
class fieldSpec extends WordSpec with Matchers {
"A Field" when {
"not set any value" should {
val emptyField = Field(0)
"have value 0" in {
emptyField.value should be(0)
}
这是我的build.sbt
val scala3Version = "3.1.1"
lazy val root = project
.in(file("."))
.settings(
name := "MADN",
version := "0.1.0-SNAPSHOT",
scalaVersion := scala3Version,
libraryDependencies += "org.scalameta" %% "munit" % "0.7.29" % Test,
libraryDependencies += "org.scalactic" %% "scalactic" % "3.2.11",
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.11" % "test"
)
当我尝试 运行 sbt jacoco 时,我收到此错误消息作为输出
[error] -- [E006] Not Found Error: C:\Software-Engineering\MADN\src\test\scala\model\fieldSpec.scala:7:24
[error] 7 |class fieldSpec extends WordSpec with Matchers {
[error] | ^^^^^^^^
[error] | Not found: type WordSpec
[error] -- [E006] Not Found Error: C:\Software-Engineering\MADN\src\test\scala\model\fieldSpec.scala:7:38
[error] 7 |class fieldSpec extends WordSpec with Matchers {
[error] | ^^^^^^^^
[error] | Not found: type Matchers
[error] -- [E008] Not Found Error: C:\Software-Engineering\MADN\src\test\scala\model\fieldSpec.scala:9:12
[error] 9 | "A Field" when {
[error] | ^^^^^^^^^^^^^^
[error] |value when is not a member of String - did you mean ("A Field" : String).wait?
[error] -- [E006] Not Found Error: C:\Software-Engineering\MADN\src\test\scala\model\fieldSpec.scala:11:23
[error] 11 | val emptyField = Field(0)
[error] | ^^^^^
[error] | Not found: Field
[error] -- [E008] Not Found Error: C:\Software-Engineering\MADN\src\test\scala\model\fieldSpec.scala:12:21
[error] 12 | "have value 0" in {
[error] | ^^^^^^^^^^^^^^^^^
[error] | value in is not a member of String
[error] -- [E008] Not Found Error: C:\Software-Engineering\MADN\src\test\scala\model\fieldSpec.scala:15:19
[error] 15 | "not be set" in {
[error] | ^^^^^^^^^^^^^^^
[error] | value in is not a member of String
[error] -- [E006] Not Found Error: C:\Software-Engineering\MADN\src\test\scala\model\fieldSpec.scala:20:26
[error] 20 | val nonEmptyField = Field(2)
[error] | ^^^^^
[error] | Not found: Field
[error] -- [E008] Not Found Error: C:\Software-Engineering\MADN\src\test\scala\model\fieldSpec.scala:21:26
[error] 21 | "return that value" in {
[error] | ^^^^^^^^^^^^^^^^^^^^^^
[error] | value in is not a member of String
[error] -- [E008] Not Found Error: C:\Software-Engineering\MADN\src\test\scala\model\fieldSpec.scala:24:15
[error] 24 | "be set" in {
[error] | ^^^^^^^^^^^
[error] | value in is not a member of String
[error] 9 errors found
[error] 9 errors found
[error] (Test / compileIncremental) Compilation failed
[error] Total time: 7 s, completed 06.04.2022 14:29:46
我还在 project/plugins.sbt
包含了插件
addSbtPlugin("com.github.sbt" % "sbt-jacoco" % "3.4.0")
我的测试在以下目录中:
src>测试>scala>模型>fieldSpec.scala
所以我可以使用 AnyWordSpec 而不是 WordSpec 来修复它
并从我的 build.sbt
中删除以下行
libraryDependencies += "org.scalameta" %% "munit" % "0.7.29" % Test,
我正在尝试在 Scala 中为我的代码编写一些测试 问题是每次我尝试 运行 jacoco with sbt 我都会遇到各种错误。
我正在使用 VSCode 如果这与它有任何关系
这是测试的代码片段
package model
import org.scalatest.Wordspec
import org.scalatest.matchers.should.Matchers._
import model._
class fieldSpec extends WordSpec with Matchers {
"A Field" when {
"not set any value" should {
val emptyField = Field(0)
"have value 0" in {
emptyField.value should be(0)
}
这是我的build.sbt
val scala3Version = "3.1.1"
lazy val root = project
.in(file("."))
.settings(
name := "MADN",
version := "0.1.0-SNAPSHOT",
scalaVersion := scala3Version,
libraryDependencies += "org.scalameta" %% "munit" % "0.7.29" % Test,
libraryDependencies += "org.scalactic" %% "scalactic" % "3.2.11",
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.11" % "test"
)
当我尝试 运行 sbt jacoco 时,我收到此错误消息作为输出
[error] -- [E006] Not Found Error: C:\Software-Engineering\MADN\src\test\scala\model\fieldSpec.scala:7:24
[error] 7 |class fieldSpec extends WordSpec with Matchers {
[error] | ^^^^^^^^
[error] | Not found: type WordSpec
[error] -- [E006] Not Found Error: C:\Software-Engineering\MADN\src\test\scala\model\fieldSpec.scala:7:38
[error] 7 |class fieldSpec extends WordSpec with Matchers {
[error] | ^^^^^^^^
[error] | Not found: type Matchers
[error] -- [E008] Not Found Error: C:\Software-Engineering\MADN\src\test\scala\model\fieldSpec.scala:9:12
[error] 9 | "A Field" when {
[error] | ^^^^^^^^^^^^^^
[error] |value when is not a member of String - did you mean ("A Field" : String).wait?
[error] -- [E006] Not Found Error: C:\Software-Engineering\MADN\src\test\scala\model\fieldSpec.scala:11:23
[error] 11 | val emptyField = Field(0)
[error] | ^^^^^
[error] | Not found: Field
[error] -- [E008] Not Found Error: C:\Software-Engineering\MADN\src\test\scala\model\fieldSpec.scala:12:21
[error] 12 | "have value 0" in {
[error] | ^^^^^^^^^^^^^^^^^
[error] | value in is not a member of String
[error] -- [E008] Not Found Error: C:\Software-Engineering\MADN\src\test\scala\model\fieldSpec.scala:15:19
[error] 15 | "not be set" in {
[error] | ^^^^^^^^^^^^^^^
[error] | value in is not a member of String
[error] -- [E006] Not Found Error: C:\Software-Engineering\MADN\src\test\scala\model\fieldSpec.scala:20:26
[error] 20 | val nonEmptyField = Field(2)
[error] | ^^^^^
[error] | Not found: Field
[error] -- [E008] Not Found Error: C:\Software-Engineering\MADN\src\test\scala\model\fieldSpec.scala:21:26
[error] 21 | "return that value" in {
[error] | ^^^^^^^^^^^^^^^^^^^^^^
[error] | value in is not a member of String
[error] -- [E008] Not Found Error: C:\Software-Engineering\MADN\src\test\scala\model\fieldSpec.scala:24:15
[error] 24 | "be set" in {
[error] | ^^^^^^^^^^^
[error] | value in is not a member of String
[error] 9 errors found
[error] 9 errors found
[error] (Test / compileIncremental) Compilation failed
[error] Total time: 7 s, completed 06.04.2022 14:29:46
我还在 project/plugins.sbt
包含了插件addSbtPlugin("com.github.sbt" % "sbt-jacoco" % "3.4.0")
我的测试在以下目录中: src>测试>scala>模型>fieldSpec.scala
所以我可以使用 AnyWordSpec 而不是 WordSpec 来修复它 并从我的 build.sbt
中删除以下行libraryDependencies += "org.scalameta" %% "munit" % "0.7.29" % Test,