-1

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

What is the best way to do that?

aperez
  • 451
  • 2
  • 8
  • 20

1 Answers1

2

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.

Community
  • 1
  • 1
Christophe Roussy
  • 16,299
  • 4
  • 85
  • 85