I am trying to supplement an existing ant build so that the project
also builds with maven. I have most of this working, but am stuck
with some tests cases.
The problem is that some tests are being generated as objects with
lots of configuration — in effect running a parameter sweep over all
the available values. The class which extends TestCase, therefore has
a 4 arg constructor. The ant build creates multiple instances of this
test, and adds them to the TestSuite.
The maven build, however, fails. The problem is that it is trying to run
the test class directly. It cannot even construct it because it lacks
the single arg constructor.
Rewriting the test classes is not an option; the main library is being
developed by a third party, and I do not want to fork it. I am trying to
use their existing set up, by only adding to it.
So, my question, is there a way in maven to add one or more TestCase
objects to the main TestSuite (assuming maven has one) explicitly
rather than having maven to the work by reflection.
Okay, I did manage to solve this. JUnit 4 has a specialised runner for parameterised tests. So I moved the maven build to JUnit 4 (the ant build is still using JUnit 3). Then I had to write some custom code to produce a list of constructor parameters, rather than the objects that the ant build code was producing. Finally, I added some annotation to the tests.
Unfortunately, this means I had to modify the ant test code, although at least this was limited to addition. Not ideal, but workable.