本文整理匯總了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();
}