简体   繁体   English

SBT运行测试依赖

[英]Sbt run test in dependency

I packaged the tests files and published them to local ivy via test:publishLocal , using this setting: 我打包了测试文件,并使用以下设置通过test:publishLocal它们发布到本地常春藤:

.settings(publishArtifact in (Test, packageBin) := true)

Then, in another project, I can reference this library with libraryDependecies += . 然后,在另一个项目中,我可以使用libraryDependecies +=引用此库。 Now, I want to use these classes. 现在,我想使用这些类。 But the test command only looks into sources, like src/test/scala . 但是test命令仅查找源,例如src/test/scala How to instruct it to look into the dependency? 如何指示它查看依赖关系?

As a workaround, you could write a test class that extends from the test class in the dependency that you want to run, and just inherits its members (methods and fields) with no members of its own. 作为一种解决方法,您可以编写一个测试类,该类从要运行的依赖项中的测试类extends而来,只继承其成员(方法和字段)而没有其自身的成员。 I think that should work. 我认为应该可以。

By inspect ing test recursively, I got to this: 通过递归inspect test ,我达到了:

progfun-actorbintree:->inspect test:test::defined-tests
[info] Task: scala.collection.Seq[sbt.TestDefinition]
[info] Description:
[info]  Provides the list of defined tests.

Executing it I get: 执行它,我得到:

progfun-actorbintree:->show test:test::defined-tests
[info] List(Test actorbintree.BinaryTreeSuite : subclass(false, org.scalatest.Suite))
[success] Total time: 1 s, completed 11/12/2013 15:50:30

Which is the sole test class in this project. 这是该项目中唯一的测试类。

So I think that's what you need to modify to get the tests from the library. 因此,我认为这就是您需要修改才能从库中获取测试的内容。 I recommend doing some inspecting yourself to get further details, such as what is a TestDefinition -- one of the things associated with tests is the framework, which might be another thing you'll need to specify. 我建议您进行一些检查以获得更多详细信息,例如什么是TestDefinition与测试相关的一件事是框架,这可能是您需要指定的另一件事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM