If you can not touch the original test, you will have serious limitations. Your main sound sounds like the best bet, but with a few changes:
Create Ant tests, excluding superclasses, so that extra classes that you don't know about are run.
You can use the @Rule annotation (new to JUnit 4.7) to know which test is running and abort it (returning an empty Statement implementation), instead of overriding specific methods, which gives you more flexibility in understanding whether to avoid the test. The only problem with this method is that you cannot stop the @Before methods from using this method, which can be slow. If this is a problem (and you really can't touch the tests), then @Ignore in the overridden method is the only thing I can think of.
If, however, you can touch on these tests, some additional options will open:
You can run them using a special runner by specifying the @RunWith tag in the class. This runner will simply execute the standard runner (JUnit4.class) in this project, but in your project (through a system property or some other mechanism) it will check the name of the test and not run the test. This has the advantage of being the least intrusive, but the most difficult to implement (runners are hairy animals, one of @Rule's stated goals is to eliminate most of the need to create them).
Another is to create an acceptThat statement in a test that will check some configuration parameters that would be true if this test should be run. This actually involves injecting directly into the test, which is most likely a transaction violator in everything that is remotely referred to as a “separate project”.
Yishai
source share