Is it possible to parameterize a TestSuite in junit 4 ?
For declaring a class as a test suite I need the annotation @RunWith(Suite.class)
, but the same
I agree, it's not possible with the provided classes, but there are workarounds that will get you most of the way there, like @mikemil's.
I've spent some time extending Suite and delegating to Parameterized, with partial success; it is possible to build runner that does what you want, and the code is more-or-less written for you in those two classes. The way those classes interact (in particular, the definition of Parameterized#getChildren()
) makes it difficult to extend or delegate to those classes to accomplish what you need, but creating a whole new class than extends ParentRunner
and lifts code from the other two would be fairly easy.
I'll try to get more time to come back to this later. If you do build a new runner before I get around to it, please post it as an answer, I'd love to use it myself.