Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
JUnit 4.13.2 Source Code Files
JUnit Source Code Files are provided in the source package file, junit-4.13.2-sources.jar.
You can browse JUnit Source Code files below:
✍: FYIcenter.com
⏎ org/junit/rules/ErrorCollector.java
package org.junit.rules; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThrows; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Callable; import org.junit.function.ThrowingRunnable; import org.junit.internal.AssumptionViolatedException; import org.hamcrest.Matcher; import org.junit.runners.model.MultipleFailureException; /** * The ErrorCollector rule allows execution of a test to continue after the * first problem is found (for example, to collect _all_ the incorrect rows in a * table, and report them all at once): * * <pre> * public static class UsesErrorCollectorTwice { * @Rule * public ErrorCollector collector= new ErrorCollector(); * * @Test * public void example() { * collector.addError(new Throwable("first thing went wrong")); * collector.addError(new Throwable("second thing went wrong")); * collector.checkThat(getResult(), not(containsString("ERROR!"))); * // all lines will run, and then a combined failure logged at the end. * } * } * </pre> * * @since 4.7 */ public class ErrorCollector extends Verifier { private List<Throwable> errors = new ArrayList<Throwable>(); @Override protected void verify() throws Throwable { MultipleFailureException.assertEmpty(errors); } /** * Adds a Throwable to the table. Execution continues, but the test will fail at the end. */ public void addError(Throwable error) { if (error == null) { throw new NullPointerException("Error cannot be null"); } if (error instanceof AssumptionViolatedException) { AssertionError e = new AssertionError(error.getMessage()); e.initCause(error); errors.add(e); } else { errors.add(error); } } /** * Adds a failure to the table if {@code matcher} does not match {@code value}. * Execution continues, but the test will fail at the end if the match fails. */ public <T> void checkThat(final T value, final Matcher<T> matcher) { checkThat("", value, matcher); } /** * Adds a failure with the given {@code reason} * to the table if {@code matcher} does not match {@code value}. * Execution continues, but the test will fail at the end if the match fails. */ public <T> void checkThat(final String reason, final T value, final Matcher<T> matcher) { checkSucceeds(new Callable<Object>() { public Object call() throws Exception { assertThat(reason, value, matcher); return value; } }); } /** * Adds to the table the exception, if any, thrown from {@code callable}. * Execution continues, but the test will fail at the end if * {@code callable} threw an exception. */ public <T> T checkSucceeds(Callable<T> callable) { try { return callable.call(); } catch (AssumptionViolatedException e) { AssertionError error = new AssertionError("Callable threw AssumptionViolatedException"); error.initCause(e); addError(error); return null; } catch (Throwable e) { addError(e); return null; } } /** * Adds a failure to the table if {@code runnable} does not throw an * exception of type {@code expectedThrowable} when executed. * Execution continues, but the test will fail at the end if the runnable * does not throw an exception, or if it throws a different exception. * * @param expectedThrowable the expected type of the exception * @param runnable a function that is expected to throw an exception when executed * @since 4.13 */ public void checkThrows(Class<? extends Throwable> expectedThrowable, ThrowingRunnable runnable) { try { assertThrows(expectedThrowable, runnable); } catch (AssertionError e) { addError(e); } } }
⏎ org/junit/rules/ErrorCollector.java
Or download all of them as a single archive file:
File name: junit-4.13.2-sources.jar File size: 234540 bytes Release date: 2021-02-13 Download
⇒ Download and Install junit-4.12.jar
⇐ Download and Install junit-4.13.2.jar
2016-03-28, 11596👍, 0💬
Popular Posts:
Java Advanced Imaging (JAI) is a Java platform extension API that provides a set of object-oriented ...
What Is commons-fileupload-1.3.3 .jar?commons-fileupload-1.3.3 .jaris the JAR file for Apache Common...
maven-compat-3.8.6.jar is the JAR file for Apache Maven 3.8.6 Compact module. The JAR file name may ...
jlGui is a music player for the Java platform. It is based on Java Sound 1.0 (i.e. JDK 1.3+). It sup...
Apache Log4j API provides the interface that applications should code to and provides the adapter co...