sbt: How to run integration test

左心房为你撑大大i 提交于 2020-06-17 04:42:40

问题


According to the documentation:

The standard testing tasks are available, but must be prefixed with it:. For example,

> IntegrationTest / testOnly org.example.AnIntegrationTest

As described, I added this to my build.sbt:

lazy val server = (project in file("server"))
  .configs(IntegrationTest)

I want to run only integration tests.

So I tried different ways - but none worked:

[IJ][play-binding-form-server] $ it:test
[error] No such setting/task
[error] it:test
...
[IJ][play-binding-form-server] $ IntegrationTest / testOnly org.example.AnIntegrationTest
[error] Expected whitespace character
[error] Expected '/'
[error] IntegrationTest / testOnly org.example.AnIntegrationTest

How is it done correctly?


回答1:


You need to enable settings(Defaults.itSettings) like here

lazy val server = (project in file("server"))
  .configs(IntegrationTest)
  .settings(Defaults.itSettings)

After this you should be able to run both within sbt

sbt> it:testOnly test.Spec
sbt> IntegrationTest / testOnly test.Spec

Or outside of sbt as

sbt "it:testOnly test.Spec"
sbt "IntegrationTest / testOnly test.Spec"


来源:https://stackoverflow.com/questions/54251069/sbt-how-to-run-integration-test

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!