我想开始使用ScalaTest在Scala中编写简单的测试。
但出于某种原因,我可以访问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和其他样式会丢失呢?
运行test在sbt shell上的输出
[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] ^发布于 2020-07-01 15:28:01
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"https://stackoverflow.com/questions/62679932
复制相似问题