久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='ZYL7j'></bdo><ul id='ZYL7j'></ul>
    <legend id='ZYL7j'><style id='ZYL7j'><dir id='ZYL7j'><q id='ZYL7j'></q></dir></style></legend>

    <small id='ZYL7j'></small><noframes id='ZYL7j'>

  • <tfoot id='ZYL7j'></tfoot>

    <i id='ZYL7j'><tr id='ZYL7j'><dt id='ZYL7j'><q id='ZYL7j'><span id='ZYL7j'><b id='ZYL7j'><form id='ZYL7j'><ins id='ZYL7j'></ins><ul id='ZYL7j'></ul><sub id='ZYL7j'></sub></form><legend id='ZYL7j'></legend><bdo id='ZYL7j'><pre id='ZYL7j'><center id='ZYL7j'></center></pre></bdo></b><th id='ZYL7j'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ZYL7j'><tfoot id='ZYL7j'></tfoot><dl id='ZYL7j'><fieldset id='ZYL7j'></fieldset></dl></div>
      1. 在套件級別上并行運行 JUnit 測試?

        Running JUnit Test in parallel on Suite Level?(在套件級別上并行運行 JUnit 測試?)
          <tbody id='LPnjb'></tbody>
              <bdo id='LPnjb'></bdo><ul id='LPnjb'></ul>

                <i id='LPnjb'><tr id='LPnjb'><dt id='LPnjb'><q id='LPnjb'><span id='LPnjb'><b id='LPnjb'><form id='LPnjb'><ins id='LPnjb'></ins><ul id='LPnjb'></ul><sub id='LPnjb'></sub></form><legend id='LPnjb'></legend><bdo id='LPnjb'><pre id='LPnjb'><center id='LPnjb'></center></pre></bdo></b><th id='LPnjb'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='LPnjb'><tfoot id='LPnjb'></tfoot><dl id='LPnjb'><fieldset id='LPnjb'></fieldset></dl></div>

                • <tfoot id='LPnjb'></tfoot>
                • <legend id='LPnjb'><style id='LPnjb'><dir id='LPnjb'><q id='LPnjb'></q></dir></style></legend>

                  <small id='LPnjb'></small><noframes id='LPnjb'>

                  本文介紹了在套件級別上并行運行 JUnit 測試?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一堆在 JUnit 測試套件中組織的測試.這些測試極大地利用 selenium 來測試 Web 應用程序.因此,對于 selenium,這些測試的運行時間很長.由于測試數據庫中有一些重疊,套件中的測試類無法并行運行,我想并行運行這些套件.

                  I have a bunch of tests that are organized in JUnit test suites. These tests are greatly utilizing selenium to test a web application. So, naturaly for selenium, the runtime of these tests is quite long. Since the test classes in the suites can not run parallel due some overlaps in the test database, i would like to run the suites parallel.

                  JUnit ParallelComputer 只能在類或方法級別并行執行測試,JUnit 是否有任何標準方法可以通過套件執行此操作?

                  The JUnit ParallelComputer can only execute tests on class or method level in parallel, are there any standard ways for JUnit to do that with suites?

                  如果我只是將套件類傳遞給 junit 運行器并將計算機配置為在類級別并行化,它會選擇測試類本身,而不是套件.

                  If i just pass suite classes to the junit runner and configure the computer to parallelize on class level, it picks the test classes itself, not the suites.

                  br弗蘭克

                  推薦答案

                  這里有一些對我有用的代碼.我沒有寫這個.如果您使用 @RunWith(ConcurrentSuite.class) 而不是 @RunWith(Suite.class) 它應該可以工作.下面還需要一個注釋.

                  Here is some code that worked for me. I did not write this. If you use @RunWith(ConcurrentSuite.class) instead of @RunWith(Suite.class) it should work. There is an annotation that is also needed which is found below.

                  package utilities.runners;
                  
                  import org.junit.internal.builders.AllDefaultPossibilitiesBuilder;
                  import org.junit.runner.Runner;
                  import org.junit.runners.Suite;
                  import org.junit.runners.model.InitializationError;
                  import org.junit.runners.model.RunnerBuilder;
                  import org.junit.runners.model.RunnerScheduler;
                  
                  import utilities.annotations.Concurrent;
                  
                  import java.util.Arrays;
                  import java.util.LinkedList;
                  import java.util.List;
                  import java.util.Queue;
                  import java.util.concurrent.CompletionService;
                  import java.util.concurrent.ExecutorCompletionService;
                  import java.util.concurrent.ExecutorService;
                  import java.util.concurrent.Executors;
                  import java.util.concurrent.Future;
                  import java.util.concurrent.ThreadFactory;
                  import java.util.concurrent.atomic.AtomicInteger;
                  
                  /**
                   * @author Mathieu Carbou (mathieu.carbou@gmail.com)
                   */
                  public final class ConcurrentSuite extends Suite {
                      public ConcurrentSuite(final Class<?> klass) throws InitializationError {
                          super(klass, new AllDefaultPossibilitiesBuilder(true) {
                              @Override
                              public Runner runnerForClass(Class<?> testClass) throws Throwable {
                                  List<RunnerBuilder> builders = Arrays.asList(
                                          new RunnerBuilder() {
                                              @Override
                                              public Runner runnerForClass(Class<?> testClass) throws Throwable {
                                                  Concurrent annotation = testClass.getAnnotation(Concurrent.class);
                                                  if (annotation != null)
                                                      return new ConcurrentJunitRunner(testClass);
                                                  return null;
                                              }
                                          },
                                          ignoredBuilder(),
                                          annotatedBuilder(),
                                          suiteMethodBuilder(),
                                          junit3Builder(),
                                          junit4Builder());
                                  for (RunnerBuilder each : builders) {
                                      Runner runner = each.safeRunnerForClass(testClass);
                                      if (runner != null)
                                          return runner;
                                  }
                                  return null;
                              }
                          });
                          setScheduler(new RunnerScheduler() {
                              ExecutorService executorService = Executors.newFixedThreadPool(
                                      klass.isAnnotationPresent(Concurrent.class) ?
                                              klass.getAnnotation(Concurrent.class).threads() :
                                              (int) (Runtime.getRuntime().availableProcessors() * 1.5),
                                      new NamedThreadFactory(klass.getSimpleName()));
                              CompletionService<Void> completionService = new ExecutorCompletionService<Void>(executorService);
                              Queue<Future<Void>> tasks = new LinkedList<Future<Void>>();
                  
                              @Override
                              public void schedule(Runnable childStatement) {
                                  tasks.offer(completionService.submit(childStatement, null));
                              }
                  
                              @Override
                              public void finished() {
                                  try {
                                      while (!tasks.isEmpty())
                                          tasks.remove(completionService.take());
                                  } catch (InterruptedException e) {
                                      Thread.currentThread().interrupt();
                                  } finally {
                                      while (!tasks.isEmpty())
                                          tasks.poll().cancel(true);
                                      executorService.shutdownNow();
                                  }
                              }
                          });
                      }
                  
                      static final class NamedThreadFactory implements ThreadFactory {
                          static final AtomicInteger poolNumber = new AtomicInteger(1);
                          final AtomicInteger threadNumber = new AtomicInteger(1);
                          final ThreadGroup group;
                  
                          NamedThreadFactory(String poolName) {
                              group = new ThreadGroup(poolName + "-" + poolNumber.getAndIncrement());
                          }
                  
                          @Override
                          public Thread newThread(Runnable r) {
                              return new Thread(group, r, group.getName() + "-thread-" + threadNumber.getAndIncrement(), 0);
                          }
                      }
                  
                  }
                  

                  并且注解如下.

                  package utilities.annotations;
                  
                  import java.lang.annotation.ElementType;
                  import java.lang.annotation.Retention;
                  import java.lang.annotation.RetentionPolicy;
                  import java.lang.annotation.Target;
                  
                  /**
                   * @author Mathieu Carbou (mathieu.carbou@gmail.com)
                   */
                  @Retention(RetentionPolicy.RUNTIME)
                  @Target({ ElementType.TYPE })
                  public @interface Concurrent {
                      int threads() default 5;
                  }
                  

                  這篇關于在套件級別上并行運行 JUnit 測試?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                  How to convert Integer to int?(如何將整數轉換為整數?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)
                  <legend id='C5FMU'><style id='C5FMU'><dir id='C5FMU'><q id='C5FMU'></q></dir></style></legend>
                    <i id='C5FMU'><tr id='C5FMU'><dt id='C5FMU'><q id='C5FMU'><span id='C5FMU'><b id='C5FMU'><form id='C5FMU'><ins id='C5FMU'></ins><ul id='C5FMU'></ul><sub id='C5FMU'></sub></form><legend id='C5FMU'></legend><bdo id='C5FMU'><pre id='C5FMU'><center id='C5FMU'></center></pre></bdo></b><th id='C5FMU'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='C5FMU'><tfoot id='C5FMU'></tfoot><dl id='C5FMU'><fieldset id='C5FMU'></fieldset></dl></div>

                      <small id='C5FMU'></small><noframes id='C5FMU'>

                        <tbody id='C5FMU'></tbody>
                          <bdo id='C5FMU'></bdo><ul id='C5FMU'></ul>
                          1. <tfoot id='C5FMU'></tfoot>

                            主站蜘蛛池模板: 一区影院 | av一级久久| 国产不卡一 | 老子午夜影院 | 欧美精品久久久久 | 欧美群妇大交群中文字幕 | 久久久久久久一区 | 69xxx免费| 青青久久 | 超碰在线播 | 国产精品免费在线 | 丁香久久 | 欧美在线| 亚洲精品乱码 | 国产福利免费视频 | 狠狠操狠狠操 | 91在线成人| 久久一区二区三区四区 | 能免费看的av | 欧美精品一区二区三区在线播放 | 欧美激情欧美激情在线五月 | 国产激情91久久精品导航 | 91久久久久久 | 国产日韩欧美精品一区二区 | 国产欧美精品一区二区三区 | 国产成人久久精品 | 日韩不卡一区二区 | 国产二区精品视频 | 欧美精品一区二区三区在线播放 | 久久国产精品久久久久 | 国产亚洲精品久久久优势 | 视频在线观看一区 | 日韩av第一页 | 国产在线精品一区二区 | 91豆花视频 | 精品一区二区三区四区 | 欧美日产国产成人免费图片 | 成年网站在线观看 | 久久天堂网| 亚洲欧洲综合av | 国产精品久久久久久久久久 |