在使用 Sclatest 进行 BDD 测试时,出现无法检测到 AnyFlatSpec 和 Junit 5 的问题。可能原因是缺少相应的依赖库。解决此问题的方法是在项目的构建配置文件(例如 build.sbt)中添加以下依赖库:
libraryDependencies ++= Seq( "org.scalatest" %% "scalatest" % "3.0.5" % Test, "org.scalatestplus" %% "scalatestplus-junit" % "1.0.0-M2" % Test, "org.junit.jupiter" % "junit-jupiter-engine" % "5.0.2" % Test )
然后重新构建项目,运行测试即可。