I'm working with a legacy project that has:
- Pure unit tests
- Integration tests (slow to run; have all sorts of nasty dependencies)
I'm looking for the simplest way to run both types of tests separately with Ant.
I wonder if there's a way to have Ant automatically recognise these two categories based on the inheritance hierarchy:
StringUtilsTest extends TestCase // "pure unit test"
vs
ProductionDBTest extends AbstractTransactionalTesterBase // "integration test"
There's a hierarchy of abstract superclasses that integration tests are based on, but they all come down to some Spring test classes and ultimately AbstractSpringContextTests
which extends junit.framework.TestCase
.
In other words, can I distinguish, in Ant, tests that (indirectly) extend AbstractSpringContextTests
and tests that directly extend TestCase
? Or would I have to manually go through the tests and e.g. put them in separate Categories or TestSuites? (There are many tests so I wouldn't want to do that.)
Resolution: I tried Sean's (very promising) approach, but couldn't get it working (easily). So I ended up going through the tests semi-manually after all, annotating the pure ones (which was the smaller group) using a setup described in this SO question, and running them with Ant like this. (Note that writing a custom TestRunner is not necessary.)