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 junit4 by junit-team.
the class Request method classes.
/**
* Create a <code>Request</code> that, when processed, will run all the tests
* in a set of classes.
*
* @param computer Helps construct Runners from classes
* @param classes the classes containing the tests
* @return a <code>Request</code> that will cause all tests in the classes to be run
*/
public static Request classes(Computer computer, Class<?>... classes) {
try {
AllDefaultPossibilitiesBuilder builder = new AllDefaultPossibilitiesBuilder();
Runner suite = computer.getSuite(builder, classes);
return runner(suite);
} catch (InitializationError e) {
return runner(new ErrorReportingRunner(e, classes));
}
}
use of org.junit.runners.model.InitializationError in project randomizedtesting by randomizedtesting.
the class TestCustomMethodProvider method testJUnit4Invalid.
@Test
public void testJUnit4Invalid() {
Class<?>[] invalid = { T2.class, T3.class, T4.class, ST1.class, ST2.class, ST3.class, ST4.class, AT1.class };
for (Class<?> cl : invalid) {
try {
new JUnitCore().run(new RandomizedRunner(cl));
Assert.fail("Expected to fail for: " + cl);
} catch (InitializationError e) {
// expected.
}
}
}
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