即使已导入ScalaTest,也缺少FunSuite
我想开始使用ScalaTest在Scala中编写简单的测试。即使已导入ScalaTest,也缺少FunSuite,scala,scalatest,Scala,Scalatest,我想开始使用ScalaTest在Scala中编写简单的测试。 但由于某些原因,我可以访问org.scalatest,但不能访问org.scalatest.FunSuite 这就是我的build.sbt的外观: name := "Algorithms" version := "0.1" scalaVersion := "2.13.3" libraryDependencies += "org.scalactic"
但由于某些原因,我可以访问
org.scalatest
,但不能访问org.scalatest.FunSuite
这就是我的
build.sbt
的外观:
name := "Algorithms"
version := "0.1"
scalaVersion := "2.13.3"
libraryDependencies += "org.scalactic" %% "scalactic" % "3.2.0"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.0" % "test"
我不明白它是否可以访问scalatest
,那么为什么FunSuite
、FlatSpec
和其他样式会丢失呢
在sbt外壳上运行test
的输出
[error] <Project Path>\Algorithms\src\test\scala\Course1\Week1\MaxPairProductTest.scala:3:48: type FunSuite is not a member of package org.scalatest
[error] class MaxPairProductTest extends org.scalatest.FunSuite {
[error] ^
[错误]\Algorithms\src\test\scala\Course1\Week1\MaxPairProductTest.scala:3:48:type FunSuite不是包org.scalatest的成员
[错误]类MaxPairProductTest扩展org.scalatest.FunSuite{
[错误]^
ScalaTest 3.2.0已经完成了先前版本中的monolith
ScalaTest 3.2.0的主要变化是实现了模块化
这是我们在3.0.8和3.1.0中准备的。因此,许多人不赞成
名称已被删除,因为不推荐会跨模块
边界
这意味着,在3.1.0中,以下定义
import org.scalatest.FunSuite
class ExampleSuite310 extends FunSuite {}
只会引起反对通知
The org.scalatest.FunSuite trait has been moved and renamed. Please use org.scalatest.funsuite.AnyFunSuite instead. This can be rewritten automatically with autofix: https://github.com/scalatest/autofix/tree/master/3.1.x", "3.1.0"
在3.2.0中,它已被完全删除。因此,从3.2.0开始,您应该这样定义
import org.scalatest.funsuite.AnyFunSuite
class ExampleSuite320 extends AnyFunSuite {}
有关新名称的完整列表,请参阅
注意,我们仍然可以导入一个工件,该工件将传递地拉取所有子工件
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.0" % "test"
但是现在我们也可以选择只依赖于特定的子工件
libraryDependencies += "org.scalatest" %% "scalatest-funsuite" % "3.2.0" % "test"
非常感谢。这解决了问题。但是,为什么我没有收到取消资格通知?甚至连网站的说明都没有提到这一点。@VarunGawande弃用警告似乎在3.1.0中对我有效。尝试使用;clean;set Test/scalacOptions+=“-弃用”;测试/编译;
。确实,网站在一些地方似乎已经过时,但scaladoc似乎维护得很好。就我个人而言,我一直在关注哪些网站应该有最新的信息。可能Scala官方文档中的本教程需要更新-:-|