1

Is there a way to place simple start/stop timing in a JUnit test suite?

When I create a test suite class, it looks like this and I can run it. But how could I put a simple long start time variable in here to show how long all the tests took to run?

public class AllTests {

    public static Test suite() throws Exception {
        TestSuite theTestSuite = new TestSuite();
        theTestSuite.addTest(com.company.AllBlahTests.suite());
        theTestSuite.addTest(com.company.AllOtherTests.suite());
        return theTestSuite;
    }
}
guerda
  • 23,388
  • 27
  • 97
  • 146
sproketboy
  • 8,967
  • 18
  • 65
  • 95
  • How exactly are you running the tests? These results are usually reported automatically by the framework running the tests. – JohnnyO Mar 22 '13 at 14:38
  • Yeah they are - I can get these from the run but I was just wondering how to get them programmatically. I use IntelliJ and just right-click and run. – sproketboy Mar 22 '13 at 14:41

1 Answers1

3

See this answer to a previous question. Before and After Suite execution hook in jUnit 4.x

If you implement that solution, you may be able to place your timing code in the setup and teardown methods of the suite class.

Community
  • 1
  • 1
Rob Breidecker
  • 604
  • 1
  • 7
  • 12