查找 JUnit 测试中测试方法的数量 class

Finding the number of test methods in a JUnit test class

如何获得 JUnit 测试中测试方法的总数 class?

是否存在类似question which was for JUnit4. As I am using JUnit3, is there any way in 获取数量的测试方法?

而运行 junit 测试项目,JUnit window 通常在顶部显示方法总数。这意味着它会计算测试方法本身的数量。有可能从中得到吗?

你可以使用反射。

Java 中的 Class class 具有方法 getMethods(),您可以使用它来获取给定 class 的所有方法(它将成为你的 JUnit class).

然后对于每个方法,您应该检查它是否是测试方法(IIRC JUnit3 中的测试方法是那些以 "test" 开头的方法)