I am trying to write some tests for my code in scala the problem is everytime i try to run jacoco with sbt I am getting all kinds of errors.
I am using VSCode if that has anything to do with it
This is a code snippet of the test
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)
}
This is my 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"
)
When I am trying to run sbt jacoco I get this error message as an output
[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
I also included the plugin at project/plugins.sbt
addSbtPlugin("com.github.sbt" % "sbt-jacoco" % "3.4.0")
My tests are in the following directory: src>test>scala>model>fieldSpec.scala
CodePudding user response:
So I was able to fix it by using AnyWordSpec instead of just WordSpec and also by deleting the following line out of my build.sbt
libraryDependencies = "org.scalameta" %% "munit" % "0.7.29" % Test,