Home | History | Annotate | Download | only in runner
      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 public class Computer {
     13 	/**
     14 	 * Returns a new default computer, which runs tests in serial order
     15 	 */
     16 	public static Computer serial() {
     17 		return new Computer();
     18 	}
     19 
     20 	/**
     21 	 * Create a suite for {@code classes}, building Runners with {@code builder}.
     22 	 * Throws an InitializationError if Runner construction fails
     23 	 */
     24 	public Runner getSuite(final RunnerBuilder builder,
     25 			Class<?>[] classes) throws InitializationError {
     26 		return new Suite(new RunnerBuilder() {
     27 			@Override
     28 			public Runner runnerForClass(Class<?> testClass) throws Throwable {
     29 				return getRunner(builder, testClass);
     30 			}
     31 		}, classes);
     32 	}
     33 
     34 	/**
     35 	 * Create a single-class runner for {@code testClass}, using {@code builder}
     36 	 */
     37 	protected Runner getRunner(RunnerBuilder builder, Class<?> testClass) throws Throwable {
     38 		return builder.runnerForClass(testClass);
     39 	}
     40 }
     41