即使导入了 ScalaTest,FunSuite 也不见了

FunSuite missing even though ScalaTest is imported

我想开始使用 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等样式不见了?

运行 testsbt 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]                                                ^

ScalaTest 3.2.0 已完成 modularisation 之前版本

的单体应用

The main change in ScalaTest 3.2.0 is carrying out the modularization that we prepared for in 3.0.8 and 3.1.0. As a result, many deprecated names have been removed, because the deprecations would cross module boundaries.

这意味着在 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 {}

有关新名称的完整列表,请参阅 deprecations expirations

请注意,我们仍然可以导入单个工件,它将传递地拉取所有子工件

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.0" % "test"

但是现在我们也可以选择只依赖于特定的子工件

libraryDependencies += "org.scalatest" %% "scalatest-funsuite" % "3.2.0" % "test"