多项目中的 SBT 测试依赖关系:使测试代码可用于依赖项目 [英] SBT Test-Dependencies in Multiprojects: Make the Test-Code Available to Dependent Projects

查看:26
本文介绍了多项目中的 SBT 测试依赖关系:使测试代码可用于依赖项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 SBT 多项目,其中一些项目相互依赖.像这样:

I've a SBT multi-project where some projects have dependencies to each other. Like this:

 lazy val coreProject: Project = Project(
    id = "core-project",
    base = file("./core-project"),
    // other stuff
    ))

  lazy val extensions: Project = Project(
    id = "extensions",
    base = file("./extensions"),
    dependencies = Seq(coreProject)
  )

现在我在测试文件夹的核心"项目中有一些测试代码.还有诸如模拟和测试实用程序之类的东西.现在我想在扩展测试中使用这些测试实用程序.对于生产代码,这是可行的,因为我已经声明了一个依赖项.但是,似乎依赖性不适用于测试.当我运行测试时,我得到缺少类的编译错误.这些类来自核心项目中的测试代码.

Now I have some test-code in the 'core' project in the test-folder. There are also stuff like mocks and test-utilities. Now I would like to use those test utilities in the tests of the extensions. For production code this works, since I've declared a dependency. However it seems that dependency doesn't hold for the tests. When I run the tests I get compilation error for missing classes. Those classes are from the test-code in the core-project.

我如何告诉 sbt 依赖项还应该包含测试范围的测试代码?这样我就可以在扩展"项目的测试代码中重用我的模拟?

How can I tell sbt that the dependency also should include the test-code for the test-scope? So that I can reuse my mocks in the test-code of the 'exension'-project?

推荐答案

像这样:

dependencies = Seq(coreProject % "compile->compile;test->test")

这在 Getting- 中的每个配置的类路径依赖项"部分中进行了讨论Started-Multi-Project 指南.

这篇关于多项目中的 SBT 测试依赖关系:使测试代码可用于依赖项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆