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


Java Runner.run方法代码示例

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


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

示例1: 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

示例2: runEnabledTests

import org.junit.runner.Runner; //导入方法依赖的package包/类
private void runEnabledTests(RunNotifier nested) {
    if (enabledTests.isEmpty()) {
        return;
    }

    Runner runner;
    try {
        runner = createExecutionRunner();
    } catch (Throwable t) {
        runner = new CannotExecuteRunner(getDisplayName(), target, t);
    }

    try {
        if (!disabledTests.isEmpty()) {
            ((Filterable) runner).filter(new Filter() {
                @Override
                public boolean shouldRun(Description description) {
                    return !disabledTests.contains(description);
                }

                @Override
                public String describe() {
                    return "disabled tests";
                }
            });
        }
    } catch (NoTestsRemainException e) {
        return;
    }

    runner.run(nested);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:33,代码来源:AbstractMultiTestRunner.java

示例3: runTest

import org.junit.runner.Runner; //导入方法依赖的package包/类
public static List<Failure> runTest(String fullQualifiedName, String testCaseName, String[] classpath) throws MalformedURLException, ClassNotFoundException {
    ClassLoader classLoader = new URLClassLoader(
            arrayStringToArrayUrl.apply(classpath),
            ClassLoader.getSystemClassLoader()
    );
    Request request = Request.method(classLoader.loadClass(fullQualifiedName), testCaseName);
    Runner runner = request.getRunner();
    RunNotifier fNotifier = new RunNotifier();
    final TestListener listener = new TestListener();
    fNotifier.addFirstListener(listener);
    fNotifier.fireTestRunStarted(runner.getDescription());
    runner.run(fNotifier);
    return listener.getTestFails();
}
 
开发者ID:SpoonLabs,项目名称:spoon-examples,代码行数:15,代码来源:TestRunner.java

示例4: runJUnitRequest

import org.junit.runner.Runner; //导入方法依赖的package包/类
public static Result runJUnitRequest(Request request) {
	RunNotifier notifier = new RunNotifier();
	Result result = new Result();
	RunListener listener = result.createListener();
	notifier.addListener(listener);
	Runner runner = request.getRunner();
	runner.run(notifier);
	return result;
}
 
开发者ID:piotrturski,项目名称:zohhak,代码行数:10,代码来源:JUnitLauncher.java

示例5: runTestClass

import org.junit.runner.Runner; //导入方法依赖的package包/类
private void runTestClass(String testClassName) throws ClassNotFoundException {
    final Class<?> testClass = Class.forName(testClassName, false, applicationClassLoader);
    Request request = Request.aClass(testClass);
    if (options.hasCategoryConfiguration()) {
        Transformer<Class<?>, String> transformer = new Transformer<Class<?>, String>() {
            public Class<?> transform(final String original) {
                try {
                    return applicationClassLoader.loadClass(original);
                } catch (ClassNotFoundException e) {
                    throw new InvalidUserDataException(String.format("Can't load category class [%s].", original), e);
                }
            }
        };
        request = request.filterWith(new CategoryFilter(
                CollectionUtils.collect(options.getIncludeCategories(), transformer),
                CollectionUtils.collect(options.getExcludeCategories(), transformer)
        ));
    }

    if (!options.getIncludedTests().isEmpty()) {
        request = request.filterWith(new MethodNameFilter(options.getIncludedTests()));
    }

    Runner runner = request.getRunner();
    //In case of no matching methods junit will return a ErrorReportingRunner for org.junit.runner.manipulation.Filter.class.
    //Will be fixed with adding class filters
    if (!org.junit.runner.manipulation.Filter.class.getName().equals(runner.getDescription().getDisplayName())) {
        RunNotifier notifier = new RunNotifier();
        notifier.addListener(listener);
        runner.run(notifier);
    }
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:33,代码来源:JUnitTestClassExecuter.java

示例6: runTestClass

import org.junit.runner.Runner; //导入方法依赖的package包/类
private void runTestClass(String testClassName) throws ClassNotFoundException {
    final Class<?> testClass = Class.forName(testClassName, true, applicationClassLoader);
    Request request = Request.aClass(testClass);
    if (options.hasCategoryConfiguration()) {
        Transformer<Class<?>, String> transformer = new Transformer<Class<?>, String>() {
            public Class<?> transform(final String original) {
                try {
                    return applicationClassLoader.loadClass(original);
                } catch (ClassNotFoundException e) {
                    throw new InvalidUserDataException(String.format("Can't load category class [%s].", original), e);
                }
            }
        };
        request = request.filterWith(new CategoryFilter(
                CollectionUtils.collect(options.getIncludeCategories(), transformer),
                CollectionUtils.collect(options.getExcludeCategories(), transformer)
        ));
    }

    if (!options.getIncludedTests().isEmpty()) {
        request = request.filterWith(new MethodNameFilter(options.getIncludedTests()));
    }

    Runner runner = request.getRunner();
    //In case of no matching methods junit will return a ErrorReportingRunner for org.junit.runner.manipulation.Filter.class.
    //Will be fixed with adding class filters
    if (!org.junit.runner.manipulation.Filter.class.getName().equals(runner.getDescription().getDisplayName())) {
        RunNotifier notifier = new RunNotifier();
        notifier.addListener(listener);
        runner.run(notifier);
    }
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:33,代码来源:JUnitTestClassExecuter.java

示例7: runAnnotatedTestClass

import org.junit.runner.Runner; //导入方法依赖的package包/类
private void runAnnotatedTestClass(Class<?> testClass, RunWith runWith)
    throws Exception {
Class<? extends Runner> runnerClass = runWith.value();
Constructor<? extends Runner> constructor = runnerClass
	.getConstructor(Class.class);
Runner runner = constructor.newInstance(testClass);
RunNotifier notifier = new RunNotifier();
notifier.addListener(new MyListener());
runner.run(notifier);
   }
 
开发者ID:lucaspouzac,项目名称:contiperf,代码行数:11,代码来源:AbstractContiPerfTest.java

示例8: testSingleClass

import org.junit.runner.Runner; //导入方法依赖的package包/类
public static XSPResult testSingleClass(Class<?> testClass) {
	ConsoleLogRecorder recorder = new ConsoleLogRecorder();

	recorder.startRecording();
	XSPResult xspResult = new XSPResult();
	Request request = Request.aClass(testClass);
	Result result = new Result();
	RunNotifier runNotifier = buildRunNotifier(xspResult, result);
	Runner testRunner = request.getRunner();
	testRunner.run(runNotifier);
	recorder.stopRecordingAndResetSystem();

	xspResult.applyResult(result, recorder);
	return xspResult;
}
 
开发者ID:OpenNTF,项目名称:BuildAndTestPattern4Xpages,代码行数:16,代码来源:XSPTestRunner.java

示例9: testWithRequestFromClassAndSimpleResultObject

import org.junit.runner.Runner; //导入方法依赖的package包/类
@Test
public void testWithRequestFromClassAndSimpleResultObject() {
	Request request = Request.aClass(TestMock.class);
	Result result = new Result();
	Runner testRunner = request.getRunner();
	RunNotifier runNotifier = new RunNotifier();
	runNotifier.addListener(result.createListener());
	testRunner.run(runNotifier);
	assertEquals(3, result.getRunCount());
	assertEquals(2, result.getFailureCount());
	assertEquals(1, result.getIgnoreCount());
}
 
开发者ID:OpenNTF,项目名称:BuildAndTestPattern4Xpages,代码行数:13,代码来源:JUnitAPITest.java

示例10: runChild

import org.junit.runner.Runner; //导入方法依赖的package包/类
@Override
protected void runChild(Runner child, RunNotifier notifier) {
	EchoingListener el = new EchoingListener((LogFileTestRunner)child);
	try {
		notifier.addListener(el);
		child.run(notifier);
	} finally {
		notifier.removeListener(el);
	}
}
 
开发者ID:Tesora,项目名称:tesora-dve-pub,代码行数:11,代码来源:LogFileSuiteRunner.java

示例11: run

import org.junit.runner.Runner; //导入方法依赖的package包/类
@Override
public void run(RunNotifier notifier) {
  classRunner.run(notifier);

  for (Runner childRunner : childRunners) {
    childRunner.run(notifier);
  }
}
 
开发者ID:joshng,项目名称:papaya,代码行数:9,代码来源:Nested.java

示例12: runChild

import org.junit.runner.Runner; //导入方法依赖的package包/类
@Override
protected void runChild(final Runner runner, final RunNotifier notifier) {
	runner.run(notifier);
}
 
开发者ID:xtf-cz,项目名称:xtf,代码行数:5,代码来源:XTFTestSuite.java

示例13: runChild

import org.junit.runner.Runner; //导入方法依赖的package包/类
@Override
protected void runChild(Runner runner, final RunNotifier notifier) {
    runner.run(notifier);
}
 
开发者ID:easymall,项目名称:easy-test,代码行数:5,代码来源:EasySuite.java

示例14: runChild

import org.junit.runner.Runner; //导入方法依赖的package包/类
protected void runChild(Runner runner, RunNotifier notifier) {
    runner.run(notifier);
}
 
开发者ID:PeterWippermann,项目名称:parameterized-suite,代码行数:4,代码来源:ParameterizedSuite.java

示例15: runChild

import org.junit.runner.Runner; //导入方法依赖的package包/类
@Override
protected void runChild(Runner runner, RunNotifier notifier) {
    notifier.addListener(listener);
    runner.run(notifier);
    notifier.removeListener(listener);
}
 
开发者ID:jprante,项目名称:elasticsearch-client-http,代码行数:7,代码来源:ListenerSuite.java


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