1 package org.junit.runner; 2 3 import org.junit.runners.Suite; 4 import org.junit.runners.model.InitializationError; 5 import org.junit.runners.model.RunnerBuilder; 6 7 /** 8 * Represents a strategy for computing runners and suites. 9 * WARNING: this class is very likely to undergo serious changes in version 4.8 and 10 * beyond. 11 * 12 * @since 4.6 13 */ 14 public class Computer { 15 /** 16 * Returns a new default computer, which runs tests in serial order 17 */ serial()18 public static Computer serial() { 19 return new Computer(); 20 } 21 22 /** 23 * Create a suite for {@code classes}, building Runners with {@code builder}. 24 * Throws an InitializationError if Runner construction fails 25 */ getSuite(final RunnerBuilder builder, Class<?>[] classes)26 public Runner getSuite(final RunnerBuilder builder, 27 Class<?>[] classes) throws InitializationError { 28 return new Suite(new RunnerBuilder() { 29 @Override 30 public Runner runnerForClass(Class<?> testClass) throws Throwable { 31 return getRunner(builder, testClass); 32 } 33 }, classes); 34 } 35 36 /** 37 * Create a single-class runner for {@code testClass}, using {@code builder} 38 */ 39 protected Runner getRunner(RunnerBuilder builder, Class<?> testClass) throws Throwable { 40 return builder.runnerForClass(testClass); 41 } 42 } 43