title: Running tests from jar with "sbt testOnly" in SBT?
body: <p>As part of a CI setup the very first step is to create a package/jar using SBT <code>dist</code>. The following steps are to run unit, integration and functional tests with the <code>dist</code>-created jar.</p>
  
  <p>Is it possible to do that with SBT?</p>
  
  <p>Normally I use <code>sbt testOnly "Unit.*"</code>, but that works in the context of a project. I can't find any documentation showing how to do this when there is already a jar.</p>
  
  <p>I'm using ScalaTest and I know there is a runner for it I could use <a href="http://www.scalatest.org/user_guide/using_the_runner" rel="noreferrer">http://www.scalatest.org/user_guide/using_the_runner</a>. But using SBT would be simpler, if that is possible.</p>
  
  <p>As an example, something like this is what I am looking for:</p>
  
  <pre><code>sbt testOnly "Unit.* -jar myjar.jar"
  </code></pre>
  
  <p>Will my tests even be included in the jar when I use the following: </p>
  
  <pre><code>sbt dist
  </code></pre>
  
  <p>?</p>
  
  <p><strong>EDIT</strong></p>
  
  <ol>
  <li>I created a new folder</li>
  <li><p>I added <code>build.sbt</code> with the following content:</p>
  
  <pre><code>name := "abc"
  
  version := "1.0-SNAPSHOT"
  
  scalaVersion := "2.10.0"
  </code></pre></li>
  <li><p>I added the <code>lib</code> folder and copied my tests jar into it</p></li>
  <li><p>I ran <code>sbt testOnly Unit.*</code></p></li>
  <li><p>It could not find any tests</p></li>
  </ol>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>I tried with the following "proper" SBT file:</p>
  
  <pre><code>name := "ihs2tests"
  
  version := "1.0-SNAPSHOT"
  
  scalaVersion := "2.10.0"
  
  unmanagedBase in Test := new java.io.File(".")
  </code></pre>
  
  <p>and moved <code>test.jar</code> into the root of the project. Again, no tests found.</p>