如何使用 SBT 在测试配置之间共享类 [英] How do you share classes between test configurations using SBT
问题描述
我已按照 SBT 文档中的说明设置测试配置.我有三个测试配置 Test、IntegrationTest 和 AcceptanceTest.所以我的 src 目录是这样的:
I have followed the instructions on SBT's documentation for setting up test configurations. I have three test configurations Test, IntegrationTest, and AcceptanceTest. So my src directory looks like this:
- 源代码/
- 接受/
- scala/
- scala/
- scala/
我的问题是,如何配置 SBT 以允许在这些配置之间共享类?示例:我在it"配置中有一个类,用于简化数据库设置和拆卸.我在验收"配置中的一个验收测试可以使用这个类.我如何在验收"中使它"类可用于测试
My question is, how can I configure SBT to allow sharing of classes between these configurations? Example: I have a class in the "it" configuration for simplifying database setup and tear down. One of my acceptance tests in the "acceptance" configuration could make use of this class. How do I make that "it" class available to the test in "acceptance"
非常感谢.
推荐答案
一个配置可以扩展另一个配置以使用该配置的依赖项和类.例如,自定义测试配置部分显示了以下定义自定义配置:
A configuration can extend another configuration to use that configuration's dependencies and classes. For example, the custom test configuration section shows this definition for the custom configuration:
lazy val FunTest = config("fun") extend(Test)
extend
部分意味着编译后的普通测试源将位于fun
源的类路径上.在您的情况下,声明acceptance
配置以扩展it
配置:The
extend
part means that the compiled normal test sources will be on the classpath forfun
sources. In your case, declare theacceptance
configuration to extend theit
configuration:lazy val AcceptanceTest = config("acceptance") extend(IntegrationTest)
这篇关于如何使用 SBT 在测试配置之间共享类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- 接受/