Record time it takes JUnit tests to run

后端 未结 7 1457
无人共我
无人共我 2021-02-04 11:52

I would like to record how long it takes my JUnit test to run programmatically. I have a large number of tests in various test classes, and I would like to find out how long ea

7条回答
  •  天命终不由人
    2021-02-04 12:28

    Try to use @Before and @After. A method annotated with @Before or @After runs before or after the test.

        @Before
        public void start() {
            start = System.currentTimeMillis();
        }
    
        @After
        public void end() {
            System.out.println(System.currentTimeMillis() - start);
        }
    

提交回复
热议问题