Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
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 (322)
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/TestWatcher.java
package org.junit.rules;
import java.util.ArrayList;
import java.util.List;
import org.junit.AssumptionViolatedException;
import org.junit.Rule;
import org.junit.runner.Description;
import org.junit.runners.model.MultipleFailureException;
import org.junit.runners.model.Statement;
/**
* TestWatcher is a base class for Rules that take note of the testing
* action, without modifying it. For example, this class will keep a log of each
* passing and failing test:
*
* <pre>
* public static class WatchmanTest {
* private static String watchedLog;
*
* @Rule(order = Integer.MIN_VALUE)
* public TestWatcher watchman= new TestWatcher() {
* @Override
* protected void failed(Throwable e, Description description) {
* watchedLog+= description + "\n";
* }
*
* @Override
* protected void succeeded(Description description) {
* watchedLog+= description + " " + "success!\n";
* }
* };
*
* @Test
* public void fails() {
* fail();
* }
*
* @Test
* public void succeeds() {
* }
* }
* </pre>
* <p>It is recommended to always set the {@link Rule#order() order} of the
* {@code TestWatcher} to {@code Integer.MIN_VALUE} so that it encloses all
* other rules. Otherwise it may see failed tests as successful and vice versa
* if some rule changes the result of a test (e.g. {@link ErrorCollector} or
* {@link ExpectedException}).
*
* @since 4.9
*/
public abstract class TestWatcher implements TestRule {
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 (org.junit.internal.AssumptionViolatedException e) {
errors.add(e);
skippedQuietly(e, description, errors);
} catch (Throwable e) {
errors.add(e);
failedQuietly(e, description, errors);
} finally {
finishedQuietly(description, errors);
}
MultipleFailureException.assertEmpty(errors);
}
};
}
private void succeededQuietly(Description description,
List<Throwable> errors) {
try {
succeeded(description);
} catch (Throwable e) {
errors.add(e);
}
}
private void failedQuietly(Throwable e, Description description,
List<Throwable> errors) {
try {
failed(e, description);
} catch (Throwable e1) {
errors.add(e1);
}
}
private void skippedQuietly(
org.junit.internal.AssumptionViolatedException e, Description description,
List<Throwable> errors) {
try {
if (e instanceof AssumptionViolatedException) {
skipped((AssumptionViolatedException) e, description);
} else {
skipped(e, description);
}
} catch (Throwable e1) {
errors.add(e1);
}
}
private void startingQuietly(Description description,
List<Throwable> errors) {
try {
starting(description);
} catch (Throwable e) {
errors.add(e);
}
}
private void finishedQuietly(Description description,
List<Throwable> errors) {
try {
finished(description);
} catch (Throwable e) {
errors.add(e);
}
}
/**
* Invoked when a test succeeds
*/
protected void succeeded(Description description) {
}
/**
* Invoked when a test fails
*/
protected void failed(Throwable e, Description description) {
}
/**
* Invoked when a test is skipped due to a failed assumption.
*/
protected void skipped(AssumptionViolatedException e, Description description) {
// For backwards compatibility with JUnit 4.11 and earlier, call the legacy version
org.junit.internal.AssumptionViolatedException asInternalException = e;
skipped(asInternalException, description);
}
/**
* Invoked when a test is skipped due to a failed assumption.
*
* @deprecated use {@link #skipped(AssumptionViolatedException, Description)}
*/
@Deprecated
protected void skipped(
org.junit.internal.AssumptionViolatedException e, Description description) {
}
/**
* Invoked when a test is about to start
*/
protected void starting(Description description) {
}
/**
* Invoked when a test method finishes (whether passing or failing)
*/
protected void finished(Description description) {
}
}
⏎ org/junit/rules/TestWatcher.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, ≈99🔥, 0💬
Popular Posts:
JDOM provides a solution for using XML from Java that is as simple as Java itself. There is no compe...
Apache Commons Lang 3 is the 3rd version of Apache Commons Lang, which provides a host of helper uti...
commons-collections4-4.4 -sources.jaris the source JAR file for Apache Commons Collections 4.2, whic...
HttpComponents Core Source Code Files are provided in the source package file, httpcomponents-core-5...
What Is jsse.jar (JDK 6) Java Secure Socket Extension? jsse.jar, Java Secure Socket Extension, is Ja...