本文整理汇总了Java中org.junit.runners.model.InitializationError类的典型用法代码示例。如果您正苦于以下问题:Java InitializationError类的具体用法?Java InitializationError怎么用?Java InitializationError使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InitializationError类属于org.junit.runners.model包,在下文中一共展示了InitializationError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Courgette
import org.junit.runners.model.InitializationError; //导入依赖的package包/类
public Courgette(Class clazz) throws IOException, InitializationError {
super(clazz);
classLoader = clazz.getClassLoader();
final CourgetteOptions courgetteOptions = getCourgetteOptions(clazz);
courgetteProperties = new CourgetteProperties(courgetteOptions, createSessionId(), courgetteOptions.threads());
final CourgetteFeatureLoader courgetteFeatureLoader = new CourgetteFeatureLoader(courgetteProperties);
cucumberFeatures = courgetteFeatureLoader.getCucumberFeatures();
runtimeOptions = courgetteFeatureLoader.getCucumberRuntimeOptions();
runnerInfoList = new ArrayList<>();
if (courgetteOptions.runLevel().equals(CourgetteRunLevel.FEATURE)) {
cucumberFeatures.forEach(feature -> runnerInfoList.add(new CourgetteRunnerInfo(courgetteProperties, feature, null)));
} else {
final Map<CucumberFeature, Integer> scenarios = courgetteFeatureLoader.getCucumberScenarios();
scenarios
.keySet()
.forEach(scenario -> runnerInfoList.add(new CourgetteRunnerInfo(courgetteProperties, scenario, scenarios.get(scenario))));
}
}
示例2: RoboOleaster
import org.junit.runners.model.InitializationError; //导入依赖的package包/类
public RoboOleaster(Class testClass) throws InitializationError {
super(testClass);
Config config = getConfig(testClass);
AndroidManifest androidManifest = getAppManifest(config);
interceptors = new Interceptors(findInterceptors());
SdkEnvironment sdkEnvironment = getSandbox(config, androidManifest);
// Configure shadows *BEFORE* setting the ClassLoader. This is necessary because
// creating the ShadowMap loads all ShadowProviders via ServiceLoader and this is
// not available once we install the Robolectric class loader.
configureShadows(sdkEnvironment);
Class bootstrappedTestClass = sdkEnvironment.bootstrappedClass(testClass);
try {
this.oleasterRobolectricRunner = sdkEnvironment
.bootstrappedClass(OleasterRobolectricRunner.class)
.getConstructor(Class.class, SdkEnvironment.class, Config.class, AndroidManifest.class)
.newInstance(bootstrappedTestClass, sdkEnvironment, config, androidManifest);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例3: createRunners
import org.junit.runners.model.InitializationError; //导入依赖的package包/类
private static List<Runner> createRunners(final Class<?> clazz) throws InitializationError {
final ValueConverter defaultValueConverter = getDefaultValueConverter(clazz);
final List<Runner> runners = new ArrayList<>();
final Table classWideTable = classWideTableOrNull(clazz);
if (classWideTable != null) {
for (final TableRow row : classWideTable) {
runners.add(new SingleRowMultiTestRunner(clazz, row, defaultValueConverter));
}
} else {
for (final FrameworkMethod testMethod : new TestClass(clazz).getAnnotatedMethods(Test.class)) {
final Spockito.UseValueConverter useValueConverter = testMethod.getAnnotation(Spockito.UseValueConverter.class);
final ValueConverter methodValueConverter = Spockito.getValueConverter(useValueConverter, defaultValueConverter);
runners.add(new SingleTestMultiRowRunner(clazz, testMethod, methodValueConverter));
}
}
return runners;
}
示例4: BytecoderUnitTestRunner
import org.junit.runners.model.InitializationError; //导入依赖的package包/类
public BytecoderUnitTestRunner(Class aClass) throws InitializationError {
super(aClass);
testClass = new TestClass(aClass);
testMethods = new ArrayList<>();
Method[] classMethods = aClass.getDeclaredMethods();
for (Method classMethod : classMethods) {
Class retClass = classMethod.getReturnType();
int length = classMethod.getParameterTypes().length;
int modifiers = classMethod.getModifiers();
if (retClass == null || length != 0 || Modifier.isStatic(modifiers)
|| !Modifier.isPublic(modifiers) || Modifier.isInterface(modifiers)
|| Modifier.isAbstract(modifiers)) {
continue;
}
String methodName = classMethod.getName();
if (methodName.toUpperCase().startsWith("TEST")
|| classMethod.getAnnotation(Test.class) != null) {
testMethods.add(new FrameworkMethod(classMethod));
}
if (classMethod.getAnnotation(Ignore.class) != null) {
testMethods.remove(classMethod);
}
}
}
示例5: runWithIncompleteAssignments
import org.junit.runners.model.InitializationError; //导入依赖的package包/类
private void runWithIncompleteAssignments(ProducerAssignments assignments) throws Throwable {
List<ParameterProducer> parameterProducers = assignments.potentialNextParameterProducers();
if (parameterProducers.isEmpty()) {
throw new InitializationError(
"No @DataProducer found to inject to suite method " + method.getName());
}
for (ParameterProducer parameterProducer : parameterProducers) {
runWithAssignments(assignments.assignNext(parameterProducer));
}
}
示例6: validateFactoryMethod
import org.junit.runners.model.InitializationError; //导入依赖的package包/类
private void validateFactoryMethod(Method factoryMethod) throws InitializationError {
if (!factoryMethod.getReturnType().isAssignableFrom(testClass.getJavaClass())) {
throw new InitializationError("Illegal factory method return type.");
}
if (!Modifier.isStatic(factoryMethod.getModifiers())) {
throw new InitializationError("@FactoryMethod must be static!");
}
}
示例7: getMethodGenericReturnType
import org.junit.runners.model.InitializationError; //导入依赖的package包/类
private static Type getMethodGenericReturnType (Method method) throws InitializationError {
final Type genericReturnType = method.getGenericReturnType();
if (genericReturnType instanceof ParameterizedTypeImpl) {
final Type[] actualTypeArguments = ((ParameterizedTypeImpl) genericReturnType).getActualTypeArguments();
return actualTypeArguments[0];
}
throw new InitializationError(
"Illegal return type of " + genericReturnType + " for method as @DataProducer");
}
示例8: shouldValidateMethodProducerReturnType
import org.junit.runners.model.InitializationError; //导入依赖的package包/类
@Test
public void shouldValidateMethodProducerReturnType() throws Exception {
TestClass testClass = new TestClass(ProducerIsNotCollection.class);
ProducerAssignments assignments = ProducerAssignments.allUnassigned(
testClass, testClass.getJavaClass().getMethod("a", String.class));
assertThatExceptionOfType(InitializationError.class)
.isThrownBy(assignments::potentialNextParameterProducers);
}
示例9: shouldThrowExceptionOnNoDataProducer
import org.junit.runners.model.InitializationError; //导入依赖的package包/类
@Test
public void shouldThrowExceptionOnNoDataProducer() throws Throwable {
Method testMethod = NoDataProducer.class.getMethod("a", String.class);
FrameworkMethod method = new FrameworkMethod(testMethod);
FrameworkMethod spyMethod = spy(method);
when(spyMethod.getAnnotation(Ignore.class)).thenReturn(null);
assertThatExceptionOfType(InitializationError.class).isThrownBy(() ->
new JUnitEasyTools(NoDataProducer.class).methodBlock(method).evaluate());
}
示例10: initExecutions
import org.junit.runners.model.InitializationError; //导入依赖的package包/类
private void initExecutions() {
if (!executionsInitialized) {
try {
Runner descriptionProvider = createRunnerFor(Arrays.asList(target), Collections.<Filter>emptyList());
templateDescription = descriptionProvider.getDescription();
} catch (InitializationError initializationError) {
throw UncheckedException.throwAsUncheckedException(initializationError);
}
createExecutions();
for (Execution execution : executions) {
execution.init(target, templateDescription);
}
executionsInitialized = true;
}
}
示例11: toModules
import org.junit.runners.model.InitializationError; //导入依赖的package包/类
private Iterable<? extends Module> toModules(final Class<? extends Module>[] baseModules) {
return transform(newArrayList(baseModules), moduleClass -> {
try {
return moduleClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(new InitializationError(e));
}
});
}
示例12: DockerUnitRunner
import org.junit.runners.model.InitializationError; //导入依赖的package包/类
public DockerUnitRunner(Class<?> klass) throws InitializationError {
super(klass);
ServiceLoader<DiscoveryProviderFactory> loader = ServiceLoader.load(DiscoveryProviderFactory.class);
List<DiscoveryProviderFactory> implementations = new ArrayList<>();
loader.forEach(impl -> {
logger.info("Found discovery provider factory of type " + impl.getClass().getSimpleName());
implementations.add(impl);
});
if(implementations.size() > 0) {
logger.info("Using discovery provider factory " + implementations.get(0).getClass().getSimpleName());
discoveryProvider = implementations.get(0).getProvider();
} else {
throw new InitializationError("No discovery provider factory found. Aborting test.");
}
}
示例13: EasySuite
import org.junit.runners.model.InitializationError; //导入依赖的package包/类
/**
* Called by this class and subclasses once the runners making up the suite have been determined
*
* @param klass root of the suite
* @param runners for each class in the suite, a {@link Runner}
*/
protected EasySuite(Class<?> klass, List<Runner> runners) throws InitializationError {
super(klass);
try {
Class.forName(klass.getName());
} catch (Exception e) {
e.printStackTrace();
}
this.runners = Collections.unmodifiableList(runners);
}
示例14: OleasterRobolectricRunner
import org.junit.runners.model.InitializationError; //导入依赖的package包/类
public OleasterRobolectricRunner(
Class<?> testClass,
SdkEnvironment sandbox,
Config config,
AndroidManifest androidManifest)
throws
InitializationError {
super(testClass);
this.sandbox = sandbox;
this.config = config;
this.androidManifest = androidManifest;
}
示例15: SingleRowMultiTestRunner
import org.junit.runners.model.InitializationError; //导入依赖的package包/类
public SingleRowMultiTestRunner(final Class<?> clazz,
final TableRow tableRow,
final ValueConverter defaultValueConverter) throws InitializationError {
super(clazz);
this.tableRow = Objects.requireNonNull(tableRow);
this.defaultValueConverter = Objects.requireNonNull(defaultValueConverter);
validate();
}