當前位置: 首頁>>代碼示例>>Java>>正文


Java MultipleFailureException類代碼示例

本文整理匯總了Java中org.junit.runners.model.MultipleFailureException的典型用法代碼示例。如果您正苦於以下問題:Java MultipleFailureException類的具體用法?Java MultipleFailureException怎麽用?Java MultipleFailureException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MultipleFailureException類屬於org.junit.runners.model包,在下文中一共展示了MultipleFailureException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: cleanUp

import org.junit.runners.model.MultipleFailureException; //導入依賴的package包/類
private Throwable cleanUp(Throwable testfailure) {
    try {
        after();
        return testfailure;
    } catch (Throwable afterFailure) {
        if (testfailure == null) {
            // Only after() threw an exception
            return afterFailure;
        }

        // Both TestHelper.awaitOrFail() and after() threw exceptions
        return new MultipleFailureException(Arrays.asList(testfailure, afterFailure)) {
            @Override
            public void printStackTrace(PrintStream out) {
                int i = 0;
                for (Throwable t : getFailures()) {
                    out.println("Error " + i + ": " + t.getMessage());
                    t.printStackTrace(out);
                    out.println();
                    i++;
                }
            }
        };
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:26,代碼來源:RunInLooperThread.java

示例2: statement

import org.junit.runners.model.MultipleFailureException; //導入依賴的package包/類
private Statement statement(final Statement base, final Description description) {

        return new Statement() {
            public void evaluate() throws Throwable {
                before(description);
                try {
                    List<Throwable> errors = new ArrayList<>();

                    try {
                        base.evaluate();
                        succeededQuietly(description, errors);
                    } catch (Throwable e) {
                        errors.add(e);
                        failedQuietly(e, description, errors);
                    }
                    MultipleFailureException.assertEmpty(errors);
                } finally {
                    after();
                }
            }
        };
    }
 
開發者ID:arquillian,項目名稱:smart-testing,代碼行數:23,代碼來源:TestBed.java

示例3: apply

import org.junit.runners.model.MultipleFailureException; //導入依賴的package包/類
@Override
public Statement apply(Statement base, Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            final List<Throwable> errors = new ArrayList<>();

            starting();

            try {
                base.evaluate();
            } catch (Throwable e) {
                errors.add(e);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
 
開發者ID:apiman,項目名稱:apiman-cli,代碼行數:20,代碼來源:WaitForHttp.java

示例4: apply

import org.junit.runners.model.MultipleFailureException; //導入依賴的package包/類
/**
 * Implementation based on {@link TestWatcher}.
 */
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
 
開發者ID:flowable,項目名稱:flowable-engine,代碼行數:29,代碼來源:FlowableDmnRule.java

示例5: apply

import org.junit.runners.model.MultipleFailureException; //導入依賴的package包/類
/**
 * Implementation based on {@link TestWatcher}.
 */
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
 
開發者ID:flowable,項目名稱:flowable-engine,代碼行數:27,代碼來源:FlowableIdmRule.java

示例6: apply

import org.junit.runners.model.MultipleFailureException; //導入依賴的package包/類
/**
 * Implementation based on {@link TestWatcher}.
 */
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<Throwable>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
 
開發者ID:flowable,項目名稱:flowable-engine,代碼行數:29,代碼來源:ActivitiRule.java

示例7: apply

import org.junit.runners.model.MultipleFailureException; //導入依賴的package包/類
@Override
public Statement apply(Statement base, Description description) {

    return new Statement() {
        @Override
        public void evaluate() throws Throwable {

            List<Throwable> errors = new ArrayList<Throwable>();

            try {
                starting(description);
                base.evaluate();
                succeeded(description);
            } catch (Throwable e) {
                errors.add(e);
                failed(e, description);
            } finally {
                finished(description);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
 
開發者ID:testcontainers,項目名稱:testcontainers-java,代碼行數:25,代碼來源:FailureDetectingExternalResource.java

示例8: apply

import org.junit.runners.model.MultipleFailureException; //導入依賴的package包/類
@Override
public Statement apply(final Statement base, final Description description, final Object[] params) {
	return new Statement() {
		public void evaluate() throws Throwable {
			ArrayList<Throwable> errors = new ArrayList<Throwable>();
			ParameterizedTestWatcher.this.startingQuietly(description, errors, params);

			try {
				base.evaluate();
				ParameterizedTestWatcher.this.succeededQuietly(description, errors, params);
			} catch (AssumptionViolatedException var7) {
				errors.add(var7);
				ParameterizedTestWatcher.this.skippedQuietly(var7, description, errors, params);
			} catch (Throwable var8) {
				errors.add(var8);
				ParameterizedTestWatcher.this.failedQuietly(var8, description, errors, params);
			} finally {
				ParameterizedTestWatcher.this.finishedQuietly(description, errors, params);
			}

			MultipleFailureException.assertEmpty(errors);
		}
	};
}
 
開發者ID:hifive,項目名稱:hifive-pitalium,代碼行數:25,代碼來源:ParameterizedTestWatcher.java

示例9: createTimeoutException

import org.junit.runners.model.MultipleFailureException; //導入依賴的package包/類
private Exception createTimeoutException(Thread thread) {
    StackTraceElement[] stackTrace = thread.getStackTrace();
    final Thread stuckThread = fLookForStuckThread ? getStuckThread(thread) : null;
    Exception currThreadException = new TestTimedOutException(fTimeout, fTimeUnit);
    if (stackTrace != null) {
        currThreadException.setStackTrace(stackTrace);
        thread.interrupt();
    }
    if (stuckThread != null) {
        Exception stuckThreadException = 
            new Exception ("Appears to be stuck in thread " +
                           stuckThread.getName());
        stuckThreadException.setStackTrace(getStackTrace(stuckThread));
        return new MultipleFailureException    
            (Arrays.<Throwable>asList(currThreadException, stuckThreadException));
    } else {
        return currThreadException;
    }
}
 
開發者ID:DIVERSIFY-project,項目名稱:sosiefier,代碼行數:20,代碼來源:FailOnTimeout.java

示例10: assertEmptyThrowsMutipleFailureExceptionForManyThrowables

import org.junit.runners.model.MultipleFailureException; //導入依賴的package包/類
@Test
public void assertEmptyThrowsMutipleFailureExceptionForManyThrowables() throws Exception {
    List<Throwable> errors = new ArrayList<Throwable>();
    errors.add(new ExpectedException("basil"));
    errors.add(new RuntimeException("garlic"));

    try {
        MultipleFailureException.assertEmpty(errors);
        fail();
    } catch (MultipleFailureException expected) {
        assertThat(expected.getFailures(), equalTo(errors));
        assertTrue(expected.getMessage().startsWith("There were 2 errors:\n"));
        assertTrue(expected.getMessage().contains("ExpectedException(basil)\n"));
        assertTrue(expected.getMessage().contains("RuntimeException(garlic)"));
    }
}
 
開發者ID:DIVERSIFY-project,項目名稱:sosiefier,代碼行數:17,代碼來源:MultipleFailureExceptionTest.java

示例11: apply

import org.junit.runners.model.MultipleFailureException; //導入依賴的package包/類
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<Throwable>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
 
開發者ID:lcm-proj,項目名稱:lcm,代碼行數:25,代碼來源:TestWatcher.java

示例12: setUp

import org.junit.runners.model.MultipleFailureException; //導入依賴的package包/類
@Before
public void setUp() throws Throwable {
    assumeTrue("Test disabled", test.isEnabled());

    realm.initialize(new NullConsole(), test);
    realm.get().createGlobalProperties(new Print(), Print.class);
    exceptionHandler.setExecutionContext(realm.get().defaultContext());

    // Apply scripted conditions
    scriptConditions();

    // Filter disabled tests (may have changed after applying scripted conditions)
    assumeTrue("Test disabled", test.isEnabled());

    if (test.negative) {
        expected.expect(
                Matchers.either(StandardErrorHandler.defaultMatcher()).or(ScriptExceptionHandler.defaultMatcher())
                        .or(Matchers.instanceOf(MultipleFailureException.class)));
    } else {
        errorHandler.match(StandardErrorHandler.defaultMatcher());
        exceptionHandler.match(ScriptExceptionHandler.defaultMatcher());
    }
}
 
開發者ID:anba,項目名稱:es6draft,代碼行數:24,代碼來源:MozillaJSTest.java

示例13: setUp

import org.junit.runners.model.MultipleFailureException; //導入依賴的package包/類
@Before
public void setUp() throws Throwable {
    assumeTrue("Test disabled", test.isEnabled());

    realm.initialize(new NullConsole(), test);
    realm.get().createGlobalProperties(new Print(), Print.class);
    exceptionHandler.setExecutionContext(realm.get().defaultContext());

    if (test.negative) {
        expected.expect(
                Matchers.either(StandardErrorHandler.defaultMatcher()).or(ScriptExceptionHandler.defaultMatcher())
                        .or(Matchers.instanceOf(MultipleFailureException.class)));
    } else {
        errorHandler.match(StandardErrorHandler.defaultMatcher());
        exceptionHandler.match(ScriptExceptionHandler.defaultMatcher());
    }
}
 
開發者ID:anba,項目名稱:es6draft,代碼行數:18,代碼來源:WebKitTest.java

示例14: should_report_all_errors

import org.junit.runners.model.MultipleFailureException; //導入依賴的package包/類
@Test
public void should_report_all_errors() throws Throwable {
  try {
    softly.assertThat(1).isEqualTo(1);
    softly.assertThat(1).isEqualTo(2);
    softly.assertThat(Lists.newArrayList(1, 2)).containsOnly(1, 3);
    MultipleFailureException.assertEmpty(softly.errorsCollected());
    fail("Should not reach here");
  } catch (MultipleFailureException e) {
    List<Throwable> failures = e.getFailures();

    assertThat(failures).hasSize(2);
    assertThat(failures.get(0).getMessage()).startsWith("expected:<[2]> but was:<[1]>");
    assertThat(failures.get(1).getMessage()).startsWith(format("%n" +
                                                               "Expecting:%n" +
                                                               "  <[1, 2]>%n" +
                                                               "to contain only:%n" +
                                                               "  <[1, 3]>%n" +
                                                               "elements not found:%n" +
                                                               "  <[3]>%n" +
                                                               "and elements not expected:%n" +
                                                               "  <[2]>%n"));
  }
}
 
開發者ID:joel-costigliola,項目名稱:assertj-core,代碼行數:25,代碼來源:JUnitSoftAssertionsFailureTest.java

示例15: should_report_all_errors

import org.junit.runners.model.MultipleFailureException; //導入依賴的package包/類
@Test
public void should_report_all_errors() throws Throwable {
  try {
    softly.then(1).isEqualTo(1);
    softly.then(1).isEqualTo(2);
    softly.then(Lists.newArrayList(1, 2)).containsOnly(1, 3);
    MultipleFailureException.assertEmpty(softly.getErrors());
    fail("Should not reach here");
  } catch (MultipleFailureException e) {
    List<Throwable> failures = e.getFailures();
    assertThat(failures).hasSize(2)
                        .extracting("message")
                        .contains("expected:<[2]> but was:<[1]>",
                                  format("%n" +
                                         "Expecting:%n" +
                                         "  <[1, 2]>%n" +
                                         "to contain only:%n" +
                                         "  <[1, 3]>%n" +
                                         "elements not found:%n" +
                                         "  <[3]>%n" +
                                         "and elements not expected:%n" +
                                         "  <[2]>%n"));
  }
}
 
開發者ID:joel-costigliola,項目名稱:assertj-core,代碼行數:25,代碼來源:JUnitBDDSoftAssertionsFailureTest.java


注:本文中的org.junit.runners.model.MultipleFailureException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。