首页 > 解决方案 > 为什么不 scalatest 编译?

问题描述

我有一个简单的测试设置,比如

package unit

import net.kolotyluk.leaderboard.scorekeeping._
import net.kolotyluk.leaderboard.telemetry.Metrics
import net.kolotyluk.scala.extras.Logging
import org.scalatest.{FlatSpec, GivenWhenThen, Matchers, SequentialNestedSuiteExecution}

import scala.collection.mutable.ArrayBuffer
import scala.concurrent.{Await,Future}
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.{Failure, Random, Success}

class LeaderboardSpec
  extends FlatSpec
    with SequentialNestedSuiteExecution
    with GivenWhenThen
    with Matchers
    with Logging {

  behavior of "Leaderboard"

  it must "handle initial conditions correctly" in {

但是当我尝试编译我的测试时,我得到了 53 个错误,比如

[IJ]sbt:leaderboard> test
[info] Compiling 1 Scala source to C:\Users\ERIC\Documents\git\repos\leaderboard\target\scala-2.12\test-classes ...
[error] C:\Users\ERIC\Documents\git\repos\leaderboard\src\test\scala\unit\LeaderboardSpec.scala:21:12: could not find implicit value for parameter pos: org.scalactic.source.Position
[error]   behavior of "Leaderboard"
[error]            ^

这实际上并没有传达任何有关问题所在的有用信息。我只能假设在我的 build.sbt 文件或其他地方没有正确配置某些东西。

这段代码确实曾经工作过,在我清理东西的过程中,事情发生了变化,现在它在没有良好诊断的情况下被破坏了。

任何人都可以建议要寻找的东西吗?

标签: scalascalatest

解决方案


因此,似乎可以正确编译和运行的一种解决方法是停止使用 SBT 并改用 Maven。

我认为这是迄今为止我在 SBT 中发现的第三个主要缺陷。


推荐阅读