本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
}
示例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();
}
}
示例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());
}
示例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"));
}
示例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();
}
}
示例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 );
}
}
示例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());
}
}
};
}
示例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);
}
}
示例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);
}
}
示例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();
}