Question

I have to check if a certain Class<?> object contains JUnit tests (both JUnit3 and JUnit4).

What is the best way to do that?

Was it helpful?

Solution

Use Java reflection on the classes to find out.

For version 3 the class must extend TestCase.

For version 4 you can scan for annotations, see this: How to get annotations of a member variable?

Basically you have to do as if you were JUnit, maybe you can even reuse some of the existing JUnit code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top