3

I recently read (link text) about a way to statically add tests to test suite in JUnit 4? What about a dynamic way, i.e. how to add a test class if its name is known not earlier than at run-time, e.g. its name is read from XML file?

Community
  • 1
  • 1

2 Answers2

2

I know how to do it. I can use JUnitExt library (http://junitext.sourceforge.net). It supports "declarative test configurations (as provided by TestNG)". See junitext.sourceforge.net/tutorial.html (How to parameterize tests using XML).

1

I don't know of a way to add to an existing suite, but you can create your own suite at runtime. The JUnitCore class lets you pass in a list of classes you want run. These can be read in from anywhere you like including XML.

Jeanne Boyarsky
  • 12,156
  • 2
  • 49
  • 59