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

时间:2016-09-08 16:34:26

标签: unit-testing intellij-idea go intellij-plugin

我不时会遇到这些令人烦恼的测试,并且有间歇性的问题,我需要多次运行才能曝光。我一直在寻找一种方便的方法来设置一个数字或#34;无限循环"来自intelliJ,但我没有找到。

是否有插件或者我错过了一些可以让我从UI执行此操作的内容(而不是更改代码)。

编辑:我发现对这种功能的支持是每个测试实用程序插件。例如,它已经存在于JUnit中,但Go Test没有。我的直觉表明,应该为所有测试插件提供这样的功能,但每个插件方法可能有一些技术原因。

2 个答案:

答案 0 :(得分:9)

在测试的运行配置中,有一个"重复:"您可以在其中指定重复次数的下拉列表,例如在测试失败之前。我相信这可以从IntelliJ IDEA 15开始。

答案 1 :(得分:0)

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);
   }
 }