title: running a subset of JUnit @Test methods
body: <p>We're using JUnit 4 to test: we have classes that don't are a subclass of <code>TestCase</code>, and they have public methods annotated with <code>@Test</code>. We have one file with many <code>@Test</code> methods. It would be nice to be able to run a subset of them via Ant from the command line, in the style of this recipe for JUnit 3:</p>
  
  <pre><code>ant runtest -Dtest=MyTest -Dtests=testFoo,testBar
  </code></pre>
  
  <p><a href="http://today.java.net/pub/a/today/2003/09/12/individual-test-cases.html" rel="noreferrer">http://today.java.net/pub/a/today/2003/09/12/individual-test-cases.html</a></p>
  
  <p>I've been trying to think of ways to achieve this with Java reflection, etc. Since there doesn't seem to be any way to "hide" <code>@Test</code> methods or remove their annotations at runtime, the only option seems to be using the ClassLoader's <code>defineClass</code> method, which seems quite difficult.</p>
  
  <p>P.S. The Right Thing in this situation would be to split up the file, but are there alternatives?</p>
  
  <p>Thanks for your time.</p>