类org.junit.runners.model.InitializationError源码实例Demo

下面列出了怎么用org.junit.runners.model.InitializationError的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: karate   文件: Karate.java
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());
}
 
源代码2 项目: courgette-jvm   文件: Courgette.java
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())));
    }
}
 
源代码3 项目: firebase-android-sdk   文件: SmokeTestSuite.java
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);
  }
}
 
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);
    }
}
 
源代码5 项目: justtestlah   文件: JustTestLahRunner.java
/**
 * 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);
  }
}
 
源代码6 项目: qpid-broker-j   文件: QpidTestRunner.java
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);
}
 
源代码7 项目: lambda-selenium   文件: LambdaTestSuite.java
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;
}
 
static SpringRunnerWithCallableProtectedMethods buildSpringRunner(Class<?> testClass) {
    try {
        return new SpringRunnerWithCallableProtectedMethods(testClass);
    } catch (InitializationError initializationError) {
        throw new IllegalStateException(initializationError);
    }
}
 
static SpringRunnerWithCallableProtectedMethods buildSpringRunner(Class<?> testClass) {
    try {
        return new SpringRunnerWithCallableProtectedMethods(testClass);
    } catch (InitializationError initializationError) {
        throw new IllegalStateException(initializationError);
    }
}
 
static SpringRunnerWithCallableProtectedMethods buildSpringRunner(Class<?> testClass) {
    try {
        return new SpringRunnerWithCallableProtectedMethods(testClass);
    } catch (InitializationError initializationError) {
        throw new IllegalStateException(initializationError);
    }
}
 
源代码11 项目: vividus   文件: BddScenariosCounter.java
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");
}
 
/**
 * 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);
}
 
源代码13 项目: mr-hashemi   文件: HashemTestRunner.java
public HashemTestRunner(Class<?> runningClass) throws InitializationError {
    super(runningClass);
    try {
        testCases = createTests(runningClass);
    } catch (IOException e) {
        throw new InitializationError(e);
    }
}
 
源代码14 项目: mr-hashemi   文件: HashemTestRunner.java
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);
    }
}
 
源代码15 项目: tds   文件: SpringJUnit4ParameterizedClassRunner.java
/**
 * 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);
}
 
/**
 * 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);
}
 
源代码17 项目: ArchUnit   文件: ArchUnitRunnerTest.java
@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);
}
 
源代码18 项目: pushfish-android   文件: AbstractMultiTestRunner.java
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);
        }
    }
}
 
源代码19 项目: pushfish-android   文件: AbstractMultiTestRunner.java
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);
        }
    }
}
 
源代码20 项目: firebase-android-sdk   文件: SmokeTestSuite.java
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;
}
 
源代码21 项目: sofa-ark   文件: ArkJUnit4RunnerTest.java
@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());
    }
}
 
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);
    }
}
 
源代码23 项目: hugegraph   文件: StructureBasicSuite.java
public StructureBasicSuite(final Class<?> klass,
                           final RunnerBuilder builder)
                           throws InitializationError,
                                  ConfigurationException {
    super(klass, builder, allTests, null, true,
          TraversalEngine.Type.STANDARD);

    RegisterUtil.registerBackends();
}
 
源代码24 项目: hugegraph   文件: ProcessBasicSuite.java
public ProcessBasicSuite(final Class<?> klass,
                         final RunnerBuilder builder)
                         throws InitializationError {
    super(klass, builder, allTests, testsToEnforce, true,
          TraversalEngine.Type.STANDARD);
    RegisterUtil.registerBackends();
}
 
public ResourceCentricBlockJUnit4ClassRunner(Class<?> klass)
        throws InitializationError {
    super(klass);

    classRequiredResourcesAnnotation = klass.getAnnotation(RequiredResources.class);
    resourcesToBeDestroyedAfterAllTests = new HashSet<TestResource>();
}
 
源代码26 项目: ArchUnit   文件: ArchUnitRunnerTestUtils.java
static ArchUnitRunner newRunnerFor(Class<?> testClass) {
    try {
        return new ArchUnitRunner(testClass);
    } catch (InitializationError initializationError) {
        throw new RuntimeException(initializationError);
    }
}
 
源代码27 项目: smallrye-open-api   文件: TckTestRunner.java
/**
 * 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;
}
 
源代码28 项目: Bytecoder   文件: BytecoderUnitTestRunner.java
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];
    }
}
 
源代码29 项目: microprofile-jwt-auth   文件: WeldJUnit4Runner.java
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);
}
 
private SpringRunnerWithCallableProtectedMethods(Class<?> clazz) throws InitializationError {
    super(clazz);
}
 
 类所在包
 同包方法