Search code examples
scalasbt

What is the recommended way to setup integration test in sbt after the deprecation of custom configs


I have just stumble into this:

https://eed3si9n.com/sbt-drop-custom-config/

Specifically:

what about IntegrationTest?

IntegrationTest should be removed. It doesn’t add anything useful besides the fact that it hangs off a subproject.

So what is the recommended way to run Integration test? Should I create a subproject containing those tests? How can then be run separately from the other tests?


Solution

  • This worked for me:

    lazy val IntegrationTest = (project in file("integration"))
      .dependsOn(root % "provided -> provided;compile -> compile;test -> test; runtime -> runtime")
      .settings(
        publish / skip := true,
        // extra test dependencies
        libraryDependencies ++= Seq(
          "com.org" %% "integration_test_dep" % "1.0.0" % Test,
        ),
      )
    
    lazy val root = (project in file("."))
      .settings(name := "my-application")
    

    It specifies a separate module in folder integration and to run the integration tests, you can type:

    sbt IntegrationTest/test