当前位置: 首页>>代码示例>>Java>>正文


Java ParentRunner类代码示例

本文整理汇总了Java中org.junit.runners.ParentRunner的典型用法代码示例。如果您正苦于以下问题:Java ParentRunner类的具体用法?Java ParentRunner怎么用?Java ParentRunner使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ParentRunner类属于org.junit.runners包,在下文中一共展示了ParentRunner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parallelize

import org.junit.runners.ParentRunner; //导入依赖的package包/类
private static Runner parallelize(Runner runner) {
    int nThreads = Integer.getInteger(Constants.NTHREADS, Runtime.getRuntime().availableProcessors());
    LOGGER.info("Using " + nThreads + " threads.");
    if (runner instanceof ParentRunner) {
        ((ParentRunner<?>) runner).setScheduler(new RunnerScheduler() {
            private final ExecutorService fService = Executors.newFixedThreadPool(nThreads);

            @Override public void schedule(Runnable childStatement) {
                fService.submit(childStatement);
            }

            @Override public void finished() {
                try {
                    fService.shutdown();
                    fService.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
                } catch (InterruptedException e) {
                    e.printStackTrace(System.err);
                }
            }
        });
    }
    return runner;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:24,代码来源:ParallelComputer.java

示例2: ensureInitialized

import org.junit.runners.ParentRunner; //导入依赖的package包/类
/**
 * Initializes this runner by initializing {@link #expectedMethods} with the list of methods which are expected to be called. This is then also checked by
 * {@link #methodBlock(FrameworkMethod)} and allows identifying the first and last methods correctly.
 */
private void ensureInitialized() {
  if (expectedMethods == null) {
    try {
      final Method getChildrenMethod = ParentRunner.class.getDeclaredMethod("getFilteredChildren"); //$NON-NLS-1$
      getChildrenMethod.setAccessible(true);
      @SuppressWarnings("unchecked")
      final Collection<FrameworkMethod> testMethods = (Collection<FrameworkMethod>) getChildrenMethod.invoke(this);
      expectedMethods = ImmutableList.copyOf(Iterables.filter(testMethods, new Predicate<FrameworkMethod>() {
        @Override
        public boolean apply(final FrameworkMethod input) {
          return input.getAnnotation(Ignore.class) == null;
        }
      }));
      currentMethodIndex = 0;
      // CHECKSTYLE:OFF
    } catch (Exception e) {
      // CHECKSTYLE:ON
      throw new IllegalStateException(e);
    }
  }
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:26,代码来源:ClassRunner.java

示例3: getDescription

import org.junit.runners.ParentRunner; //导入依赖的package包/类
public Description getDescription() {
  Description description = Description.createSuiteDescription(myName, getTestClass().getAnnotations());
  try {
    final Method getFilteredChildrenMethod = ParentRunner.class.getDeclaredMethod("getFilteredChildren", new Class[0]);
    getFilteredChildrenMethod.setAccessible(true);
    Collection filteredChildren = (Collection)getFilteredChildrenMethod.invoke(this, new Object[0]);
    for (Iterator iterator = filteredChildren.iterator(); iterator.hasNext();) {
      Object child = iterator.next();
      description.addChild(describeChild((Runner)child));
    }
  }
  catch (Exception e) {
    e.printStackTrace();
  }
  return description;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:IdeaSuite.java

示例4: makeLink

import org.junit.runners.ParentRunner; //导入依赖的package包/类
public ParentRunner<?> makeLink(Class<? extends ParentRunner<?>> runnerClass, final Class<?> testClass,
                                final CompositeRunner compositeRunner, final ParentRunner<?> nextRunner,
                                boolean isTestStructureProvider) throws InitializationError {
    ClassPool pool = ClassPool.getDefault();

    String newClassName = runnerClass.getName() + (isTestStructureProvider ? "TestStructureProvider" : "ChainLink");
    final Class<?> newRunnerCtClass = makeLinkClass(pool, newClassName, runnerClass, isTestStructureProvider);

    try {
        return (ParentRunner<?>) new ReflectiveCallable() {
            @Override
            protected Object runReflectiveCall() throws Throwable {
                return newRunnerCtClass.getConstructor(Class.class, CompositeRunner.class, ParentRunner.class)
                    .newInstance(testClass, compositeRunner, nextRunner);
            }
        }.run();
    } catch (InitializationError e) {
        throw e;
    } catch (Throwable throwable) {
        throw new RuntimeException(throwable);
    }
}
 
开发者ID:diosmosis,项目名称:junit-composite-runner,代码行数:23,代码来源:RunnerChainLinkFactory.java

示例5: buildFeatureElementRunners

import org.junit.runners.ParentRunner; //导入依赖的package包/类
private void buildFeatureElementRunners() {
   for (CucumberTagStatement cucumberTagStatement : cucumberFeature
      .getFeatureElements()) {
      try {
         ParentRunner<?> featureElementRunner;
         if (cucumberTagStatement instanceof CucumberScenario) {
            featureElementRunner =
               new RestExecutionUnitRunner(runtime, cucumberTagStatement,
                  jUnitReporter, cucumberFeature);
         } else {
            featureElementRunner =
               new RestScenarioOutlineRunner(runtime,
                  (CucumberScenarioOutline) cucumberTagStatement, jUnitReporter,
                  cucumberFeature);
         }
         children.add(featureElementRunner);
      } catch (InitializationError e) {
         throw new CucumberException("Failed to create scenario runner", e);
      }
   }
}
 
开发者ID:LiamHayes1,项目名称:rest-cucumber,代码行数:22,代码来源:RestFeatureRunner.java

示例6: parallelize

import org.junit.runners.ParentRunner; //导入依赖的package包/类
private static Runner parallelize(Runner runner) {
    if (runner instanceof ParentRunner) {
        ((ParentRunner<?>) runner).setScheduler(new RunnerScheduler() {
            private final ExecutorService fService = Executors.newCachedThreadPool();

            public void schedule(Runnable childStatement) {
                fService.submit(childStatement);
            }

            public void finished() {
                try {
                    fService.shutdown();
                    fService.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
                } catch (InterruptedException e) {
                    e.printStackTrace(System.err);
                }
            }
        });
    }
    return runner;
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:22,代码来源:ParallelComputer.java

示例7: useChildHarvester

import org.junit.runners.ParentRunner; //导入依赖的package包/类
@Test
public void useChildHarvester() throws InitializationError {
    log = "";
    ParentRunner<?> runner = new BlockJUnit4ClassRunner(FruitTest.class);
    runner.setScheduler(new RunnerScheduler() {
        public void schedule(Runnable childStatement) {
            log += "before ";
            childStatement.run();
            log += "after ";
        }

        public void finished() {
            log += "afterAll ";
        }
    });

    runner.run(new RunNotifier());
    assertEquals("before apple after before banana after afterAll ", log);
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:20,代码来源:ParentRunnerTest.java

示例8: noBeforeOnClasspath

import org.junit.runners.ParentRunner; //导入依赖的package包/类
@Test
public void noBeforeOnClasspath() throws Exception {
  File libJar = tempFolder.newFile("lib.jar");
  try (FileOutputStream fis = new FileOutputStream(libJar);
      JarOutputStream jos = new JarOutputStream(fis)) {
    addClassToJar(jos, RunWith.class);
    addClassToJar(jos, JUnit4.class);
    addClassToJar(jos, BlockJUnit4ClassRunner.class);
    addClassToJar(jos, ParentRunner.class);
    addClassToJar(jos, SuperTest.class);
    addClassToJar(jos, SuperTest.class.getEnclosingClass());
  }
  compilationHelper
      .addSourceLines(
          "Test.java",
          "import org.junit.runner.RunWith;",
          "import org.junit.runners.JUnit4;",
          "import " + SuperTest.class.getCanonicalName() + ";",
          "@RunWith(JUnit4.class)",
          "class Test extends SuperTest {",
          "  @Override public void setUp() {}",
          "}")
      .setArgs(Arrays.asList("-cp", libJar.toString()))
      .doTest();
}
 
开发者ID:google,项目名称:error-prone,代码行数:26,代码来源:JUnit4SetUpNotRunTest.java

示例9: getDescription

import org.junit.runners.ParentRunner; //导入依赖的package包/类
public Description getDescription() {
  Description description = Description.createSuiteDescription(myName, getTestClass().getAnnotations());
  try {
    final Method getFilteredChildrenMethod = ParentRunner.class.getDeclaredMethod("getFilteredChildren", new Class[0]);
    getFilteredChildrenMethod.setAccessible(true);
    List filteredChildren = (List)getFilteredChildrenMethod.invoke(this, new Object[0]);
    for (int i = 0, filteredChildrenSize = filteredChildren.size(); i < filteredChildrenSize; i++) {
      Object child = filteredChildren.get(i);
      description.addChild(describeChild((Runner)child));
    }
  }
  catch (Exception e) {
    e.printStackTrace();
  }
  return description;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:IdeaSuite.java

示例10: getChildren

import org.junit.runners.ParentRunner; //导入依赖的package包/类
@Override
protected List getChildren() {
    try {
        Method method = ParentRunner.class.getDeclaredMethod("getChildren");
        method.setAccessible(true);
        return (List) method.invoke(oleasterRobolectricRunner);
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
        e.printStackTrace();
    }
    return new ArrayList();
}
 
开发者ID:bangarharshit,项目名称:Oleaster,代码行数:12,代码来源:RoboOleaster.java

示例11: describeChild

import org.junit.runners.ParentRunner; //导入依赖的package包/类
@Override
protected Description describeChild(Object object) {
    try {
        Method method = ParentRunner.class.getDeclaredMethod("describeChild", Object.class);
        method.setAccessible(true);
        return (Description) method.invoke(oleasterRobolectricRunner, object);
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
        e.printStackTrace();
    }
    return Description.EMPTY;
}
 
开发者ID:bangarharshit,项目名称:Oleaster,代码行数:12,代码来源:RoboOleaster.java

示例12: runChild

import org.junit.runners.ParentRunner; //导入依赖的package包/类
@Override
protected void runChild(Object object, RunNotifier runNotifier) {
    try {
        Method method = ParentRunner.class.getDeclaredMethod("runChild", Object.class, RunNotifier.class);
        method.setAccessible(true);
        method.invoke(oleasterRobolectricRunner, object, runNotifier);
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
        e.printStackTrace();
    }
}
 
开发者ID:bangarharshit,项目名称:Oleaster,代码行数:11,代码来源:RoboOleaster.java

示例13: parallelSchedulerTest

import org.junit.runners.ParentRunner; //导入依赖的package包/类
@Test
public void parallelSchedulerTest() throws Throwable {
    ParallelParameterized parallelParameterized = new ParallelParameterized(FibonacciTest.class);

    Class<?> clazz = parallelParameterized.getClass();

    while (clazz != ParentRunner.class) {
        clazz = clazz.getSuperclass();
    }

    Field schedulerField = clazz.getDeclaredField("scheduler");
    schedulerField.setAccessible(true);

    assertTrue(schedulerField.get(parallelParameterized) instanceof ParallelScheduler);
}
 
开发者ID:QACore,项目名称:Java-Testing-Toolbox,代码行数:16,代码来源:ParallelParameterizedTest.java

示例14: runChild

import org.junit.runners.ParentRunner; //导入依赖的package包/类
/**
 * Sets the thread's context class loader to the class loader for the test
 * class.
 */
@Override
protected void runChild(Runner runner, RunNotifier notifier) {
	ParentRunner<?> pr = (ParentRunner<?>) runner; // test class runner
	ClassLoader cl = null;
	try {
		cl = Thread.currentThread().getContextClassLoader();
		Thread.currentThread().setContextClassLoader(
				pr.getTestClass().getJavaClass().getClassLoader());
		super.runChild(runner, notifier);
	} finally {
		Thread.currentThread().setContextClassLoader(cl);
	}
}
 
开发者ID:vanilladb,项目名称:vanillacore,代码行数:18,代码来源:IsolatedClassLoaderSuite.java

示例15: initializeFilter

import org.junit.runners.ParentRunner; //导入依赖的package包/类
/**
 * Initializes the test filter.
 *
 * @param parentRunner
 *          the {@link ParentRunner} to initialize, must not be {@code null}
 */
public static void initializeFilter(final ParentRunner<?> parentRunner) {
  try {
    parentRunner.filter(INSTANCE);
  } catch (NoTestsRemainException e) {
    // we ignore the case where no children are left
  }
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:14,代码来源:FilterRegistry.java


注:本文中的org.junit.runners.ParentRunner类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。