title: Play! framework: customize which tests are run
body: <p>I have a Play! 2 for Scala application, and I am using Specs2 for tests. I can run all tests with the <code>test</code> command, or a particular specification with <code>test-only MyParticularSpec</code>.</p>
  
  <p>What I would like to do is mark some particular specifications, or even single methods inside a specification, in order to do things like:</p>
  
  <ul>
  <li>running all tests that are not integration (that is, that do not access external resources)</li>
  <li>running all tests that do not access external resources in write mode (but still running the reading tests)</li>
  <li>running all tests but a given one</li>
  </ul>
  
  <p>and so on.</p>
  
  <p>I guess something like that should be doable, perhaps by adding some annotations, but I am not sure how to go for it.</p>
  
  <blockquote>
    <p>Does there exist a mechanism to selectively run some tests and not other ones?</p>
  </blockquote>
  
  <p><strong>EDIT</strong> I have answered myself when using <code>test-only</code>. Still the command line option does not work for the <code>test</code> task. Following the <a href="http://www.scala-sbt.org/release/docs/Detailed-Topics/Testing.html#additional-test-configurations">sbt guide</a> I have tried to create an additional sbt configuration, like</p>
  
  <pre><code>object ApplicationBuild extends Build {
    // more settings
    lazy val UnitTest = config("unit") extend(Test)
    lazy val specs = "org.scala-tools.testing" %% "specs" % "1.6.9" % "unit"
  
    val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA)
      .configs(UnitTest)
      .settings(inConfig(UnitTest)(Defaults.testTasks) : _*)
      .settings(
        testOptions in UnitTest += Tests.Argument("exclude integration"),
        libraryDependencies += specs
      )
  }
  </code></pre>
  
  <p>This works when I pass arguments without options, for instance when I put <code>Test.Argument("plan")</code>. But I was not able to find how to pass a more complex argument. I have tried</p>
  
  <pre><code>Tests.Argument("exclude integration")
  Tests.Argument("exclude=integration")
  Tests.Argument("-exclude integration")
  Tests.Argument("-exclude=integration")
  Tests.Argument("exclude", "integration")
  Tests.Argument("exclude \"integration\"")
  </code></pre>
  
  <p>and probably more. Still not any clue what is the correct syntax.</p>
  
  <blockquote>
    <p>Does anyone know how to pass arguments with options to specs2 from sbt?</p>
  </blockquote>