org.junit.runners.model.InitializationError Java Examples
The following examples show how to use
org.junit.runners.model.InitializationError.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LambdaTestSuite.java From lambda-selenium with MIT License | 6 votes |
protected static List<TestRequest> getTestRequests(String folderName, Filter filter) { List<TestRequest> requests = new ArrayList<>(); getTestClasses(folderName).forEach(testClass -> { try { new BlockJUnit4ClassRunner(testClass).getDescription().getChildren() .forEach(description -> { if (filter.shouldRun(description)) { TestRequest request = new TestRequest(description); request.setTestRunUUID(TestUUID.getTestUUID()); requests.add(request); } }); } catch (InitializationError e) { LOGGER.log(e); } }); return requests; }
Example #2
Source File: Courgette.java From courgette-jvm with MIT License | 6 votes |
public Courgette(Class clazz) throws InitializationError { super(clazz); final CourgetteOptions courgetteOptions = new CourgetteRunOptions(clazz); courgetteProperties = new CourgetteProperties(courgetteOptions, createSessionId(), courgetteOptions.threads()); callbacks = new CourgetteCallbacks(clazz); final CourgetteLoader courgetteLoader = new CourgetteLoader(courgetteProperties); features = courgetteLoader.getFeatures(); runnerInfoList = new ArrayList<>(); if (courgetteOptions.runLevel().equals(CourgetteRunLevel.FEATURE)) { features.forEach(feature -> runnerInfoList.add(new CourgetteRunnerInfo(courgetteProperties, feature, null))); } else { final Map<PickleLocation, Feature> scenarios = courgetteLoader.getCucumberScenarios(); scenarios .keySet() .forEach(location -> runnerInfoList.add(new CourgetteRunnerInfo(courgetteProperties, scenarios.get(location), location.getLine()))); } }
Example #3
Source File: QpidTestRunner.java From qpid-broker-j with Apache License 2.0 | 6 votes |
public QpidTestRunner(final Class<?> klass) throws InitializationError { super(klass); _testClass = klass; final RunBrokerAdmin runBrokerAdmin = (RunBrokerAdmin) _testClass.getAnnotation(RunBrokerAdmin.class); final String type; if (runBrokerAdmin == null) { type = System.getProperty(PROPERTY_BROKER_ADMIN_TYPE, EmbeddedBrokerPerClassAdminImpl.TYPE); } else { type = runBrokerAdmin.type(); } _original = new BrokerAdminFactory().createInstance(type); _brokerAdmin = new LoggingBrokerAdminDecorator(_original); }
Example #4
Source File: JustTestLahRunner.java From justtestlah with Apache License 2.0 | 6 votes |
/** * Constructs a new {@link JustTestLahRunner}. * * @param clazz test class * @throws InitializationError {@link InitializationError} * @throws IOException {@link IOException} */ public JustTestLahRunner(Class<?> clazz) throws InitializationError, IOException { super(clazz); // Initialize Spring profiles and settings init(); // Bridge logging to SLF4J bridgeLogging(); if (properties.getProperty(CLOUD_PROVIDER, CLOUDPROVIDER_LOCAL).equals(CLOUDPROVIDER_AWS)) { LOG.info("Using qa.justtestlah.awsdevicefarm.AWSTestRunner"); awsRunner = getAWSRunner(clazz); } else { CucumberOptionsBuilder.setCucumberOptions(properties); initCucumber(clazz); } }
Example #5
Source File: Karate.java From karate with MIT License | 6 votes |
public Karate(Class<?> clazz) throws InitializationError, IOException { super(clazz); List<FrameworkMethod> testMethods = getTestClass().getAnnotatedMethods(Test.class); if (!testMethods.isEmpty()) { logger.warn("WARNING: there are methods annotated with '@Test', they will NOT be run when using '@RunWith(Karate.class)'"); } RunnerOptions options = RunnerOptions.fromAnnotationAndSystemProperties(clazz); List<Resource> resources = FileUtils.scanForFeatureFiles(options.getFeatures(), clazz.getClassLoader()); children = new ArrayList(resources.size()); featureMap = new HashMap(resources.size()); for (Resource resource : resources) { Feature feature = FeatureParser.parse(resource); feature.setCallName(options.getName()); feature.setCallLine(resource.getLine()); children.add(feature); } tagSelector = Tags.fromKarateOptionsTags(options.getTags()); }
Example #6
Source File: SmokeTestSuite.java From firebase-android-sdk with Apache License 2.0 | 6 votes |
private static List<String> getTestClassNames(Context ctx) throws InitializationError { String name = ctx.getPackageName(); try { PackageManager pm = ctx.getPackageManager(); ApplicationInfo ai = pm.getApplicationInfo(name, PackageManager.GET_META_DATA); String names = ai.metaData.getString(TEST_CLASSES_KEY); if (names == null) { throw new InitializationError("No test classes found in Application Manifest"); } return Arrays.asList(names.split(",")); } catch (PackageManager.NameNotFoundException ex) { throw new InitializationError(ex); } }
Example #7
Source File: SeparateClassloaderTestRunner.java From sofa-tracer with Apache License 2.0 | 6 votes |
public SeparateClassloaderTestRunner(Class<?> clazz) throws InitializationError { super(clazz); try { Class springJUnit4ClassRunnerClass = separateClassloader .loadClass(SpringJUnit4ClassRunner.class.getName()); Constructor constructor = springJUnit4ClassRunnerClass.getConstructor(Class.class); ExcludeClasses annotation = clazz.getAnnotation(ExcludeClasses.class); clazzLoadBySeparateClassloader = separateClassloader.loadClass(clazz.getName()); runnerObject = constructor.newInstance(clazzLoadBySeparateClassloader); runMethod = springJUnit4ClassRunnerClass.getMethod("run", RunNotifier.class); if (annotation != null) { excludeClasses = annotation.value(); } } catch (Throwable e) { throw new InitializationError(e); } }
Example #8
Source File: HashemTestRunner.java From mr-hashemi with Universal Permissive License v1.0 | 5 votes |
public HashemTestRunner(Class<?> runningClass) throws InitializationError { super(runningClass); try { testCases = createTests(runningClass); } catch (IOException e) { throw new InitializationError(e); } }
Example #9
Source File: AbstractMultiTestRunner.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private void initExecutions() { if (executions.isEmpty()) { 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); } } }
Example #10
Source File: ArchUnitRunnerTest.java From ArchUnit with Apache License 2.0 | 5 votes |
@Test public void rejects_missing_analyze_annotation() throws InitializationError { thrown.expect(ArchTestInitializationException.class); thrown.expectMessage(Object.class.getSimpleName()); thrown.expectMessage("must be annotated"); thrown.expectMessage(AnalyzeClasses.class.getSimpleName()); new ArchUnitRunner(Object.class); }
Example #11
Source File: SpringJUnit4ClassRunner.java From java-technology-stack with MIT License | 5 votes |
/** * Construct a new {@code SpringJUnit4ClassRunner} and initialize a * {@link TestContextManager} to provide Spring testing functionality to * standard JUnit tests. * @param clazz the test class to be run * @see #createTestContextManager(Class) */ public SpringJUnit4ClassRunner(Class<?> clazz) throws InitializationError { super(clazz); if (logger.isDebugEnabled()) { logger.debug("SpringJUnit4ClassRunner constructor called with [" + clazz + "]"); } ensureSpringRulesAreNotPresent(clazz); this.testContextManager = createTestContextManager(clazz); }
Example #12
Source File: SpringRunnerWithCallableProtectedMethods.java From quickperf with Apache License 2.0 | 5 votes |
static SpringRunnerWithCallableProtectedMethods buildSpringRunner(Class<?> testClass) { try { return new SpringRunnerWithCallableProtectedMethods(testClass); } catch (InitializationError initializationError) { throw new IllegalStateException(initializationError); } }
Example #13
Source File: WeldJUnit4Runner.java From microprofile-jwt-auth with Apache License 2.0 | 5 votes |
public WeldJUnit4Runner(final Class<Object> klass) throws InitializationError { super(klass); this.klass = klass; // Uncomment to enable verbose tracing of CDI //enableJDKConsoleLogging(Level.FINEST); this.weld = new Weld(); /* Use this to put the Weld container in development with export of the trace information to the /tmp directory this.weld = new Weld().property("org.jboss.weld.development", true) .property("org.jboss.weld.probe.exportDataAfterDeployment", "/tmp/"); */ this.container = weld.initialize(); // This is currently needed in order for a class called by the ServiceLoader to be able to access the CDI instance WeldSEProvider cdi = new WeldSEProvider(); CDI.setCDIProvider(cdi); }
Example #14
Source File: SpringRunnerWithCallableProtectedMethods.java From quickperf with Apache License 2.0 | 5 votes |
static SpringRunnerWithCallableProtectedMethods buildSpringRunner(Class<?> testClass) { try { return new SpringRunnerWithCallableProtectedMethods(testClass); } catch (InitializationError initializationError) { throw new IllegalStateException(initializationError); } }
Example #15
Source File: BddScenariosCounter.java From vividus with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws ParseException, InitializationError, ReflectiveOperationException { Vividus.init(); CommandLineParser parser = new DefaultParser(); Option helpOption = new Option("h", "help", false, "print this message."); Option directoryOption = new Option("d", "dir", true, "directory to count scenarios in (e.g. story/release)."); Options options = new Options(); options.addOption(helpOption); options.addOption(directoryOption); CommandLine commandLine = parser.parse(options, args); if (commandLine.hasOption(helpOption.getOpt())) { new HelpFormatter().printHelp("BddScenariosCounter", options); return; } String storyLocation = commandLine.hasOption(directoryOption.getOpt()) ? commandLine.getOptionValue(directoryOption.getOpt()) : DEFAULT_STORY_LOCATION; configureStoryLocation(storyLocation); System.out.println("Story parsing may take up to 5 minutes. Please be patient."); JUnitReportingRunner runner = new JUnitReportingRunner(StoriesRunner.class); print(getNumberOfChildren(runner.getDescription(), BDDLevel.STORY.getLevel()), "Stories"); print(getNumberOfChildren(runner.getDescription(), BDDLevel.SCENARIO.getLevel()), "Scenarios"); print(getNumberOfChildren(runner.getDescription(), BDDLevel.EXAMPLE.getLevel()), "Scenarios with Examples"); }
Example #16
Source File: SpringJUnit4ParameterizedClassRunner.java From tds with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Constructs a new <code>SpringJUnit4ClassRunner</code> and initializes a * {@link TestContextManager} to provide Spring testing functionality to * standard JUnit tests. * * @param type the test class to be run * @see #createTestContextManager(Class) */ TestClassRunnerForParameters(Class<?> type, List<Object[]> parameterList, int i) throws InitializationError { super(type); if (logger.isDebugEnabled()) { logger.debug("SpringJUnit4ClassRunner constructor called with [" + type + "]."); } fParameterList = parameterList; fParameterSetNumber = i; this.testContextManager = createTestContextManager(type); }
Example #17
Source File: SpringJUnit4ClassRunner.java From spring-analysis-note with MIT License | 5 votes |
/** * Construct a new {@code SpringJUnit4ClassRunner} and initialize a * {@link TestContextManager} to provide Spring testing functionality to * standard JUnit tests. * @param clazz the test class to be run * @see #createTestContextManager(Class) */ public SpringJUnit4ClassRunner(Class<?> clazz) throws InitializationError { super(clazz); if (logger.isDebugEnabled()) { logger.debug("SpringJUnit4ClassRunner constructor called with [" + clazz + "]"); } ensureSpringRulesAreNotPresent(clazz); this.testContextManager = createTestContextManager(clazz); }
Example #18
Source File: HashemTestRunner.java From mr-hashemi with Universal Permissive License v1.0 | 5 votes |
public static void runInMain(Class<?> testClass, String[] args) throws InitializationError, NoTestsRemainException { JUnitCore core = new JUnitCore(); core.addListener(new TextListener(System.out)); HashemTestRunner suite = new HashemTestRunner(testClass); if (args.length > 0) { suite.filter(new NameFilter(args[0])); } Result r = core.run(suite); if (!r.wasSuccessful()) { System.exit(1); } }
Example #19
Source File: AbstractMultiTestRunner.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private void initExecutions() { if (executions.isEmpty()) { 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); } } }
Example #20
Source File: SpringRunnerWithCallableProtectedMethods.java From quickperf with Apache License 2.0 | 5 votes |
static SpringRunnerWithCallableProtectedMethods buildSpringRunner(Class<?> testClass) { try { return new SpringRunnerWithCallableProtectedMethods(testClass); } catch (InitializationError initializationError) { throw new IllegalStateException(initializationError); } }
Example #21
Source File: ArkJUnit4RunnerTest.java From sofa-ark with Apache License 2.0 | 5 votes |
@Test public void testJUnitRunner() { try { Assert.assertTrue("@Before".equals(state)); state = "@Test"; ArkJUnit4Runner runner = new ArkJUnit4Runner(ArkJUnit4RunnerTest.class); ClassLoader loader = runner.getTestClass().getJavaClass().getClassLoader(); Assert.assertTrue(loader.getClass().getCanonicalName() .equals(TestClassLoader.class.getCanonicalName())); } catch (InitializationError error) { Assert.fail(error.getMessage()); } }
Example #22
Source File: EmissaryIsolatedClassloaderRunner.java From emissary with Apache License 2.0 | 5 votes |
private static Class<?> getFromTestClassloader(Class<?> clazz) throws InitializationError { try { ClassLoader testClassLoader = new TestClassLoader(); return Class.forName(clazz.getName(), true, testClassLoader); } catch (ClassNotFoundException e) { throw new InitializationError(e); } }
Example #23
Source File: StructureBasicSuite.java From hugegraph with Apache License 2.0 | 5 votes |
public StructureBasicSuite(final Class<?> klass, final RunnerBuilder builder) throws InitializationError, ConfigurationException { super(klass, builder, allTests, null, true, TraversalEngine.Type.STANDARD); RegisterUtil.registerBackends(); }
Example #24
Source File: ProcessBasicSuite.java From hugegraph with Apache License 2.0 | 5 votes |
public ProcessBasicSuite(final Class<?> klass, final RunnerBuilder builder) throws InitializationError { super(klass, builder, allTests, testsToEnforce, true, TraversalEngine.Type.STANDARD); RegisterUtil.registerBackends(); }
Example #25
Source File: ResourceCentricBlockJUnit4ClassRunner.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
public ResourceCentricBlockJUnit4ClassRunner(Class<?> klass) throws InitializationError { super(klass); classRequiredResourcesAnnotation = klass.getAnnotation(RequiredResources.class); resourcesToBeDestroyedAfterAllTests = new HashSet<TestResource>(); }
Example #26
Source File: ArchUnitRunnerTestUtils.java From ArchUnit with Apache License 2.0 | 5 votes |
static ArchUnitRunner newRunnerFor(Class<?> testClass) { try { return new ArchUnitRunner(testClass); } catch (InitializationError initializationError) { throw new RuntimeException(initializationError); } }
Example #27
Source File: TckTestRunner.java From smallrye-open-api with Apache License 2.0 | 5 votes |
/** * Figures out what TCK test is being run. * * @throws InitializationError */ @SuppressWarnings("unchecked") private Class<? extends Arquillian> determineTckTestClass(Class<?> testClass) throws InitializationError { ParameterizedType ptype = (ParameterizedType) testClass.getGenericSuperclass(); Class cc = (Class) ptype.getActualTypeArguments()[0]; return cc; }
Example #28
Source File: BytecoderUnitTestRunner.java From Bytecoder with Apache License 2.0 | 5 votes |
public BytecoderUnitTestRunner(final Class aClass) throws InitializationError { super(aClass); testOptions = new ArrayList<>(); final BytecoderTestOptions declaredOptions = getTestClass().getJavaClass().getAnnotation(BytecoderTestOptions.class); if (declaredOptions != null) { if (declaredOptions.includeJVM()) { testOptions.add(new TestOption(null, false, false, false, false)); } if (declaredOptions.value().length == 0 && declaredOptions.includeTestPermutations()) { testOptions.add(new TestOption(CompileTarget.BackendType.js, false, false, false, false)); testOptions.add(new TestOption(CompileTarget.BackendType.js, false, false, true, false)); testOptions.add(new TestOption(CompileTarget.BackendType.js, true, false, false, false)); testOptions.add(new TestOption(CompileTarget.BackendType.wasm, false, false, false, false)); testOptions.add(new TestOption(CompileTarget.BackendType.wasm, true, false, false, false)); //testOptions.add(new TestOption(CompileTarget.BackendType.wasm_llvm, false, false, false, false)); testOptions.add(new TestOption(CompileTarget.BackendType.wasm_llvm, false, false, false, true)); } else { for (final BytecoderTestOption o : declaredOptions.value()) { testOptions.add(new TestOption(o.backend(), o.preferStackifier(), o.exceptionsEnabled(), o.minify(), o. escapeAnalysisEnabled())); } } additionalClassesToLink = declaredOptions.additionalClassesToLink(); additionalResources = declaredOptions.additionalResources(); } else { testOptions.add(new TestOption(null, false, false, false, false)); testOptions.add(new TestOption(CompileTarget.BackendType.js, false, false, false, false)); testOptions.add(new TestOption(CompileTarget.BackendType.js, false, false, true, false)); testOptions.add(new TestOption(CompileTarget.BackendType.js, true, false, false, false)); testOptions.add(new TestOption(CompileTarget.BackendType.wasm, false, false, false, false)); testOptions.add(new TestOption(CompileTarget.BackendType.wasm, true, false, false, false)); //testOptions.add(new TestOption(CompileTarget.BackendType.wasm_llvm, false, false, false, false)); testOptions.add(new TestOption(CompileTarget.BackendType.wasm_llvm, false, false, false, true)); additionalClassesToLink = new String[0]; additionalResources = new String[0]; } }
Example #29
Source File: SmokeTestSuite.java From firebase-android-sdk with Apache License 2.0 | 5 votes |
private static List<Class<?>> getTestClasses(Context ctx) throws InitializationError { List<String> names = getTestClassNames(ctx); ArrayList<Class<?>> classes = new ArrayList<>(names.size()); try { for (String name : names) { Class<?> c = Class.forName(name); classes.add(c); } } catch (ClassNotFoundException ex) { throw new InitializationError(ex); } return classes; }
Example #30
Source File: JustTestLahRunner.java From justtestlah with Apache License 2.0 | 4 votes |
/** * This is the code taken from {@link io.cucumber.junit.Cucumber} * * @param clazz {@link Class} * @throws InitializationError {@link InitializationError} */ private void initCucumber(Class<?> clazz) throws InitializationError { Assertions.assertNoCucumberAnnotatedMethods(clazz); // Parse the options early to provide fast feedback about invalid options RuntimeOptions propertiesFileOptions = new CucumberPropertiesParser().parse(CucumberProperties.fromPropertiesFile()).build(); RuntimeOptions annotationOptions = new CucumberOptionsAnnotationParser() .withOptionsProvider(new JUnitCucumberOptionsProvider()) .parse(clazz) .build(propertiesFileOptions); RuntimeOptions environmentOptions = new CucumberPropertiesParser() .parse(CucumberProperties.fromEnvironment()) .build(annotationOptions); RuntimeOptions runtimeOptions = new CucumberPropertiesParser() .parse(CucumberProperties.fromSystemProperties()) .addDefaultSummaryPrinterIfAbsent() .build(environmentOptions); if (!runtimeOptions.isStrict()) { LOG.warn( "By default Cucumber is running in --non-strict mode.\n" + "This default will change to --strict and --non-strict will be removed.\n" + "You can use --strict or @CucumberOptions(strict = true) to suppress this warning"); } // Next parse the junit options JUnitOptions junitPropertiesFileOptions = new JUnitOptionsParser().parse(CucumberProperties.fromPropertiesFile()).build(); JUnitOptions junitAnnotationOptions = new JUnitOptionsParser().parse(clazz).build(junitPropertiesFileOptions); JUnitOptions junitEnvironmentOptions = new JUnitOptionsParser() .parse(CucumberProperties.fromEnvironment()) .build(junitAnnotationOptions); JUnitOptions junitOptions = new JUnitOptionsParser() .parse(CucumberProperties.fromSystemProperties()) .setStrict(runtimeOptions.isStrict()) .build(junitEnvironmentOptions); this.bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID); // Parse the features early. Don't proceed when there are lexer errors FeatureParser parser = new FeatureParser(bus::generateId); Supplier<ClassLoader> classLoader = ClassLoaders::getDefaultClassLoader; FeaturePathFeatureSupplier featureSupplier = new FeaturePathFeatureSupplier(classLoader, runtimeOptions, parser); this.features = featureSupplier.get(); // Create plugins after feature parsing to avoid the creation of empty files on // lexer errors. this.plugins = new Plugins(new PluginFactory(), runtimeOptions); ObjectFactoryServiceLoader objectFactoryServiceLoader = new ObjectFactoryServiceLoader(runtimeOptions); ObjectFactorySupplier objectFactorySupplier = new ThreadLocalObjectFactorySupplier(objectFactoryServiceLoader); BackendSupplier backendSupplier = new BackendServiceLoader(clazz::getClassLoader, objectFactorySupplier); TypeRegistryConfigurerSupplier typeRegistryConfigurerSupplier = new ScanningTypeRegistryConfigurerSupplier(classLoader, runtimeOptions); ThreadLocalRunnerSupplier runnerSupplier = new ThreadLocalRunnerSupplier( runtimeOptions, bus, backendSupplier, objectFactorySupplier, typeRegistryConfigurerSupplier); Predicate<Pickle> filters = new Filters(runtimeOptions); this.children = features.stream() .map(feature -> FeatureRunner.create(feature, filters, runnerSupplier, junitOptions)) .filter(runner -> !runner.isEmpty()) .collect(toList()); LOG.info( "Found {} feature(s) in {}: {}", features.size(), System.getProperty("cucumber.features"), features); }