Henrik Kirk
Henrik Kirk

Reputation: 604

Disable single test in Play 2.4 scala

I have some long running tests in my project. These these are sitting in parallel to my integration and unit-tests in

/test/manual/*

Is there in Play 2.4 for Scala a way to disable/mark these test classes. So they are not run automaticly when

$ activator test

but only run when using the test-only command.

Problem is that I do not want to run these longer tests on my CI server.

Upvotes: 3

Views: 253

Answers (1)

Jean
Jean

Reputation: 21595

Having similar problems for long-running integration tests, I created an It configuration derived from the standard test config (in <projectHome>/build.sbt):

lazy val It = config("it").extend(Test)

Then I add the sources and test sources to this config

scalaSource in It <<= (scalaSource in Test)

and you needd to enable to config and corresponding tasks available in the current project

lazy val root = (project in file(".")).configs(It)
                                      .settings(inConfig(It)(Defaults.testTasks): _*)

I then disable long running tests in the Test config :

testOptions in Test := Seq(Tests.Argument("exclude", "LongRunning"))

And include only these long running tests in the It config:

testOptions in It := Seq(Tests.Argument("include", "LongRunning"))

These last 2 configs are kinda dependent on the test framework you use (specs2 in my case, scala test would probably use -n and -l in addition to tags to achieve the same)

Then sbt test will exclude all LongRunning tests and you can run it:test or it:testOnly your.long.running.TestCaseHere in an interactive sbt session if need be.

Upvotes: 3

Related Questions