How to print current executing JUnit test method while running all tests in a class or suite using ANT?

前端 未结 6 1325
野性不改
野性不改 2021-01-20 10:24

I have a set of JUnit Test Cases and I execute them from ANT using the junit task. While executing the tests, in the console I get to see only which test case (i.e. Java cla

6条回答
  •  面向向阳花
    2021-01-20 10:48

    If you do not want to create your own test runner you could try using the stacktrace.

    The following Method prints the class and method name of the method that called it.

    public static void printMethod() {
        System.out.println(Thread.currentThread().getStackTrace()[2]);
    }
    

    You would have to call this method in each of your test methods.

提交回复
热议问题