mardi 4 avril 2017

How to show progress/status bar while Java tests are being run using JUnit on Command Line

Is it possible to show some sort of progress bar or status update to the command line while JUnit tests are running?

import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;

public final class TestRunner {
  public static void main(String[] args) {
     final Result result =
         JUnitCore.runClasses(
             common.SecretTest.class,
             common.UuidTest.class,
             common.UuidsTest.class,
             server.BasicControllerTest.class,
             server.DatabaseTest.class,
             // ... there are many more
             util.store.StoreTest.class
         );
      for (final Failure failure : result.getFailures()) {
         System.out.println(failure.toString());
      }
      System.out.println(result.wasSuccessful());
   }
}

The tests work fine, it's just that they take quite some time to complete and I was wondering if there is some sort of infrastructure built into JUnit that allows a % complete to be displayed to the terminal, similar to how git updates you on the % complete as you pull from master, for instance.

Aucun commentaire:

Enregistrer un commentaire