Finding the number of test methods in a JUnit test class

Shahid

How I can get the number of total test methods in a JUnit test class?

There exists a similar question which was for JUnit4. As I am using JUnit3, is there any way in to get the number of test methods?

While running the junit test project, JUnit window usually shows the total number of methods on the top. That means it counts the number of test methods itself. Is it possible to get from it?

xp500

You can use reflection.

The Class class in Java has the method getMethods() which you can use to get all the methods for the given class (which will be your JUnit class).

Then for each method you should check if it's a test method (IIRC the test methods in JUnit3 are those that start with "test")

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related