title: Exclude individual JUnit Test methods without modifying the Test class?
body: <p>I'm currently re-using JUnit 4 tests from another project against my code. I obtain them directly from the other project's repository as part of my automated Ant build. This is great, as it ensures I keep my code green against the very latest version of the tests.</p>
  
  <p>However, there is a subset of tests that I never expect to pass on my code. But if I start adding @Ignore annotations to those tests, I will have to maintain my own separate copy of the test implementation, which I <strong>really</strong> don't want to do. </p>
  
  <p>Is there a way of excluding individual tests without modifying the Test source? Here's what I have looked at so far:</p>
  
  <ul>
  <li><p>As far as I can see, the Ant JUnit task only allows you to exclude entire Test classes, not individual test methods - so that's no good for me, I need method granularity.</p></li>
  <li><p>I considered putting together a TestSuite that uses reflection to dynamically find and add all of the original tests, then add code to explicitly remove the tests I don't want to run. But I ditched that idea when I noticed that the <a href="http://junit.org/junit/javadoc/4.5/junit/framework/TestSuite.html" rel="nofollow noreferrer">TestSuite API</a> doesn't provide a method for removing tests.</p></li>
  <li><p>I can create my own Test classes that extend the original Test classes, override the specific tests I don't want to run, and annotate them with @Ignore. I then run JUnit on my subclasses. The downside here is that if new Test classes are added to the original project, I won't pick them up automatically. I'll have to monitor for new Test classes as they are added to the original project. This is my best option so far, but doesn't feel ideal.</p></li>
  <li><p>The only other option I can think of is to run the bad tests anyway and ignore the failures. However, these tests take a while to run (and fail!) so I'd prefer to not run them at all. Additionally, I can't see a way of telling the Ant task to ignore failures on specific test methods (again - I see how you can do it for individual Test classes, but not methods).</p></li>
  </ul>