简体   繁体   中英

sbt: How to run integration test

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?

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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