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


Java Runner类代码示例

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


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

示例1: allTestsFiltered

import org.junit.runner.Runner; //导入依赖的package包/类
private boolean allTestsFiltered(Runner runner, List<Filter> filters) {
    LinkedList<Description> queue = new LinkedList<Description>();
    queue.add(runner.getDescription());
    while (!queue.isEmpty()) {
        Description description = queue.removeFirst();
        queue.addAll(description.getChildren());
        boolean run = true;
        for (Filter filter : filters) {
            if (!filter.shouldRun(description)) {
                run = false;
                break;
            }
        }
        if (run) {
            return false;
        }
    }
    return true;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:20,代码来源:JUnitTestClassExecuter.java

示例2: runnerForClass

import org.junit.runner.Runner; //导入依赖的package包/类
@Override
public Runner runnerForClass(Class<?> testClass) throws Throwable {
    try {
        return new BlockJUnit4ClassRunner(testClass);
    } catch (Throwable t) {
        //failed to instantiate BlockJUnitRunner. try deprecated JUnitRunner (for JUnit < 4.5)
        try {
            Class<Runner> runnerClass = (Class<Runner>) Thread.currentThread().getContextClassLoader().loadClass("org.junit.internal.runners.JUnit4ClassRunner");
            final Constructor<Runner> constructor = runnerClass.getConstructor(Class.class);
            return constructor.newInstance(testClass);
        } catch (Throwable e) {
            LoggerFactory.getLogger(getClass()).warn("Unable to load JUnit4 runner to calculate Ignored test cases", e);
        }
    }
    return null;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:AllExceptIgnoredTestRunnerBuilder.java

示例3: parallelize

import org.junit.runner.Runner; //导入依赖的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

示例4: createRunners

import org.junit.runner.Runner; //导入依赖的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;
}
 
开发者ID:tools4j,项目名称:spockito,代码行数:18,代码来源:Spockito.java

示例5: runTestsAndAssertCounters

import org.junit.runner.Runner; //导入依赖的package包/类
/**
 * Run the tests in the supplied {@code testClass}, using the specified
 * {@link Runner}, and assert the expectations of the test execution.
 *
 * <p>If the specified {@code runnerClass} is {@code null}, the tests
 * will be run with the runner that the test class is configured with
 * (i.e., via {@link RunWith @RunWith}) or the default JUnit runner.
 *
 * @param runnerClass the explicit runner class to use or {@code null}
 * if the implicit runner should be used
 * @param testClass the test class to run with JUnit
 * @param expectedStartedCount the expected number of tests that started
 * @param expectedFailedCount the expected number of tests that failed
 * @param expectedFinishedCount the expected number of tests that finished
 * @param expectedIgnoredCount the expected number of tests that were ignored
 * @param expectedAssumptionFailedCount the expected number of tests that
 * resulted in a failed assumption
 */
public static void runTestsAndAssertCounters(Class<? extends Runner> runnerClass, Class<?> testClass,
		int expectedStartedCount, int expectedFailedCount, int expectedFinishedCount, int expectedIgnoredCount,
		int expectedAssumptionFailedCount) throws Exception {

	TrackingRunListener listener = new TrackingRunListener();

	if (runnerClass != null) {
		Constructor<?> constructor = runnerClass.getConstructor(Class.class);
		Runner runner = (Runner) BeanUtils.instantiateClass(constructor, testClass);
		RunNotifier notifier = new RunNotifier();
		notifier.addListener(listener);
		runner.run(notifier);
	}
	else {
		JUnitCore junit = new JUnitCore();
		junit.addListener(listener);
		junit.run(testClass);
	}

	assertEquals("tests started for [" + testClass + "]:", expectedStartedCount, listener.getTestStartedCount());
	assertEquals("tests failed for [" + testClass + "]:", expectedFailedCount, listener.getTestFailureCount());
	assertEquals("tests finished for [" + testClass + "]:", expectedFinishedCount, listener.getTestFinishedCount());
	assertEquals("tests ignored for [" + testClass + "]:", expectedIgnoredCount, listener.getTestIgnoredCount());
	assertEquals("failed assumptions for [" + testClass + "]:", expectedAssumptionFailedCount, listener.getTestAssumptionFailureCount());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:44,代码来源:JUnitTestingUtils.java

示例6: CustomRunner

import org.junit.runner.Runner; //导入依赖的package包/类
public CustomRunner(Class<?> klass, RunnerBuilder builder) throws InitializationError {
    super(
            klass,
            new RunnerBuilder() {
                @Override public Runner runnerForClass(Class<?> testClass) throws Throwable {
                    Boolean oldValue = IS_FAST_TEST_SUITE_ACTIVE.get();

                    try {
                        IS_FAST_TEST_SUITE_ACTIVE.set(true);
                        Runner r = builder.runnerForClass(testClass);
                        return r;
                    } finally {
                        IS_FAST_TEST_SUITE_ACTIVE.set(oldValue);
                    }
                }
            }
    );
}
 
开发者ID:awslabs,项目名称:aws-encryption-sdk-java,代码行数:19,代码来源:FastTestsOnlySuite.java

示例7: createRunnersForParameters

import org.junit.runner.Runner; //导入依赖的package包/类
private List<Runner> createRunnersForParameters(
        Iterable<Object> allParameters, String namePattern,
        ParametersRunnerFactory runnerFactory) throws Exception {
    try {
        List<TestWithParameters> tests = createTestsForParameters(
                allParameters, namePattern);
        List<Runner> runners = new ArrayList<Runner>();
        for (TestWithParameters test : tests) {
            runners.add(runnerFactory
                    .createRunnerForTestWithParameters(test));
        }
        return runners;
    } catch (ClassCastException e) {
        throw parametersMethodReturnedWrongType();
    }
}
 
开发者ID:hortonworks,项目名称:registry,代码行数:17,代码来源:CustomParameterizedRunner.java

示例8: getClientRunner

import org.junit.runner.Runner; //导入依赖的package包/类
@Override
public Runner getClientRunner(Class<?> testClass) {
    String  serverHost = System.getProperty(SupportedConfigurationProperties.Client.SERVER_HOST, "localhost");
    Integer serverPort = Integer.parseInt(System.getProperty(SupportedConfigurationProperties.Client.SERVER_PORT, "7890"));

    SocketSupplier clientSocketSupplier = new RetrySupportClientSocketSupplier(
            new ClientSocketSupplier(serverHost, serverPort),
            Long.parseLong(
                    System.getProperty(SupportedConfigurationProperties.Client.MAX_CONNECTION_WAIT_PERIOD,
                                       String.valueOf(RetrySupportClientSocketSupplier.DEFAULT_MAX_WAIT_PERIOD_MS))),
            new DefaultClock(),
            new DefaultThreadSleeper()
    );
    DefaultRemoteInvoker remoteInvoker = new DefaultRemoteInvoker(clientSocketSupplier);
    ClientSideInternalRemoteRunner runner = new ClientSideInternalRemoteRunner(testClass, remoteInvoker);
    runner.init();
    return runner;
}
 
开发者ID:MarkBramnik,项目名称:rtest,代码行数:19,代码来源:RealRunnerProviderImpl.java

示例9: resolveRealRunner

import org.junit.runner.Runner; //导入依赖的package包/类
private Runner resolveRealRunner(Class<?> testClass){
    RealRunner realRunner = testClass.getAnnotation(RealRunner.class);
    if(realRunner == null) {
        // the real runner annotation is not specified - we'll just use Spock's default
        // Sputnik runner
        try {
            return new Sputnik(testClass);
        } catch (InitializationError initializationError) {
            LOG.warn("Failed to initialize a sputnik runner", initializationError);
            throw new RTestException(initializationError);
        }
    }
    else {
        try {
            return realRunner.value().getConstructor(testClass.getClass()).newInstance(testClass);
        } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new RTestException("Failed to instantiate the real runner ", e);
        }
    }
}
 
开发者ID:MarkBramnik,项目名称:rtest,代码行数:21,代码来源:ServerSideInternalRemoteRunner.java

示例10: getRunner

import org.junit.runner.Runner; //导入依赖的package包/类
@Override
public Runner getRunner()
{
	Runner runner = null;
	try
	{
		runner = new DynamicClasspathHybrisJUnit4ClassRunner(clazz);
	}
	catch (InitializationError initializationError)
	{
		initializationError.printStackTrace();
		throw new RuntimeException(initializationError);
	}

	return runner;
}
 
开发者ID:SAP,项目名称:hybris-commerce-eclipse-plugin,代码行数:17,代码来源:HybrisJUnitRequest.java

示例11: getDescription

import org.junit.runner.Runner; //导入依赖的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

示例12: runChildren

import org.junit.runner.Runner; //导入依赖的package包/类
private void runChildren(@SuppressWarnings("hiding") final RunNotifier notifier) {
    RunnerScheduler currentScheduler = scheduler;
    try {
        List<Runner> roots = graph.getRoots().stream().map(r -> nameToRunner.get(r)).collect(Collectors.toList());
        for (Runner each : roots) {
            currentScheduler.schedule(new Runnable() {
                @Override
                public void run() {
                    ConcurrentDependsOnClasspathSuite.this.runChild(each, notifier);
                }
            });
        }
    } finally {
        currentScheduler.finished();
    }
}
 
开发者ID:aafuks,项目名称:aaf-junit,代码行数:17,代码来源:ConcurrentDependsOnClasspathSuite.java

示例13: getChildren

import org.junit.runner.Runner; //导入依赖的package包/类
@Override
protected List<Runner> getChildren() {
    List<Runner> children = super.getChildren();
    
    if (override != null) {
        for (Iterator<Runner> iterator = children.iterator(); iterator.hasNext(); ) {
            Runner child = iterator.next();
            String fName = child.getDescription().getDisplayName();
            if (fName.startsWith("[") && fName.endsWith("]")) {
                fName = fName.substring(1, fName.length()-1);
            }
            if (overrideIsRegex && !paramNameMatchesRegex(fName, override)) {
                iterator.remove();
            }
            else if (!overrideIsRegex && !fName.equals(override)) {
                iterator.remove();
            }
        }
    }        
    return children;
}
 
开发者ID:jaytaylor,项目名称:sql-layer,代码行数:22,代码来源:SelectedParameterizedRunner.java

示例14: testParameterizations

import org.junit.runner.Runner; //导入依赖的package包/类
/**
 * Confirms that each given name has a {@linkplain ReifiedParamRunner} associated with it, and returns the
 * name -> runner map
 * @param runner the parameterized runner
 * @param names the expected names
 * @return a map of names to reified runners
 */
private static Map<String,ReifiedParamRunner> testParameterizations(NamedParameterizedRunner runner, String... names)
{
    List<Runner> children = runner.getChildren();
    assertEquals("children.size()", names.length, children.size());

    Set<String> expectedNames = new HashSet<>(names.length, 1.0f);
    for (String name : names) {
        assertTrue("unexpected error, duplicate name: " + name, expectedNames.add(name));
    }

    Map<String,ReifiedParamRunner> foundRunners = new HashMap<>();
    for (Runner child : children)
    {
        ReifiedParamRunner reified = (ReifiedParamRunner)child;
        String paramToString = reified.paramToString();
        assertNull("duplicate name: " + paramToString, foundRunners.put(paramToString, reified));
    }

    for (String expected : expectedNames)
    {
        assertTrue("didn't find expected param: " + expected, foundRunners.containsKey(expected));
    }

    return foundRunners;
}
 
开发者ID:jaytaylor,项目名称:sql-layer,代码行数:33,代码来源:NamedParameterizedRunnerTest.java

示例15: createRunners

import org.junit.runner.Runner; //导入依赖的package包/类
private static List<Runner> createRunners(Function<Schema, MsgCodec> codecFactory) throws InitializationError {
    List<Runner> runners = new ArrayList<>();
    
    Schema originalSchema = PairedTestProtocols.getOriginalSchema();
    Schema upgradedSchema = PairedTestProtocols.getUpgradedSchema();

    try {
        for (Map.Entry<String, PairedMessages> messageEntry : PairedTestProtocols.createMessages().entrySet()) {
            runners.add(new InboundTest(originalSchema, upgradedSchema, codecFactory, "InboundTest." + messageEntry.getKey(), 
                    messageEntry.getValue().originalMessage, messageEntry.getValue().upgradedMessage));
            runners.add(new OutboundTest(originalSchema, upgradedSchema, codecFactory,"OutboundTest." + messageEntry.getKey(), 
                    messageEntry.getValue().originalMessage, messageEntry.getValue().upgradedMessage));
            runners.add(new InboundGroupTest(originalSchema, upgradedSchema, codecFactory, "InboundGroupTest." + messageEntry.getKey(),
                    messageEntry.getValue().originalMessage, messageEntry.getValue().upgradedMessage));
            runners.add(new OutboundGroupTest(originalSchema, upgradedSchema, codecFactory,"OutboundGroupTest." + messageEntry.getKey(),
                    messageEntry.getValue().originalMessage, messageEntry.getValue().upgradedMessage));
        }
    } catch (IncompatibleSchemaException e) {
        throw new InitializationError(e);
    }

    return runners;
}
 
开发者ID:cinnober,项目名称:msgcodec,代码行数:24,代码来源:TestUpgradesSuite.java


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