doudong2149
doudong2149
2016-09-08 16:34

如何在Go Test IntelliJ中重复运行一个或一组测试

已采纳

From time to time I have this annoying tests with intermittent issues, that I need to run many times to expose. I was looking for a convenient way to set a number or "endless loop" from the intelliJ, but I did not find.

Is there a plugin or I missed something that could allow me to do this from the UI (instead of changing code for it).

EDIT: As I found the support for such feature is per test utility plugin. For example, it already exists for JUnit, but there is no such for Go Test. My instinct suggests that such functionality should be generically provided for all test plugins, but there might be some technical reasons for per plugin approach.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • doujiu7680 doujiu7680 5年前

    In the Run Configuration of the test there is a "Repeat:" dropdown where you can specify the number of repeats, for example until the test fails. I believe this is available since IntelliJ IDEA 15.

    点赞 评论 复制链接分享
  • duanguangsong2380 duanguangsong2380 5年前
    You can use oracle JDK to create a executor service which schedules the running /execution of the test suite periodically unless you shut down the service 
    
    Please have a look at the below oracle doc 
    
    https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ScheduledExecutorService.html
    
    Sample 
    
     import static java.util.concurrent.TimeUnit.*;
     class BeeperControl {
       private final ScheduledExecutorService scheduler =
         Executors.newScheduledThreadPool(1);
    
       public void beepForAnHour() {
         final Runnable beeper = new Runnable() {
           public void run() { System.out.println("beep"); }
         };
         final ScheduledFuture<?> beeperHandle =
           scheduler.scheduleAtFixedRate(beeper, 10, 10, SECONDS);
         scheduler.schedule(new Runnable() {
           public void run() { beeperHandle.cancel(true); }
         }, 60 * 60, SECONDS);
       }
     }
    
    点赞 评论 复制链接分享