I get a very strange error upon running Test/compile. Everything compiles completely fine if all the classes are located in src/main. However, if any reference (say instantiation) to the classes/traits are done within the src/test, the following errors are emitted:
[error] Error while emitting xxx/PluginSuite.scala
[error] assertion failed: Bad superClass for class StateDiagram: val <none>
Now, Plugin and PluginRouter depend mutually on each other. As stated above, if the client code is written in src/main, no problem arises. But when it is done in the src/test, the above error is emitted.
I have cleaned the cache and many other things, but the error persists.
Here, is the shortened code that reproduces the error:
trait StateDiagram {
self: StateMachine =>
...
}
trait PluginStateDiagram extends StateDiagram {
self: StateMachine =>
...
}
trait Plugin extends StateMachine with PluginStateDiagram {
type S = PluginState
val pluginRouter: PluginRouter
from(any*).to(Initialized) { (x, y) =>
pluginRouter.subscribe(this)
}
}
class NetworkPlugin(val pluginRouter: PluginRouter) extends Plugin {}
class PluginSuite extends FunSuite {
test("RequestManager should not error responses") {
val pluginRouter = new PluginRouter()
// This is where the error occurs. If moved to src/main, it works fine.
val networkPlugin = new NetworkPlugin(pluginRouter)
}
}
build.sbt
lazy val root = (project in file(".")).settings(
inThisBuild(List(organization := "org.naderica", scalaVersion := "3.6.3", name := "brix")),
name := "brix",
libraryDependencies ++= {
val junitV = "4.13.2"
val junitInterfaceV = "0.11"
Seq(
"junit" % "junit" % junitV % Test,
"com.novocode" % "junit-interface" % junitInterfaceV % Test,
"org.scalatest" %% "scalatest" % "latest.integration" % Test,
"org.scalameta" %% "munit" % "latest.integration" % Test,
"org.json" % "json" % "latest.integration",
"io.cequence" %% "openai-scala-client" % "latest.integration",
// "com.theokanning.openai-gpt3-java" % "service" % "latest.integration",
"com.microsoft.playwright" % "playwright" % "latest.integration"
)
},
testOptions += Tests.Argument(TestFrameworks.JUnit, "-v")
)