如何使用两个不同的依赖项注入容器运行scalatest规范?
我有一个由scalatest规范文件组成的测试套件。它们在我的DIC上的内存实现上都运行良好,DIC是蛋糕模式的实现 现在我想运行与集成测试相同的测试套件,这意味着内存中的实现将被与数据库通信的集合、与之通信的github API等所取代如何使用两个不同的依赖项注入容器运行scalatest规范?,scala,scalatest,Scala,Scalatest,我有一个由scalatest规范文件组成的测试套件。它们在我的DIC上的内存实现上都运行良好,DIC是蛋糕模式的实现 现在我想运行与集成测试相同的测试套件,这意味着内存中的实现将被与数据库通信的集合、与之通信的github API等所取代 我是否应该创建不同的sbt环境,并将di容器放在两个单独的环境(功能和集成)中,其中一个根据环境加载?这样做的最佳方式是什么 我是否可以在混合容器的功能和集成测试套件中收集测试?这个工作怎么样?它将在哪里定义 val functionalTestSuite=
- 我是否应该创建不同的sbt环境,并将di容器放在两个单独的环境(功能和集成)中,其中一个根据环境加载?这样做的最佳方式是什么
- 我是否可以在混合容器的功能和集成测试套件中收集测试?这个工作怎么样?它将在哪里定义
val functionalTestSuite=具有FunctionalTestEnvironment的新测试套件 val integrationTestSuite=带有IntegrationTestEnvironment的新测试套件
class FunctionalTestingSuite扩展了套件{
覆盖val nestedSuites:IndexedSeq[Suite]={
//val actorSystem=FunctionalSpec.createActorSystem
IndexedSeq(
带有FunctionalTestEnvironmentHelper的新CodeRepositorySpec(FunctionalSpec.createActorSystem),
带有FunctionalTestEnvironmentHelper的新PipelineCollectionSpec(FunctionalSpec.createActorSystem),
新型管道控制器SPEC,带有功能性StennerEnvironmenthelper,
带有FunctionalTestEnvironmentHelper的新管道规范(FunctionalSpec.createActorSystem),
带有FunctionalTestEnvironmentHelper的新作业集合规范(FunctionalSpec.createActorSystem),
具有FunctionalTestEnvironmentHelper的新JobControllerSpec,
带有FunctionalTestEnvironmentHelper的新作业规范(FunctionalSpec.createActorSystem)
)
}
}
依赖注入容器是通过每次混合一个trait来注入的,在本例中是functionaltentenvironmenthelper
。在集成环境中,使用了integrationTestenEnvironmentHelper
。
我最终制作了单独的测试套件。后来我可以将sbt配置为只运行这些文件,而不是让它自动搜索文件
这样做的缺点是每次向套件中添加测试都需要大量的样板文件。我希望有人会修改我的答案,删除样板文件
class FunctionalTestingSuite扩展了套件{
覆盖val nestedSuites:IndexedSeq[Suite]={
//val actorSystem=FunctionalSpec.createActorSystem
IndexedSeq(
带有FunctionalTestEnvironmentHelper的新CodeRepositorySpec(FunctionalSpec.createActorSystem),
带有FunctionalTestEnvironmentHelper的新PipelineCollectionSpec(FunctionalSpec.createActorSystem),
新型管道控制器SPEC,带有功能性StennerEnvironmenthelper,
带有FunctionalTestEnvironmentHelper的新管道规范(FunctionalSpec.createActorSystem),
带有FunctionalTestEnvironmentHelper的新作业集合规范(FunctionalSpec.createActorSystem),
具有FunctionalTestEnvironmentHelper的新JobControllerSpec,
带有FunctionalTestEnvironmentHelper的新作业规范(FunctionalSpec.createActorSystem)
)
}
}
依赖注入容器是通过每次混合一个trait来注入的,在本例中是functionaltentenvironmenthelper
。在集成环境中,使用了integrationTestenEnvironmentHelper