使用SBT依赖项的{test`配置的类路径

时间:2016-12-05 21:16:13

标签: scala testing mocking sbt

我依赖于scala库,并且在其测试中有一个我想要使用的模拟对象。我现在只是将它手工复制到我的项目测试目录中。

我的问题是:是否可以从我正在使用的库的测试配置中导入模拟? (我试过'只是导入'但它在编译步骤中找不到它)

1 个答案:

答案 0 :(得分:1)

是的,这是可能的。您需要使用备用的常春藤配置映射。这就是它的样子:

libraryDependencies += "org.scalatest" %% "scalatest" % "2.1.3" % "test->compile"

在此示例中,项目主(“编译”)配置将取决于依赖项的常春藤“测试”配置。如果你还想要标准依赖,你可以拼写出来:

libraryDependencies += "org.scalatest" %% "scalatest" % "2.1.3" % "test->compile;compile->compile"

有关详细信息,请参阅sbt documentation