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


Java RunNotifier类代码示例

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


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

示例1: run

import org.junit.runner.notification.RunNotifier; //导入依赖的package包/类
final void run(final RunNotifier notifier) {
    RunNotifier nested = new RunNotifier();
    NestedRunListener nestedListener = new NestedRunListener(notifier);
    nested.addListener(nestedListener);

    try {
        runEnabledTests(nested);
    } finally {
        nestedListener.cleanup();
    }

    for (Description disabledTest : disabledTests) {
        nested.fireTestStarted(disabledTest);
        nested.fireTestIgnored(disabledTest);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:AbstractMultiTestRunner.java

示例2: runChild

import org.junit.runner.notification.RunNotifier; //导入依赖的package包/类
@Override
protected void runChild(Spec spec, RunNotifier notifier) {
	List<Spec> specs = spec.getSuite().getSpecs();
	boolean suiteHasNoSpecs = specs.isEmpty();
	boolean isFirstSpec = specs.indexOf(spec) == 0;
	boolean isLastSpec = specs.indexOf(spec) == specs.size() -1;

	if (suiteHasNoSpecs || isFirstSpec){
		runBeforeCallbacks(spec);
	}

	if (spec.getBlock().isPresent()) {
		runBeforeEachCallbacks(spec);
		runLeaf(spec, describeChild(spec), notifier);
		runAfterEachCallbacks(spec);
	} else {
		notifier.fireTestIgnored(describeChild(spec));
	}


	if (suiteHasNoSpecs || isLastSpec){
		runAfterCallbacks(spec);
	}
}
 
开发者ID:bangarharshit,项目名称:Oleaster,代码行数:25,代码来源:OleasterRunner.java

示例3: runChild

import org.junit.runner.notification.RunNotifier; //导入依赖的package包/类
@Override
protected void runChild(final ArchTestExecution child, final RunNotifier notifier) {
    ExpectedViolation expectedViolation = ExpectedViolation.none();
    HandlingAssertion handlingAssertion = HandlingAssertion.none();
    Description description = describeChild(child);
    notifier.fireTestStarted(description);
    try {
        ExpectedViolationDefinition violationDefinition = extractExpectedConfiguration(child);
        violationDefinition.configure(expectedViolation);
        violationDefinition.configure(handlingAssertion);
        expectedViolation.apply(new IntegrationTestStatement(child, handlingAssertion), description).evaluate();
    } catch (Throwable throwable) {
        notifier.fireTestFailure(new Failure(description, throwable));
    } finally {
        notifier.fireTestFinished(description);
    }
}
 
开发者ID:TNG,项目名称:ArchUnit,代码行数:18,代码来源:ArchUnitIntegrationTestRunner.java

示例4: run

import org.junit.runner.notification.RunNotifier; //导入依赖的package包/类
@Override
public void run(RunNotifier notifier) {
    final CourgetteRunner courgetteRunner = new CourgetteRunner(runnerInfoList, courgetteProperties);

    if (courgetteRunner.canRunFeatures()) {
        courgetteRunner.run();
        courgetteRunner.createReport();
        courgetteRunner.createCourgetteReport();
    }

    if (courgetteRunner.allFeaturesPassed()) {
        System.exit(0x0);
    } else {
        courgetteRunner.createRerunFile();
        System.exit(0x1);
    }
}
 
开发者ID:prashant-ramcharan,项目名称:courgette-jvm,代码行数:18,代码来源:Courgette.java

示例5: run

import org.junit.runner.notification.RunNotifier; //导入依赖的package包/类
@Override
public void run(final RunNotifier notifier) {
	try {
		final File initialTempDir = FileUtil.getInitialTempDir();
		final File rootTestDir = STROOMTestUtil.createRootTestDir(initialTempDir);
		final File testDir = STROOMTestUtil.createTestDir(rootTestDir);

		/* Redirect the temp dir for the tests. */
		StroomProperties.setOverrideProperty(StroomProperties.STROOM_TEMP, testDir.getCanonicalPath(), "test");

		FileUtil.forgetTempDir();

		printTemp();
		super.run(notifier);
		printTemp();

		FileUtil.forceDelete(testDir);

		FileUtil.forgetTempDir();
		StroomProperties.removeOverrides();
	} catch (final Exception e) {
		throw new RuntimeException(e.getMessage(), e);
	}
}
 
开发者ID:gchq,项目名称:stroom-agent,代码行数:25,代码来源:StroomJUnit4ClassRunner.java

示例6: runChildren

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

示例7: runChild

import org.junit.runner.notification.RunNotifier; //导入依赖的package包/类
@Override
protected void runChild(FeatureRunner featureRunner, RunNotifier notifier)
{

    TestControl testControl = getTestClass().getJavaClass().getAnnotation(TestControl.class);

    ContainerAwareTestContext currentTestContext =
            new ContainerAwareTestContext(testControl, this.testContext);

    currentTestContext.applyBeforeFeatureConfig(getTestClass().getJavaClass());
    try
    {
        super.runChild(featureRunner, notifier);
    }
    finally
    {
        currentTestContext.applyAfterFeatureConfig();
    }
}
 
开发者ID:database-rider,项目名称:database-rider,代码行数:20,代码来源:CdiCucumberTestRunner.java

示例8: runTestsAndAssertCounters

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

示例9: shouldValidateUnsuccessfullyForInjectMocksPresence

import org.junit.runner.notification.RunNotifier; //导入依赖的package包/类
@Test
public void shouldValidateUnsuccessfullyForInjectMocksPresence() throws Exception {
    // given
    RunNotifier notifier = mock(RunNotifier.class);
    TestClass testClass = new TestClass(getClass());
    DelayedInjectionRunnerValidator validator = new DelayedInjectionRunnerValidator(notifier, testClass);
    Description description = mock(Description.class);

    // when
    validator.testFinished(description);

    // then
    ArgumentCaptor<Failure> captor = ArgumentCaptor.forClass(Failure.class);
    verify(notifier).fireTestFailure(captor.capture());
    Failure failure = captor.getValue();
    assertThat(failure.getMessage(), containsString("Do not use @InjectMocks"));
}
 
开发者ID:ljacqu,项目名称:DependencyInjector,代码行数:18,代码来源:DelayedInjectionRunnerValidatorTest.java

示例10: runChild

import org.junit.runner.notification.RunNotifier; //导入依赖的package包/类
@Override
protected void runChild(FrameworkMethod method, RunNotifier notifier)
{
  try {
    _baratine = new BaratineContainer();

    _baratine.boot(true);

    super.runChild(method, notifier);
  } catch (RuntimeException e) {
    throw e;
  } catch (Throwable t) {
    throw new RuntimeException(t);
  } finally {
    _baratine.stop();
  }
}
 
开发者ID:baratine,项目名称:baratine,代码行数:18,代码来源:RunnerBaratine.java

示例11: runChild

import org.junit.runner.notification.RunNotifier; //导入依赖的package包/类
@Override
protected void runChild( final FrameworkMethod method, RunNotifier notifier )
{
    Description description = describeChild( method );
    if ( method.getAnnotation( Ignore.class ) != null )
    {
        notifier.fireTestIgnored( description );
    }
    else
    {
        if ( method.getAnnotation( Repeat.class ) != null && method.getAnnotation( Ignore.class ) == null )
        {
            retryCount = method.getAnnotation( Repeat.class ).retryCount();
            sleepTime = method.getAnnotation( Repeat.class ).sleepTime();
        }
        runTestUnit( methodBlock( method ), description, notifier );
    }
}
 
开发者ID:vmware,项目名称:OHMS,代码行数:19,代码来源:RetryRunner.java

示例12: prepareMethodBlock

import org.junit.runner.notification.RunNotifier; //导入依赖的package包/类
protected Statement prepareMethodBlock(final FrameworkMethod method, final RunNotifier notifier) {
	final Statement methodBlock = superMethodBlock(method);
	return new Statement() {
		@Override
		public void evaluate() throws Throwable {
			try {
				methodBlock.evaluate();
				Description description = describeChild(method);
				try {
					notifier.fireTestStarted(description);
					notifier.fireTestAssumptionFailed(new Failure(description, new AssumptionViolatedException("Method " + method.getName() + " did parse any input")));
				} finally {
					notifier.fireTestFinished(description);
				}
			} catch(TestDataCarrier testData) {
				AbstractParallelScenarioRunner.this.testData.put(method, testData.getData());
			}
		}
	};
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:21,代码来源:AbstractParallelScenarioRunner.java

示例13: runChild

import org.junit.runner.notification.RunNotifier; //导入依赖的package包/类
@Override
protected void runChild(FrameworkMethod method, RunNotifier notifier) {
  Description description = describeChild(method);

  // check Ignore first
  if (method.getAnnotation(Ignore.class) != null) {
    notify("@Ignore", description);
    notifier.fireTestIgnored(description);

  } else if (localTestsEnabled && method.getAnnotation(RemoteOnly.class) != null) {

    // if running in local mode and @RemoteOnly annotation exists, ignore
    notify("Skip @RemoteOnly", description);
    notifier.fireTestIgnored(description);
  } else if (remoteTestsEnabled && method.getAnnotation(LocalOnly.class) != null) {

    // if running in remote mode and @LocalOnly annotation exists, ignore
    notify("Skip @LocalOnly", description);
    notifier.fireTestIgnored(description);
  } else {
    // default is run in either mode
    notify("Test[" + mode + "]", description);
    super.runChild(method, notifier);
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:jetty-runtime,代码行数:26,代码来源:LocalRemoteTestRunner.java

示例14: run

import org.junit.runner.notification.RunNotifier; //导入依赖的package包/类
@Override
public void run(final RunNotifier rn) {
    System.out.println("Run is called!");
    if (isMainThread() && runOtherThread()) {
        if (Utils.isMacOS()) {
            SwingAWTUtils.getDefaultToolkit(); // OS X workaround
        }
        runnerThread = new Thread(new Runnable() {
            @Override
            public void run() {
                OtherThreadRunner.super.run(rn);
                putPoison();
            }
        });
        runnerThread.start();
        executeTasks();
    } else {
        super.run(rn);
    }
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:21,代码来源:OtherThreadRunner.java

示例15: runChild

import org.junit.runner.notification.RunNotifier; //导入依赖的package包/类
@Override
protected void runChild(final FrameworkMethod method, final RunNotifier notifier) {
    try {
        try {
            ThreadScopeContextHolder.createContext();

            final LogExecutionTime logExecutionTime = new LogExecutionTime();
            try {
                runChildBefore(this, method, notifier);
                super.runChild(method, notifier);

            } finally {
                runChildAfter(this, method, notifier, logExecutionTime);
            }

        } finally {
            ThreadScopeContextHolder.destroyContext();
        }
    } catch (final Exception e) {
        throw new RuntimeException(e.getMessage(), e);
    }

    ExternalShutdownController.shutdown();
}
 
开发者ID:gchq,项目名称:stroom-proxy,代码行数:25,代码来源:StroomJUnit4ClassRunner.java


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