如何在 sbt 控制台加载测试配置 jars

问题描述 投票:0回答:1

我正在尝试在 sbt 控制台(REPL)中编写 scalatest。但 sbt 控制台不会加载标记为“测试配置”的依赖项。 sbt console scala> <console>:12: error: object scalatest is not a member of package org import org.scalatest._ ^ Interpreter encountered errors during initialization! $ sbt sbt:scalatest-example> consoleProject scala> (fullClasspath in Compile).eval.files foreach println /home/ashok/scala/anagram/target/scala-2.12/classes /home/ashok/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.12.8.jar scala> (fullClasspath in Test).eval.files foreach println /home/ashok/scala/anagram/target/scala-2.12/test-classes /home/ashok/scala/anagram/target/scala-2.12/classes /home/ashok/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.12.8.jar /home/ashok/.ivy2/cache/org.scalatest/scalatest_2.12/bundles/scalatest_2.12-3.0.5.jar /home/ashok/.ivy2/cache/org.scalactic/scalactic_2.12/bundles/scalactic_2.12-3.0.5.jar /home/ashok/.ivy2/cache/org.scala-lang/scala-reflect/jars/scala-reflect-2.12.8.jar /home/ashok/.ivy2/cache/org.scala-lang.modules/scala-xml_2.12/bundles/scala-xml_2.12-1.0.6.jar

我找到的解决方法是从 scalatest 中删除 Test 标签。但这并不理想。我想知道是否有更干净的方法,在控制台中加载测试配置。

// libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % Test libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5"


scala sbt scalatest
1个回答
0
投票

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

    

© www.soinside.com 2019 - 2024. All rights reserved.