sbt:如何运行集成测试

时间:2019-01-18 09:33:10

标签: scala sbt integration-testing

根据documentation

  

标准测试任务可用,但必须前缀   它:。例如,

     

> IntegrationTest / testOnly org.example.AnIntegrationTest

如上所述,我将此添加到了build.sbt

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

我只想运行集成测试。

所以我尝试了不同的方法-但没有一个起作用:

[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

如何正确完成?

1 个答案:

答案 0 :(得分:1)

您需要像此处启用public interface IFoo { void Bar(int a); } public static class FooExtensions { public static void Bar(this IFoo foo, int a, int b) { //... } public static void Bar(this IFoo foo, int a, int b, int c) { //... } }

settings(Defaults.itSettings)

此后,您应该可以在sbt内同时运行

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

或在sbt> it:testOnly test.Spec sbt> IntegrationTest / testOnly test.Spec 之外为

sbt