简体   繁体   English

.sbt重新定义测试任务

[英].sbt redefining test task

For my specific reason, I'd like to override test task to run not all tests, but to behave like test-only TopTestSuiteName param1 param2 . 由于我的特定原因,我想覆盖test任务以不运行所有测试,而是像test-only TopTestSuiteName param1 param2 Is it possible? 可能吗?

I tried to go through documentation on tasks and examples, but still far from understanding what is possible and what's not. 我试图浏览有关任务和示例的文档,但是距离了解什么是可能的和什么不是什么还很遥远。

Or maybe I could create custom task and somehow use existing test-only functionality? 还是我可以创建自定义任务并以某种方式使用现有test-only功能? I feel it is reasonable but completely cannot understand - where do I start. 我认为这是合理的,但完全无法理解-我从哪里开始。

I would suggest you leave test alone and add a custom thing instead. 我建议您不要进行test ,而是添加自定义内容。

How about an alias? 别名如何? You could just add this to your .sbt definition: 您可以将其添加到您的.sbt定义中:

addCommandAlias("myTest", "testOnly TopTestSuiteName -- param1 param2")

But if you actually need myTest to be a task (for example if you want another task to depend on it), then here's code (in .sbt format for sbt 0.13) for reusing testOnly functionality in a custom task: 但是,如果您实际上需要将myTest用作任务(例如,如果您希望另一个任务依赖于它),那么以下代码(用于sbt 0.13的.sbt格式)可在自定义任务中重用testOnly功能:

val myTest = taskKey[Unit]("call testOnly with some special args")

myTest in Test :=
  (testOnly in Test).toTask(" TopTestSuiteName -- param1 param2").value

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

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