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
If you use @Before and @After annotations and note the junit testcase start and endtime. Then finding the difference of two timestamps should give you the testcase execution time. Something like this:
public class Example {
long startTime;
long endTime;
@Before public void recordStartTime() {
startTime = System.currentTimeMillis();
}
@Test public void testSomething() {
//test method
}
@After public void recordEndAndExecutionTime() {
endTime = System.currentTimeMillis();
System.out.println("Last testcase exection time in millisecond : " + (endTime - startTime));
}
}