use of org.junit.runners.model.InitializationError in project gerrit by GerritCodeReview.
the class ConfigSuite method runnersFor.
private static List<Runner> runnersFor(Class<?> clazz) {
Method defaultConfig = getDefaultConfig(clazz);
List<Method> configs = getConfigs(clazz);
Map<String, org.eclipse.jgit.lib.Config> configMap = callConfigMapMethod(getConfigMap(clazz), configs);
Field parameterField = getOnlyField(clazz, Parameter.class);
checkArgument(parameterField != null, "No @ConfigSuite.Parameter found");
Field nameField = getOnlyField(clazz, Name.class);
List<Runner> result = Lists.newArrayListWithCapacity(configs.size() + 1);
try {
result.add(new ConfigRunner(clazz, parameterField, nameField, null, callConfigMethod(defaultConfig)));
for (Method m : configs) {
result.add(new ConfigRunner(clazz, parameterField, nameField, m.getName(), callConfigMethod(m)));
}
for (Map.Entry<String, org.eclipse.jgit.lib.Config> e : configMap.entrySet()) {
result.add(new ConfigRunner(clazz, parameterField, nameField, e.getKey(), e.getValue()));
}
return result;
} catch (InitializationError e) {
System.err.println("Errors initializing runners:");
for (Throwable t : e.getCauses()) {
t.printStackTrace();
}
throw new RuntimeException(e);
}
}
use of org.junit.runners.model.InitializationError in project xtext-core by eclipse.
the class RunnerBuilder method getScenarios.
private static Scenario[] getScenarios(Class<?> klass, boolean completeInput) throws InitializationError {
Scenarios annotation = klass.getAnnotation(Scenarios.class);
if (annotation == null) {
return Scenario.values();
} else if (completeInput) {
throw new InitializationError("Must not use ProcessedBy.processCompleteInput together with the Scenarios annotation");
}
Scenario[] result = annotation.value();
if (result.length == 0) {
throw new InitializationError("Must at least specify one smoke test scenario or omit the Scenarios annotation");
}
return result;
}
use of org.junit.runners.model.InitializationError in project janusgraph by JanusGraph.
the class BerkeleyProcessComputerSuite method getTestList.
private static Class<?>[] getTestList() throws InitializationError {
try {
final Field field = ProcessComputerSuite.class.getDeclaredField("allTests");
field.setAccessible(true);
return (Class<?>[]) ArrayUtils.removeElement((Class<?>[]) field.get(null), TraversalInterruptionComputerTest.class);
} catch (ReflectiveOperationException e) {
throw new InitializationError("Unable to create test list");
}
}
use of org.junit.runners.model.InitializationError in project intellij-community by JetBrains.
the class AllTestsSuite method getSuiteClasses.
private static Class<?>[] getSuiteClasses(Class<?> klass) throws InitializationError {
TestPackage annotation = klass.getAnnotation(TestPackage.class);
if (annotation == null)
throw new InitializationError("No test package specified");
String testPackage = annotation.value();
SlowPolicy policy = annotation.policy();
TestCaseLoader loader = new TestCaseLoader("", true);
try {
TestAll.fillTestCases(loader, testPackage, TestAll.getClassRoots());
} catch (IOException e) {
throw new InitializationError(e);
}
List<Class<?>> result = ContainerUtil.newArrayList();
for (Class aClass : loader.getClasses()) {
if (policy == SlowPolicy.ALL) {
result.add(aClass);
} else {
boolean slow = isSlow(aClass);
if (slow && policy == SlowPolicy.SLOW_ONLY || !slow && policy == SlowPolicy.FAST_ONLY) {
result.add(aClass);
}
}
}
return result.toArray(ArrayUtil.EMPTY_CLASS_ARRAY);
}
use of org.junit.runners.model.InitializationError in project intellij-community by JetBrains.
the class JUnit46ClassesRequestBuilder method getClassesRequest.
public static Request getClassesRequest(final String suiteName, Class[] classes, Map classMethods, Class category) {
boolean canUseSuiteMethod = canUseSuiteMethod(classMethods);
try {
if (category != null) {
try {
Class.forName("org.junit.experimental.categories.Categories");
} catch (ClassNotFoundException e) {
throw new RuntimeException("Categories are not available");
}
}
Runner suite;
if (canUseSuiteMethod) {
try {
Class.forName("org.junit.experimental.categories.Categories");
suite = new IdeaSuite48(collectWrappedRunners(classes), suiteName, category);
} catch (ClassNotFoundException e) {
suite = new IdeaSuite(collectWrappedRunners(classes), suiteName);
}
} else {
final AllDefaultPossibilitiesBuilder builder = new AllDefaultPossibilitiesBuilder(canUseSuiteMethod);
try {
Class.forName("org.junit.experimental.categories.Categories");
suite = new IdeaSuite48(builder, classes, suiteName, category);
} catch (ClassNotFoundException e) {
suite = new IdeaSuite(builder, classes, suiteName);
}
}
return Request.runner(suite);
} catch (InitializationError e) {
throw new RuntimeException(e);
}
}
Aggregations