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


Java Failure类代码示例

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


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

示例1: testFailure

import org.junit.runner.notification.Failure; //导入依赖的package包/类
@Override
public void testFailure(Failure failure) throws Exception {
    TestDescriptorInternal testInternal;
    synchronized (lock) {
        testInternal = executing.get(failure.getDescription());
    }
    boolean needEndEvent = false;
    if (testInternal == null) {
        // This can happen when, for example, a @BeforeClass or @AfterClass method fails
        needEndEvent = true;
        testInternal = nullSafeDescriptor(idGenerator.generateId(), failure.getDescription());
        resultProcessor.started(testInternal, startEvent());
    }
    resultProcessor.failure(testInternal.getId(), failure.getException());
    if (needEndEvent) {
        resultProcessor.completed(testInternal.getId(), new TestCompleteEvent(timeProvider.getCurrentTime()));
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:JUnitTestEventAdapter.java

示例2: testFailure

import org.junit.runner.notification.Failure; //导入依赖的package包/类
/**
 * Called when an atomic test fails.
 *
 * @param failure
 *            describes the test that failed and the exception that was thrown
 */
@Override
public void testFailure(Failure failure) throws Exception {
	Display.getDefault().syncExec(new Runnable() {
		@Override
		public void run() {

			IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
			try {
				N4IDEXpectView view = (N4IDEXpectView) windows[0].getActivePage().showView(
						N4IDEXpectView.ID);
				view.notifyFailedExecutionOf(failure);
			} catch (PartInitException e) {
				N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
			}
		}
	});
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:24,代码来源:N4IDEXpectRunListener.java

示例3: testAssumptionFailure

import org.junit.runner.notification.Failure; //导入依赖的package包/类
/**
 * Called when an atomic test flags that it assumes a condition that is false
 *
 * describes the test that failed and the {@link AssumptionViolatedException} that was thrown
 */
@Override
public void testAssumptionFailure(Failure failure) {
	Display.getDefault().syncExec(new Runnable() {
		@Override
		public void run() {

			IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
			try {
				N4IDEXpectView view = (N4IDEXpectView) windows[0].getActivePage().showView(
						N4IDEXpectView.ID);
				view.notifyFailedExecutionOf(failure);
			} catch (PartInitException e) {
				N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
			}
		}
	});
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:23,代码来源:N4IDEXpectRunListener.java

示例4: endTest

import org.junit.runner.notification.Failure; //导入依赖的package包/类
@Override public void endTest(final PlaybackResult result) {
    if (!exploratoryTest) {
        Platform.runLater(new Runnable() {
            @Override public void run() {
                resultPane.addResult(result);
            }
        });
    }
    if (!needReports()) {
        return;
    }
    if (!exploratoryTest && result.hasFailure()) {
        MarathonAssertion assertion = new MarathonAssertion(result.failures(), getFilePath());
        runListener.testAssumptionFailure(
                new Failure(Description.createTestDescription(MarathonTestCase.class, getFilePath()), assertion));
    }
    TestAttributes.put("test_object", testCase);
    runListener.testFinished(Description.createTestDescription(MarathonTestCase.class, getFilePath()));
    addScreenCaptures();
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:21,代码来源:DisplayWindow.java

示例5: testThreadDumpAndDeadlocks

import org.junit.runner.notification.Failure; //导入依赖的package包/类
@Test(timeout=30000)
public void testThreadDumpAndDeadlocks() throws Exception {
  new Deadlock();
  String s = null;
  while (true) {
    s = TimedOutTestsListener.buildDeadlockInfo();
    if (s != null)
      break;
    Thread.sleep(100);
  }
  
  Assert.assertEquals(3, countStringOccurrences(s, "BLOCKED"));
  
  Failure failure = new Failure(
      null, new Exception(TimedOutTestsListener.TEST_TIMED_OUT_PREFIX));
  StringWriter writer = new StringWriter();
  new TimedOutTestsListener(new PrintWriter(writer)).testFailure(failure);
  String out = writer.toString();
  
  Assert.assertTrue(out.contains("THREAD DUMP"));
  Assert.assertTrue(out.contains("DEADLOCKS DETECTED"));
  
  System.out.println(out);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:25,代码来源:TestTimedOutTestsListener.java

示例6: testFailure

import org.junit.runner.notification.Failure; //导入依赖的package包/类
@Override
public void testFailure(Failure failure) throws Exception {
    // Ignore assumptions.
    if (failure.getException() instanceof AssumptionViolatedException) {
        return;
    }

    final StringBuilder b = new StringBuilder("REPRODUCE WITH: gradle ");
    String task = System.getProperty("tests.task");
    // TODO: enforce (intellij still runs the runner?) or use default "test" but that won't work for integ
    b.append(task);

    GradleMessageBuilder gradleMessageBuilder = new GradleMessageBuilder(b);
    gradleMessageBuilder.appendAllOpts(failure.getDescription());

    // Client yaml suite tests are a special case as they allow for additional parameters
    if (ESClientYamlSuiteTestCase.class.isAssignableFrom(failure.getDescription().getTestClass())) {
        gradleMessageBuilder.appendClientYamlSuiteProperties();
    }

    System.err.println(b.toString());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:ReproduceInfoPrinter.java

示例7: testAssumptionFailure

import org.junit.runner.notification.Failure; //导入依赖的package包/类
/**
 * (non-Javadoc)
 * @see org.junit.runner.notification.RunListener#testAssumptionFailure(org.junit.runner.notification.Failure)
 */
@Override
public void testAssumptionFailure( Failure failure ) {

    if (log.isDebugEnabled()) {
        log.debug("testAssumptionFailure(): Test failed: " + failure.toString() + "| Description: "
                  + failure.getDescription());
    }
    log.info("Test assumption failure received. It will be stored in DB as test failed event.");
    try {
        testFailure(failure);
    } catch (Exception e) {
        log.error("Error while processing testFailure event", e);
    }
    super.testAssumptionFailure(failure);
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:20,代码来源:AtsJunitTestListener.java

示例8: main

import org.junit.runner.notification.Failure; //导入依赖的package包/类
public static void main(String[] args) {
  final Result result =
      JUnitCore.runClasses(
          codeu.chat.common.SecretTest.class,
          codeu.chat.relay.ServerTest.class,
          codeu.chat.server.BasicControllerTest.class,
          codeu.chat.server.RawControllerTest.class,
          codeu.chat.util.TimeTest.class,
          codeu.chat.util.TokenizerTest.class,
          codeu.chat.util.UuidTest.class,
          codeu.chat.util.store.StoreTest.class
      );
   for (final Failure failure : result.getFailures()) {
      System.out.println(failure.toString());
   }
   System.out.println(result.wasSuccessful());
}
 
开发者ID:Pandarati,项目名称:CodeU-Summer-2017,代码行数:18,代码来源:TestRunner.java

示例9: isKnownIssue

import org.junit.runner.notification.Failure; //导入依赖的package包/类
private boolean isKnownIssue(Failure failure) {

		if (failure == null) {
			return false;
		}

		if (failure.getDescription() == null) {
			return false;
		}

		final KnownIssue knownIssue = failure.getDescription().getAnnotation(KnownIssue.class);
		final String message = failure.getMessage();

		if (knownIssue == null || message == null || knownIssue.value() == null) {
			return false;
		}

		if (message.contains(knownIssue.value())) {
			return true;
		}

		return false;
	}
 
开发者ID:xtf-cz,项目名称:xtf,代码行数:24,代码来源:IntermediateReporter.java

示例10: runChild

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

示例11: runTestSuiteAgainst

import org.junit.runner.notification.Failure; //导入依赖的package包/类
/**
 * Creates and runs a JUnit test runner for testSuite.
 *
 * @param testSuite the class defining test cases to run
 * @param view a UI component to report test failures to
 * @return the counts of failures and total test cases.
 */
static RunResult runTestSuiteAgainst(Class testSuite, View view)
{
    if(testSuite == null)
        throw new NullPointerException("testSuite");

    if(view == null)
        throw new NullPointerException("view");

    Result result = new JUnitCore().run(testSuite);

    if (result.getFailureCount() > 0)
    {
        for (Failure f : result.getFailures())
            view.declarePassProgramTestFailure(f.getTrace());
    }


    return new RunResult(result.getFailureCount(), result.getRunCount());
}
 
开发者ID:capergroup,项目名称:bayou,代码行数:27,代码来源:TestSuiteRunner.java

示例12: failsWithExpectedTimeoutButWrongError

import org.junit.runner.notification.Failure; //导入依赖的package包/类
@Test
public void failsWithExpectedTimeoutButWrongError() {
  Result result = TestRunner.runTest(FailsWithExpectedTimeoutButWrongError.class);

  assertThat(result.wasSuccessful()).isFalse();

  List<Failure> failures = result.getFailures();
  assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);

  Failure failure = failures.get(0);
  String expectedMessage = "\n"
      + "Expected: (an instance of java.util.concurrent.TimeoutException and exception with message a string containing \"this is a message for FailsWithExpectedTimeoutButWrongError\")"
      + "\n" + "     "
      + "but: an instance of java.util.concurrent.TimeoutException <java.lang.NullPointerException> is a java.lang.NullPointerException";
  assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class)
      .hasMessageContaining(expectedMessage);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:18,代码来源:ExpectedTimeoutRuleTest.java

示例13: testThreadDumpAndDeadlocks

import org.junit.runner.notification.Failure; //导入依赖的package包/类
@Test(timeout=500)
public void testThreadDumpAndDeadlocks() throws Exception {
  new Deadlock();
  String s = null;
  while (true) {
    s = TimedOutTestsListener.buildDeadlockInfo();
    if (s != null)
      break;
    Thread.sleep(100);
  }
  
  Assert.assertEquals(3, countStringOccurrences(s, "BLOCKED"));
  
  Failure failure = new Failure(
      null, new Exception(TimedOutTestsListener.TEST_TIMED_OUT_PREFIX));
  StringWriter writer = new StringWriter();
  new TimedOutTestsListener(new PrintWriter(writer)).testFailure(failure);
  String out = writer.toString();
  
  Assert.assertTrue(out.contains("THREAD DUMP"));
  Assert.assertTrue(out.contains("DEADLOCKS DETECTED"));
  
  System.out.println(out);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestTimedOutTestsListener.java

示例14: main

import org.junit.runner.notification.Failure; //导入依赖的package包/类
public static void main(String[] args) {
  final Result result =
      JUnitCore.runClasses(
          codeu.chat.common.SecretTest.class,
          codeu.chat.relay.ServerTest.class,
          codeu.chat.server.BasicControllerTest.class,
          codeu.chat.server.RawControllerTest.class,
          codeu.chat.util.TimeTest.class,
          codeu.chat.util.UuidTest.class,
          codeu.chat.util.store.StoreTest.class
      );
   for (final Failure failure : result.getFailures()) {
      System.out.println(failure.toString());
   }
   System.out.println(result.wasSuccessful());
}
 
开发者ID:google,项目名称:codeu_project_2017,代码行数:17,代码来源:TestRunner.java

示例15: createListener

import org.junit.runner.notification.Failure; //导入依赖的package包/类
private static JUnit4TestListener createListener(final StringBuffer buf) {
  return new JUnit4TestListener(new PrintStream(new OutputStream() {
    @Override
    public void write(int b) throws IOException {
      buf.append(new String(new byte[]{(byte)b}));
    }
  })) {
    @Override
    protected long currentTime() {
      return 0;
    }

    @Override
    protected String getTrace(Failure failure) {
      return StringUtil.convertLineSeparators(super.getTrace(failure));
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:JUnitTreeByDescriptionHierarchyTest.java


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