【问题标题】:Scalatest problem : value FunSuite is not a member of org.scalatestScalatest 问题:价值 FunSuite 不是 org.scalatest 的成员
【发布时间】:2022-01-15 16:46:56
【问题描述】:

我正在尝试在 Scala 3 中为我的项目编写测试。我将 Scalatest 库添加为:

libraryDependencies ++= Seq( 
   ....
  "org.scalatest"           %% "scalatest"                  % "3.2.9"   % Test
)

我知道我的结构是正确的:

但它给了我错误:

value FunSuite 不是 org.scalatest 的成员 - 您是说 scalatest.funsuite 吗?

但是,我在另一个项目中使用了相同的方法,并且效果很好。

【问题讨论】:

  • 我猜你需要导入org.scalatest.funsuite.AnyFunSuite并使用它。
  • 谢谢约翰尼!有用。但是为什么所有站点示例都基于org.scalatest.FunSuite
  • 不知道。但是单击Getting started with FunSuite 中第一次提到FunSuite,确实会让您进入AnyFunSuite 的scaladoc。但是那里的示例代码使用了 FunSuite。
  • 如果你回答,我会接受。
  • 我猜这个问题与他们更新文档的方式中的一些错误有关。也许您可以在他们的 Github 存储库中提出问题?

标签: scala scalatest


【解决方案1】:

感谢@Johney

正确用法如下(至少在scala 3.0.2中):

import org.scalatest.funsuite.*

class TestParser extends AnyFunSuite {
}

当然,诸如Getting started with FunSuite 之类的教程是基于import org.scalatest.FunSuite,但正确的例子是here,这也是Getting started with FunSuite 中第一次提到FunSuite

【讨论】:

    猜你喜欢
    • 2021-08-29
    • 2017-11-09
    • 2016-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-20
    相关资源
    最近更新 更多