Exception Fact Sheet for "jUnit"

The goal of an Exception Fact Sheet is to reveal the design of exception handling in an application.

--Maxence, Martin

For feedback, please contact Martin

Table of contents

Basic Statistics

Number of Classes 185
Number of Domain Exception Types (Thrown or Caught) 11
Number of Domain Checked Exception Types 5
Number of Domain Runtime Exception Types 3
Number of Domain Unknown Exception Types 3
nTh = Number of Throw 78
nTh = Number of Throw in Catch 36
Number of Catch-Rethrow (may not be correct) 9
nC = Number of Catch 102
nCTh = Number of Catch with Throw 36
Number of Empty Catch (really Empty) 5
Number of Empty Catch (with comments) 4
Number of Empty Catch 9
nM = Number of Methods 1003
nbFunctionWithCatch = Number of Methods with Catch 64 / 1003
nbFunctionWithThrow = Number of Methods with Throw 55 / 1003
nbFunctionWithThrowS = Number of Methods with ThrowS 159 / 1003
nbFunctionTransmitting = Number of Methods with "Throws" but NO catch, NO throw (only transmitting) 136 / 1003
P1 = nCTh / nC 35.3% (0.353)
P2 = nMC / nM 6.4% (0.064)
P3 = nbFunctionWithThrow / nbFunction 5.5% (0.055)
P4 = nbFunctionTransmitting / nbFunction 13.6% (0.136)
P5 = nbThrowInCatch / nbThrow 46.2% (0.462)
R2 = nCatch / nThrow 1.308
A1 = Number of Caught Exception Types From External Libraries 16
A2 = Number of Reused Exception Types From External Libraries (thrown from application code) 7

W1 is a rough estimation of the richness of the exception model. It does not take into account the inheritance relationships between domain exceptions.

Proportion P1 measures the overall exception flow. According to our experience, it varies from 5% to 70%. Early-catch design generally yields a low P1, libraries that must warn clients about errors (e.g. databases) generally have a high P1.

Proportion P2 measures the dispersion of catch blocks in the application. According to our experience, it varies from 2% to 15%. A small P2 indicates a rather centralized management of errors.

R1 shows how many exceptions types from libraries (incl. JDK) are thrown from application code. For instance, IllegalArgumentException comes from the JDK but is used in many applications.

A1 measures the awareness of the application to library exceptions. A high value of A1 means either that the application is polluted with checked exceptions or that it is able to apply specific recovery depending on the library exception.

Exception Hierachy

Exception Map

Each exception that is used at least once in the project is a dot. A orange dot represents a domain exception that is defined in the application. A blue dot exception is defined in the JDK or in a library. The x-axis represents the number of times an exception is caught, the y-axis the number of times an exception is thrown.

Exceptions With State

State means fields. Number of exceptions with state: 5
InitializationError
              package org.junit.runners.model;public class InitializationError extends Exception {
	private static final long serialVersionUID= 1L;
	private final List<Throwable> fErrors;

	/**
	 * Construct a new {@code InitializationError} with one or more
	 * errors {@code errors} as causes
	 */
	public InitializationError(List<Throwable> errors) {
		fErrors= errors;
	}
	
	public InitializationError(Throwable error) {
		this(Arrays.asList(error));
	}
	
	/**
	 * Construct a new {@code InitializationError} with one cause
	 * with message {@code string}
	 */
	public InitializationError(String string) {
		this(new Exception(string));
	}

	/**
	 * Returns one or more Throwables that led to this initialization error.
	 */
	public List<Throwable> getCauses() {
		return fErrors;
	}
}
            
MultipleFailureException
              package org.junit.runners.model;public class MultipleFailureException extends Exception {
	private static final long serialVersionUID= 1L;
	
	private final List<Throwable> fErrors;

	public MultipleFailureException(List<Throwable> errors) {
		fErrors= new ArrayList<Throwable>(errors);
	}

	public List<Throwable> getFailures() {
		return Collections.unmodifiableList(fErrors);
	}

	@Override
	public String getMessage() {
		StringBuilder sb = new StringBuilder(
				String.format("There were %d errors:", fErrors.size()));
		for (Throwable e : fErrors) {
			sb.append(String.format("\n  %s(%s)", e.getClass().getName(), e.getMessage()));
		}
		return sb.toString();
	}

	/**
	 * Asserts that a list of throwables is empty. If it isn't empty,
	 * will throw {@link MultipleFailureException} (if there are
	 * multiple throwables in the list) or the first element in the list
	 * (if there is only one element).
	 * 
	 * @param errors list to check
	 * @throws Throwable if the list is not empty
	 */
	@SuppressWarnings("deprecation")
	public static void assertEmpty(List<Throwable> errors) throws Throwable {
		if (errors.isEmpty())
			return;
		if (errors.size() == 1)
			throw errors.get(0);

		/*
		 * Many places in the code are documented to throw
		 * org.junit.internal.runners.model.MultipleFailureException.
		 * That class now extends this one, so we throw the internal
		 * exception in case developers have tests that catch
		 * MultipleFailureException.
		 */
		throw new org.junit.internal.runners.model.MultipleFailureException(errors);
	}
            
AssumptionViolatedException
              package org.junit.internal;public class AssumptionViolatedException extends RuntimeException implements SelfDescribing {
	private static final long serialVersionUID= 1L;

	private final Object fValue;

	private final Matcher<?> fMatcher;

	public AssumptionViolatedException(Object value, Matcher<?> matcher) {
		super(value instanceof Throwable ? (Throwable) value : null);
		fValue= value;
		fMatcher= matcher;
	}
	
	public AssumptionViolatedException(String assumption) {
		this(assumption, null);
	}

	@Override
	public String getMessage() {
		return StringDescription.asString(this);
	}

	public void describeTo(Description description) {
		if (fMatcher != null) {
			description.appendText("got: ");
			description.appendValue(fValue);
			description.appendText(", expected: ");
			description.appendDescriptionOf(fMatcher);
		} else {
			description.appendText("failed assumption: " + fValue);
		}
	}
}
            
ComparisonFailure
              package junit.framework;public class ComparisonFailure extends AssertionFailedError {
	private static final int MAX_CONTEXT_LENGTH= 20;
	private static final long serialVersionUID= 1L;
	
	private String fExpected;
	private String fActual;

	/**
	 * Constructs a comparison failure.
	 * @param message the identifying message or null
	 * @param expected the expected string value
	 * @param actual the actual string value
	 */
	public ComparisonFailure (String message, String expected, String actual) {
		super (message);
		fExpected= expected;
		fActual= actual;
	}
	
	/**
	 * Returns "..." in place of common prefix and "..." in
	 * place of common suffix between expected and actual.
	 * 
	 * @see Throwable#getMessage()
	 */
	@Override
	public String getMessage() {
		return new ComparisonCompactor(MAX_CONTEXT_LENGTH, fExpected, fActual).compact(super.getMessage());
	}
	
	/**
	 * Gets the actual string value
	 * @return the actual string value
	 */
	public String getActual() {
		return fActual;
	}
	/**
	 * Gets the expected string value
	 * @return the expected string value
	 */
	public String getExpected() {
		return fExpected;
	}
}
              package org.junit;public class ComparisonFailure extends AssertionError {	
	/** 
	 * The maximum length for fExpected and fActual. If it is exceeded, the strings should be shortened. 
	 * @see ComparisonCompactor
	 */
	private static final int MAX_CONTEXT_LENGTH= 20;
	private static final long serialVersionUID= 1L;
	
	private String fExpected;
	private String fActual;

	/**
	 * Constructs a comparison failure.
	 * @param message the identifying message or null
	 * @param expected the expected string value
	 * @param actual the actual string value
	 */
	public ComparisonFailure (String message, String expected, String actual) {
		super (message);
		fExpected= expected;
		fActual= actual;
	}
	
	/**
	 * Returns "..." in place of common prefix and "..." in
	 * place of common suffix between expected and actual.
	 * 
	 * @see Throwable#getMessage()
	 */
	@Override
	public String getMessage() {
		return new ComparisonCompactor(MAX_CONTEXT_LENGTH, fExpected, fActual).compact(super.getMessage());
	}
	
	/**
	 * Returns the actual string value
	 * @return the actual string value
	 */
	public String getActual() {
		return fActual;
	}
	/**
	 * Returns the expected string value
	 * @return the expected string value
	 */
	public String getExpected() {
		return fExpected;
	}
	
	private static class ComparisonCompactor {
		private static final String ELLIPSIS= "...";
		private static final String DELTA_END= "]";
		private static final String DELTA_START= "[";
		
		/**
		 * The maximum length for <code>expected</code> and <code>actual</code>. When <code>contextLength</code> 
		 * is exceeded, the Strings are shortened
		 */
		private int fContextLength;
		private String fExpected;
		private String fActual;
		private int fPrefix;
		private int fSuffix;

		/**
		 * @param contextLength the maximum length for <code>expected</code> and <code>actual</code>. When contextLength 
		 * is exceeded, the Strings are shortened
		 * @param expected the expected string value
		 * @param actual the actual string value
		 */
		public ComparisonCompactor(int contextLength, String expected, String actual) {
			fContextLength= contextLength;
			fExpected= expected;
			fActual= actual;
		}

		private String compact(String message) {
			if (fExpected == null || fActual == null || areStringsEqual())
				return Assert.format(message, fExpected, fActual);

			findCommonPrefix();
			findCommonSuffix();
			String expected= compactString(fExpected);
			String actual= compactString(fActual);
			return Assert.format(message, expected, actual);
		}

		private String compactString(String source) {
			String result= DELTA_START + source.substring(fPrefix, source.length() - fSuffix + 1) + DELTA_END;
			if (fPrefix > 0)
				result= computeCommonPrefix() + result;
			if (fSuffix > 0)
				result= result + computeCommonSuffix();
			return result;
		}

		private void findCommonPrefix() {
			fPrefix= 0;
			int end= Math.min(fExpected.length(), fActual.length());
			for (; fPrefix < end; fPrefix++) {
				if (fExpected.charAt(fPrefix) != fActual.charAt(fPrefix))
					break;
			}
		}

		private void findCommonSuffix() {
			int expectedSuffix= fExpected.length() - 1;
			int actualSuffix= fActual.length() - 1;
			for (; actualSuffix >= fPrefix && expectedSuffix >= fPrefix; actualSuffix--, expectedSuffix--) {
				if (fExpected.charAt(expectedSuffix) != fActual.charAt(actualSuffix))
					break;
			}
			fSuffix=  fExpected.length() - expectedSuffix;
		}

		private String computeCommonPrefix() {
			return (fPrefix > fContextLength ? ELLIPSIS : "") + fExpected.substring(Math.max(0, fPrefix - fContextLength), fPrefix);
		}

		private String computeCommonSuffix() {
			int end= Math.min(fExpected.length() - fSuffix + 1 + fContextLength, fExpected.length());
			return fExpected.substring(fExpected.length() - fSuffix + 1, end) + (fExpected.length() - fSuffix + 1 < fExpected.length() - fContextLength ? ELLIPSIS : "");
		}

		private boolean areStringsEqual() {
			return fExpected.equals(fActual);
		}
	}
}
            
ArrayComparisonFailure
              package org.junit.internal;public class ArrayComparisonFailure extends AssertionError {

	private static final long serialVersionUID= 1L;
	
	private List<Integer> fIndices= new ArrayList<Integer>();
	private final String fMessage;
	private final AssertionError fCause;

	/**
	 * Construct a new <code>ArrayComparisonFailure</code> with an error text and the array's
	 * dimension that was not equal
	 * @param cause the exception that caused the array's content to fail the assertion test 
	 * @param index the array position of the objects that are not equal.
	 * @see Assert#assertArrayEquals(String, Object[], Object[])
	 */
	public ArrayComparisonFailure(String message, AssertionError cause, int index) {
		fMessage= message;
		fCause= cause;
		addDimension(index);
	}

	public void addDimension(int index) {
		fIndices.add(0, index);
	}

	@Override
	public String getMessage() {
		StringBuilder builder= new StringBuilder();
		if (fMessage != null)
			builder.append(fMessage);
		builder.append("arrays first differed at element ");
		for (int each : fIndices) {
			builder.append("[");
			builder.append(each);
			builder.append("]");
		}
		builder.append("; ");
		builder.append(fCause.getMessage());
		return builder.toString();
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override public String toString() {
		return getMessage();
	}
}
            

Thrown Exceptions Summary

A (Domain) exception is defined in the application. A (Lib) exception is defined in the JDK or in a library. An exception can be thrown, thrown from within a catch, or declared in the signature of a method (usually for checked exceptions). Hovering over a number triggers showing code snippets from the application code.

Type Exception Thrown Thrown
from Catch
Declared
- Unknown 24
              
//in main/java/junit/framework/TestResult.java
throw e;

              
//in main/java/junit/framework/TestCase.java
throw exception;

              
//in main/java/junit/framework/TestCase.java
throw e.getTargetException();

              
//in main/java/junit/framework/TestCase.java
throw e;

              
//in main/java/org/junit/rules/ExpectedException.java
throw e;

              
//in main/java/org/junit/rules/ExpectedException.java
throw e;

              
//in main/java/org/junit/rules/TestWatcher.java
throw e;

              
//in main/java/org/junit/rules/TestWatcher.java
throw t;

              
//in main/java/org/junit/rules/TestWatchman.java
throw e;

              
//in main/java/org/junit/rules/TestWatchman.java
throw t;

              
//in main/java/org/junit/experimental/theories/Theories.java
throw e;

              
//in main/java/org/junit/internal/ComparisonCriteria.java
throw e;

              
//in main/java/org/junit/internal/runners/statements/FailOnTimeout.java
throw thread.fExceptionThrownByOriginalStatement;

              
//in main/java/org/junit/internal/runners/statements/FailOnTimeout.java
throw exception;

              
//in main/java/org/junit/internal/runners/statements/Fail.java
throw fError;

              
//in main/java/org/junit/internal/runners/statements/ExpectException.java
throw e;

              
//in main/java/org/junit/internal/runners/MethodRoadie.java
throw e.getTargetException();

              
//in main/java/org/junit/internal/runners/model/ReflectiveCallable.java
throw e.getTargetException();

              
//in main/java/org/junit/internal/runners/ClassRoadie.java
throw e.getTargetException();

              
//in main/java/org/junit/internal/runners/SuiteMethod.java
throw e.getCause();

              
//in main/java/org/junit/runners/ParentRunner.java
throw e;

              
//in main/java/org/junit/runners/Parameterized.java
throw parametersMethodReturnedWrongType();

              
//in main/java/org/junit/runners/Parameterized.java
throw parametersMethodReturnedWrongType();

              
//in main/java/org/junit/runners/model/MultipleFailureException.java
throw errors.get(0);

            
- -
- Builder 8
              
// in main/java/junit/framework/TestCase.java
throw e.getTargetException();

              
// in main/java/org/junit/internal/runners/MethodRoadie.java
throw e.getTargetException();

              
// in main/java/org/junit/internal/runners/model/ReflectiveCallable.java
throw e.getTargetException();

              
// in main/java/org/junit/internal/runners/ClassRoadie.java
throw e.getTargetException();

              
// in main/java/org/junit/internal/runners/SuiteMethod.java
throw e.getCause();

              
// in main/java/org/junit/runners/Parameterized.java
throw parametersMethodReturnedWrongType();

              
// in main/java/org/junit/runners/Parameterized.java
throw parametersMethodReturnedWrongType();

              
// in main/java/org/junit/runners/model/MultipleFailureException.java
throw errors.get(0);

            
- -
- Variable 16
              
// in main/java/junit/framework/TestResult.java
throw e;

              
// in main/java/junit/framework/TestCase.java
throw exception;

              
// in main/java/junit/framework/TestCase.java
throw e;

              
// in main/java/org/junit/rules/ExpectedException.java
throw e;

              
// in main/java/org/junit/rules/ExpectedException.java
throw e;

              
// in main/java/org/junit/rules/TestWatcher.java
throw e;

              
// in main/java/org/junit/rules/TestWatcher.java
throw t;

              
// in main/java/org/junit/rules/TestWatchman.java
throw e;

              
// in main/java/org/junit/rules/TestWatchman.java
throw t;

              
// in main/java/org/junit/experimental/theories/Theories.java
throw e;

              
// in main/java/org/junit/internal/ComparisonCriteria.java
throw e;

              
// in main/java/org/junit/internal/runners/statements/FailOnTimeout.java
throw thread.fExceptionThrownByOriginalStatement;

              
// in main/java/org/junit/internal/runners/statements/FailOnTimeout.java
throw exception;

              
// in main/java/org/junit/internal/runners/statements/Fail.java
throw fError;

              
// in main/java/org/junit/internal/runners/statements/ExpectException.java
throw e;

              
// in main/java/org/junit/runners/ParentRunner.java
throw e;

            
- -
(Lib) RuntimeException 12
              
// in main/java/junit/framework/JUnit4TestCaseFacade.java
public void run(TestResult result) { throw new RuntimeException( "This test stub created only for informational purposes."); }
// in main/java/org/junit/runner/Request.java
public static Request classes(Computer computer, Class<?>... classes) { try { AllDefaultPossibilitiesBuilder builder= new AllDefaultPossibilitiesBuilder(true); Runner suite= computer.getSuite(builder, classes); return runner(suite); } catch (InitializationError e) { throw new RuntimeException( "Bug in saff's brain: Suite constructor, called as above, should always complete"); } }
// in main/java/org/junit/experimental/max/MaxCore.java
private Runner buildRunner(Description each) { if (each.toString().equals("TestSuite with 0 tests")) return Suite.emptySuite(); if (each.toString().startsWith(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX)) // This is cheating, because it runs the whole class // to get the warning for this method, but we can't do better, // because JUnit 3.8's // thrown away which method the warning is for. return new JUnit38ClassRunner(new TestSuite(getMalformedTestClass(each))); Class<?> type= each.getTestClass(); if (type == null) throw new RuntimeException("Can't build a runner from description [" + each + "]"); String methodName= each.getMethodName(); if (methodName == null) return Request.aClass(type).getRunner(); return Request.method(type, methodName).getRunner(); }
// in main/java/org/junit/experimental/results/FailureList.java
public Result result() { Result result= new Result(); RunListener listener= result.createListener(); for (Failure failure : failures) { try { listener.testFailure(failure); } catch (Exception e) { throw new RuntimeException("I can't believe this happened"); } } return result; }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
Override public Object getValue() throws CouldNotGenerateValueException { try { return fMethod.invokeExplosively(null); } catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: argument length is checked"); } catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getMethods returned an inaccessible method"); } catch (Throwable e) { throw new CouldNotGenerateValueException(); // do nothing, just look for more values } }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
private Object getStaticFieldValue(final Field field) { try { return field.get(null); } catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: field from getClass doesn't exist on object"); } catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getFields returned an inaccessible field"); } }
// in main/java/org/junit/internal/runners/MethodRoadie.java
public void runBeforesThenTestThenAfters(Runnable test) { try { runBefores(); test.run(); } catch (FailedBefore e) { } catch (Exception e) { throw new RuntimeException("test should never throw an exception to this level"); } finally { runAfters(); } }
// in main/java/org/junit/runners/model/TestClass.java
public <T> List<T> getAnnotatedFieldValues(Object test, Class<? extends Annotation> annotationClass, Class<T> valueClass) { List<T> results= new ArrayList<T>(); for (FrameworkField each : getAnnotatedFields(annotationClass)) { try { Object fieldValue= each.get(test); if (valueClass.isInstance(fieldValue)) results.add(valueClass.cast(fieldValue)); } catch (IllegalAccessException e) { throw new RuntimeException( "How did getFields return a field we couldn't access?", e); } } return results; }
// in main/java/org/junit/runners/model/TestClass.java
public <T> List<T> getAnnotatedMethodValues(Object test, Class<? extends Annotation> annotationClass, Class<T> valueClass) { List<T> results= new ArrayList<T>(); for (FrameworkMethod each : getAnnotatedMethods(annotationClass)) { try { Object fieldValue= each.invokeExplosively(test, new Object[]{}); if (valueClass.isInstance(fieldValue)) results.add(valueClass.cast(fieldValue)); } catch (Throwable e) { throw new RuntimeException( "Exception in " + each.getName(), e); } } return results; }
// in main/java/org/junit/runners/Suite.java
public static Runner emptySuite() { try { return new Suite((Class<?>)null, new Class<?>[0]); } catch (InitializationError e) { throw new RuntimeException("This shouldn't be possible"); } }
10
              
// in main/java/org/junit/runner/Request.java
catch (InitializationError e) { throw new RuntimeException( "Bug in saff's brain: Suite constructor, called as above, should always complete"); }
// in main/java/org/junit/experimental/results/FailureList.java
catch (Exception e) { throw new RuntimeException("I can't believe this happened"); }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: argument length is checked"); }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getMethods returned an inaccessible method"); }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: field from getClass doesn't exist on object"); }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getFields returned an inaccessible field"); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Exception e) { throw new RuntimeException("test should never throw an exception to this level"); }
// in main/java/org/junit/runners/model/TestClass.java
catch (IllegalAccessException e) { throw new RuntimeException( "How did getFields return a field we couldn't access?", e); }
// in main/java/org/junit/runners/model/TestClass.java
catch (Throwable e) { throw new RuntimeException( "Exception in " + each.getName(), e); }
// in main/java/org/junit/runners/Suite.java
catch (InitializationError e) { throw new RuntimeException("This shouldn't be possible"); }
0
(Domain) InitializationError 7
              
// in main/java/org/junit/experimental/categories/Categories.java
private void assertNoDescendantsHaveCategoryAnnotations(Description description) throws InitializationError { for (Description each : description.getChildren()) { if (each.getAnnotation(Category.class) != null) throw new InitializationError("Category annotations on Parameterized classes are not supported on individual methods."); assertNoDescendantsHaveCategoryAnnotations(each); } }
// in main/java/org/junit/internal/runners/MethodValidator.java
public void assertValid() throws InitializationError { if (!fErrors.isEmpty()) throw new InitializationError(fErrors); }
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
public Runner buildRunner(Class<? extends Runner> runnerClass, Class<?> testClass) throws Exception { try { return runnerClass.getConstructor(Class.class).newInstance( new Object[] { testClass }); } catch (NoSuchMethodException e) { try { return runnerClass.getConstructor(Class.class, RunnerBuilder.class).newInstance( new Object[] { testClass, fSuiteBuilder }); } catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); } } }
// in main/java/org/junit/runners/ParentRunner.java
private void validate() throws InitializationError { List<Throwable> errors= new ArrayList<Throwable>(); collectInitializationErrors(errors); if (!errors.isEmpty()) throw new InitializationError(errors); }
// in main/java/org/junit/runners/model/RunnerBuilder.java
Class<?> addParent(Class<?> parent) throws InitializationError { if (!parents.add(parent)) throw new InitializationError(String.format("class '%s' (possibly indirectly) contains itself as a SuiteClass", parent.getName())); return parent; }
2
              
// in main/java/org/junit/experimental/categories/Categories.java
catch (NoTestsRemainException e) { throw new InitializationError(e); }
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
catch (NoSuchMethodException e) { try { return runnerClass.getConstructor(Class.class, RunnerBuilder.class).newInstance( new Object[] { testClass, fSuiteBuilder }); } catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); } }
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); }
23
              
// in main/java/org/junit/runner/Computer.java
public Runner getSuite(final RunnerBuilder builder, Class<?>[] classes) throws InitializationError { return new Suite(new RunnerBuilder() { @Override public Runner runnerForClass(Class<?> testClass) throws Throwable { return getRunner(builder, testClass); } }, classes); }
// in main/java/org/junit/experimental/categories/Categories.java
private void assertNoCategorizedDescendentsOfUncategorizeableParents(Description description) throws InitializationError { if (!canHaveCategorizedChildren(description)) assertNoDescendantsHaveCategoryAnnotations(description); for (Description each : description.getChildren()) assertNoCategorizedDescendentsOfUncategorizeableParents(each); }
// in main/java/org/junit/experimental/categories/Categories.java
private void assertNoDescendantsHaveCategoryAnnotations(Description description) throws InitializationError { for (Description each : description.getChildren()) { if (each.getAnnotation(Category.class) != null) throw new InitializationError("Category annotations on Parameterized classes are not supported on individual methods."); assertNoDescendantsHaveCategoryAnnotations(each); } }
// in main/java/org/junit/experimental/ParallelComputer.java
Override public Runner getSuite(RunnerBuilder builder, java.lang.Class<?>[] classes) throws InitializationError { Runner suite= super.getSuite(builder, classes); return fClasses ? parallelize(suite) : suite; }
// in main/java/org/junit/internal/runners/MethodValidator.java
public void assertValid() throws InitializationError { if (!fErrors.isEmpty()) throw new InitializationError(fErrors); }
// in main/java/org/junit/internal/runners/JUnit4ClassRunner.java
protected void validate() throws InitializationError { MethodValidator methodValidator= new MethodValidator(fTestClass); methodValidator.validateMethodsForDefaultRunner(); methodValidator.assertValid(); }
// in main/java/org/junit/runners/ParentRunner.java
private void validate() throws InitializationError { List<Throwable> errors= new ArrayList<Throwable>(); collectInitializationErrors(errors); if (!errors.isEmpty()) throw new InitializationError(errors); }
// in main/java/org/junit/runners/Parameterized.java
private void createRunnersForParameters(Iterable<Object[]> allParameters, String namePattern) throws InitializationError, Exception { try { int i= 0; for (Object[] parametersOfSingleTest : allParameters) { String name= nameFor(namePattern, i, parametersOfSingleTest); TestClassRunnerForParameters runner= new TestClassRunnerForParameters( getTestClass().getJavaClass(), parametersOfSingleTest, name); runners.add(runner); ++i; } } catch (ClassCastException e) { throw parametersMethodReturnedWrongType(); } }
// in main/java/org/junit/runners/model/RunnerBuilder.java
Class<?> addParent(Class<?> parent) throws InitializationError { if (!parents.add(parent)) throw new InitializationError(String.format("class '%s' (possibly indirectly) contains itself as a SuiteClass", parent.getName())); return parent; }
// in main/java/org/junit/runners/model/RunnerBuilder.java
public List<Runner> runners(Class<?> parent, Class<?>[] children) throws InitializationError { addParent(parent); try { return runners(children); } finally { removeParent(parent); } }
// in main/java/org/junit/runners/model/RunnerBuilder.java
public List<Runner> runners(Class<?> parent, List<Class<?>> children) throws InitializationError { return runners(parent, children.toArray(new Class<?>[0])); }
(Lib) Exception 5
              
// in main/java/junit/textui/TestRunner.java
public TestResult start(String args[]) throws Exception { String testCase= ""; String method= ""; boolean wait= false; for (int i= 0; i < args.length; i++) { if (args[i].equals("-wait")) wait= true; else if (args[i].equals("-c")) testCase= extractClassName(args[++i]); else if (args[i].equals("-m")) { String arg= args[++i]; int lastIndex= arg.lastIndexOf('.'); testCase= arg.substring(0, lastIndex); method= arg.substring(lastIndex + 1); } else if (args[i].equals("-v")) System.err.println("JUnit " + Version.id() + " by Kent Beck and Erich Gamma"); else testCase= args[i]; } if (testCase.equals("")) throw new Exception("Usage: TestRunner [-wait] testCaseName, where name is the name of the TestCase class"); try { if (!method.equals("")) return runSingleMethod(testCase, method, wait); Test suite= getTest(testCase); return doRun(suite, wait); } catch (Exception e) { throw new Exception("Could not create and run test suite: " + e); } }
// in main/java/org/junit/internal/runners/statements/ExpectException.java
Override public void evaluate() throws Exception { boolean complete = false; try { fNext.evaluate(); complete = true; } catch (AssumptionViolatedException e) { throw e; } catch (Throwable e) { if (!fExpected.isAssignableFrom(e.getClass())) { String message= "Unexpected exception, expected<" + fExpected.getName() + "> but was<" + e.getClass().getName() + ">"; throw new Exception(message, e); } } if (complete) throw new AssertionError("Expected exception: " + fExpected.getName()); }
// in main/java/org/junit/internal/runners/SuiteMethod.java
public static Test testFromSuiteMethod(Class<?> klass) throws Throwable { Method suiteMethod= null; Test suite= null; try { suiteMethod= klass.getMethod("suite"); if (! Modifier.isStatic(suiteMethod.getModifiers())) { throw new Exception(klass.getName() + ".suite() must be static"); } suite= (Test) suiteMethod.invoke(null); // static method } catch (InvocationTargetException e) { throw e.getCause(); } return suite; }
// in main/java/org/junit/runners/Parameterized.java
private FrameworkMethod getParametersMethod() throws Exception { List<FrameworkMethod> methods= getTestClass().getAnnotatedMethods( Parameters.class); for (FrameworkMethod each : methods) { if (each.isStatic() && each.isPublic()) return each; } throw new Exception("No public static parameters method on class " + getTestClass().getName()); }
2
              
// in main/java/junit/textui/TestRunner.java
catch (Exception e) { throw new Exception("Could not create and run test suite: " + e); }
// in main/java/org/junit/internal/runners/statements/ExpectException.java
catch (Throwable e) { if (!fExpected.isAssignableFrom(e.getClass())) { String message= "Unexpected exception, expected<" + fExpected.getName() + "> but was<" + e.getClass().getName() + ">"; throw new Exception(message, e); } }
47
              
// in main/java/junit/framework/JUnit4TestAdapterCache.java
public RunNotifier getNotifier(final TestResult result, final JUnit4TestAdapter adapter) { RunNotifier notifier = new RunNotifier(); notifier.addListener(new RunListener() { @Override public void testFailure(Failure failure) throws Exception { result.addError(asTest(failure.getDescription()), failure.getException()); } @Override public void testFinished(Description description) throws Exception { result.endTest(asTest(description)); } @Override public void testStarted(Description description) throws Exception { result.startTest(asTest(description)); } }); return notifier; }
// in main/java/junit/framework/JUnit4TestAdapterCache.java
Override public void testFailure(Failure failure) throws Exception { result.addError(asTest(failure.getDescription()), failure.getException()); }
// in main/java/junit/framework/JUnit4TestAdapterCache.java
Override public void testFinished(Description description) throws Exception { result.endTest(asTest(description)); }
// in main/java/junit/framework/JUnit4TestAdapterCache.java
Override public void testStarted(Description description) throws Exception { result.startTest(asTest(description)); }
// in main/java/junit/framework/TestCase.java
protected void setUp() throws Exception { }
// in main/java/junit/framework/TestCase.java
protected void tearDown() throws Exception { }
// in main/java/junit/textui/TestRunner.java
public TestResult start(String args[]) throws Exception { String testCase= ""; String method= ""; boolean wait= false; for (int i= 0; i < args.length; i++) { if (args[i].equals("-wait")) wait= true; else if (args[i].equals("-c")) testCase= extractClassName(args[++i]); else if (args[i].equals("-m")) { String arg= args[++i]; int lastIndex= arg.lastIndexOf('.'); testCase= arg.substring(0, lastIndex); method= arg.substring(lastIndex + 1); } else if (args[i].equals("-v")) System.err.println("JUnit " + Version.id() + " by Kent Beck and Erich Gamma"); else testCase= args[i]; } if (testCase.equals("")) throw new Exception("Usage: TestRunner [-wait] testCaseName, where name is the name of the TestCase class"); try { if (!method.equals("")) return runSingleMethod(testCase, method, wait); Test suite= getTest(testCase); return doRun(suite, wait); } catch (Exception e) { throw new Exception("Could not create and run test suite: " + e); } }
// in main/java/junit/textui/TestRunner.java
protected TestResult runSingleMethod(String testCase, String method, boolean wait) throws Exception { Class<? extends TestCase> testClass= loadSuiteClass(testCase).asSubclass(TestCase.class); Test test= TestSuite.createTest(testClass, method); return doRun(test, wait); }
// in main/java/junit/extensions/TestSetup.java
Override public void run(final TestResult result) { Protectable p= new Protectable() { public void protect() throws Exception { setUp(); basicRun(result); tearDown(); } }; result.runProtected(this, p); }
// in main/java/junit/extensions/TestSetup.java
public void protect() throws Exception { setUp(); basicRun(result); tearDown(); }
// in main/java/junit/extensions/TestSetup.java
protected void setUp() throws Exception { }
// in main/java/junit/extensions/TestSetup.java
protected void tearDown() throws Exception { }
// in main/java/org/junit/runner/notification/RunNotifier.java
public void fireTestRunStarted(final Description description) { new SafeNotifier() { @Override protected void notifyListener(RunListener each) throws Exception { each.testRunStarted(description); }; }.run(); }
// in main/java/org/junit/runner/notification/RunNotifier.java
Override protected void notifyListener(RunListener each) throws Exception { each.testRunStarted(description); }
// in main/java/org/junit/runner/notification/RunNotifier.java
public void fireTestRunFinished(final Result result) { new SafeNotifier() { @Override protected void notifyListener(RunListener each) throws Exception { each.testRunFinished(result); }; }.run(); }
// in main/java/org/junit/runner/notification/RunNotifier.java
Override protected void notifyListener(RunListener each) throws Exception { each.testRunFinished(result); }
// in main/java/org/junit/runner/notification/RunNotifier.java
public void fireTestStarted(final Description description) throws StoppedByUserException { if (fPleaseStop) throw new StoppedByUserException(); new SafeNotifier() { @Override protected void notifyListener(RunListener each) throws Exception { each.testStarted(description); }; }.run(); }
// in main/java/org/junit/runner/notification/RunNotifier.java
Override protected void notifyListener(RunListener each) throws Exception { each.testStarted(description); }
// in main/java/org/junit/runner/notification/RunNotifier.java
private void fireTestFailures(List<RunListener> listeners, final List<Failure> failures) { if (!failures.isEmpty()) new SafeNotifier(listeners) { @Override protected void notifyListener(RunListener listener) throws Exception { for (Failure each : failures) listener.testFailure(each); }; }.run(); }
// in main/java/org/junit/runner/notification/RunNotifier.java
Override protected void notifyListener(RunListener listener) throws Exception { for (Failure each : failures) listener.testFailure(each); }
// in main/java/org/junit/runner/notification/RunNotifier.java
public void fireTestAssumptionFailed(final Failure failure) { new SafeNotifier() { @Override protected void notifyListener(RunListener each) throws Exception { each.testAssumptionFailure(failure); }; }.run(); }
// in main/java/org/junit/runner/notification/RunNotifier.java
Override protected void notifyListener(RunListener each) throws Exception { each.testAssumptionFailure(failure); }
// in main/java/org/junit/runner/notification/RunNotifier.java
public void fireTestIgnored(final Description description) { new SafeNotifier() { @Override protected void notifyListener(RunListener each) throws Exception { each.testIgnored(description); } }.run(); }
// in main/java/org/junit/runner/notification/RunNotifier.java
Override protected void notifyListener(RunListener each) throws Exception { each.testIgnored(description); }
// in main/java/org/junit/runner/notification/RunNotifier.java
public void fireTestFinished(final Description description) { new SafeNotifier() { @Override protected void notifyListener(RunListener each) throws Exception { each.testFinished(description); }; }.run(); }
// in main/java/org/junit/runner/notification/RunNotifier.java
Override protected void notifyListener(RunListener each) throws Exception { each.testFinished(description); }
// in main/java/org/junit/runner/notification/RunListener.java
public void testRunStarted(Description description) throws Exception { }
// in main/java/org/junit/runner/notification/RunListener.java
public void testRunFinished(Result result) throws Exception { }
// in main/java/org/junit/runner/notification/RunListener.java
public void testStarted(Description description) throws Exception { }
// in main/java/org/junit/runner/notification/RunListener.java
public void testFinished(Description description) throws Exception { }
// in main/java/org/junit/runner/notification/RunListener.java
public void testFailure(Failure failure) throws Exception { }
// in main/java/org/junit/runner/notification/RunListener.java
public void testIgnored(Description description) throws Exception { }
// in main/java/org/junit/runner/Result.java
Override public void testRunStarted(Description description) throws Exception { fStartTime= System.currentTimeMillis(); }
// in main/java/org/junit/runner/Result.java
Override public void testRunFinished(Result result) throws Exception { long endTime= System.currentTimeMillis(); fRunTime+= endTime - fStartTime; }
// in main/java/org/junit/runner/Result.java
Override public void testFinished(Description description) throws Exception { fCount.getAndIncrement(); }
// in main/java/org/junit/runner/Result.java
Override public void testFailure(Failure failure) throws Exception { fFailures.add(failure); }
// in main/java/org/junit/runner/Result.java
Override public void testIgnored(Description description) throws Exception { fIgnoreCount.getAndIncrement(); }
// in main/java/org/junit/rules/ErrorCollector.java
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; } }); }
// in main/java/org/junit/rules/ErrorCollector.java
public Object call() throws Exception { assertThat(reason, value, matcher); return value; }
// in main/java/org/junit/experimental/max/MaxHistory.java
Override public void testStarted(Description description) throws Exception { starts.put(description, System.nanoTime()); // Get most accurate // possible time }
// in main/java/org/junit/experimental/max/MaxHistory.java
Override public void testFinished(Description description) throws Exception { long end= System.nanoTime(); long start= starts.get(description); putTestDuration(description, end - start); }
// in main/java/org/junit/experimental/max/MaxHistory.java
Override public void testFailure(Failure failure) throws Exception { putTestFailureTimestamp(failure.getDescription(), overallStart); }
// in main/java/org/junit/experimental/max/MaxHistory.java
Override public void testRunFinished(Result result) throws Exception { save(); }
// in main/java/org/junit/experimental/theories/Theories.java
protected void runWithCompleteAssignment(final Assignments complete) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, Throwable { new BlockJUnit4ClassRunner(getTestClass().getJavaClass()) { @Override protected void collectInitializationErrors( List<Throwable> errors) { // do nothing } @Override public Statement methodBlock(FrameworkMethod method) { final Statement statement= super.methodBlock(method); return new Statement() { @Override public void evaluate() throws Throwable { try { statement.evaluate(); handleDataPointSuccess(); } catch (AssumptionViolatedException e) { handleAssumptionViolation(e); } catch (Throwable e) { reportParameterizedError(e, complete .getArgumentStrings(nullsOk())); } } }; } @Override protected Statement methodInvoker(FrameworkMethod method, Object test) { return methodCompletesWithParameters(method, complete, test); } @Override public Object createTest() throws Exception { return getTestClass().getOnlyConstructor().newInstance( complete.getConstructorArguments(nullsOk())); } }.methodBlock(fTestMethod).evaluate(); }
// in main/java/org/junit/experimental/theories/Theories.java
Override public Object createTest() throws Exception { return getTestClass().getOnlyConstructor().newInstance( complete.getConstructorArguments(nullsOk())); }
// in main/java/org/junit/experimental/theories/internal/Assignments.java
public static Assignments allUnassigned(Method testMethod, TestClass testClass) throws Exception { List<ParameterSignature> signatures; signatures= ParameterSignature.signatures(testClass .getOnlyConstructor()); signatures.addAll(ParameterSignature.signatures(testMethod)); return new Assignments(new ArrayList<PotentialAssignment>(), signatures, testClass); }
// in main/java/org/junit/experimental/ParallelComputer.java
private static <T> Runner parallelize(Runner runner) { if (runner instanceof ParentRunner<?>) { ((ParentRunner<?>) runner).setScheduler(new RunnerScheduler() { private final List<Future<Object>> fResults= new ArrayList<Future<Object>>(); private final ExecutorService fService= Executors .newCachedThreadPool(); public void schedule(final Runnable childStatement) { fResults.add(fService.submit(new Callable<Object>() { public Object call() throws Exception { childStatement.run(); return null; } })); }
// in main/java/org/junit/experimental/ParallelComputer.java
public void schedule(final Runnable childStatement) { fResults.add(fService.submit(new Callable<Object>() { public Object call() throws Exception { childStatement.run(); return null; } }
// in main/java/org/junit/experimental/ParallelComputer.java
public Object call() throws Exception { childStatement.run(); return null; }
// in main/java/org/junit/internal/runners/statements/FailOnTimeout.java
private void throwTimeoutException(StatementThread thread) throws Exception { Exception exception= new Exception(String.format( "test timed out after %d milliseconds", fTimeout)); exception.setStackTrace(thread.getStackTrace()); throw exception; }
// in main/java/org/junit/internal/runners/statements/ExpectException.java
Override public void evaluate() throws Exception { boolean complete = false; try { fNext.evaluate(); complete = true; } catch (AssumptionViolatedException e) { throw e; } catch (Throwable e) { if (!fExpected.isAssignableFrom(e.getClass())) { String message= "Unexpected exception, expected<" + fExpected.getName() + "> but was<" + e.getClass().getName() + ">"; throw new Exception(message, e); } } if (complete) throw new AssertionError("Expected exception: " + fExpected.getName()); }
// in main/java/org/junit/internal/runners/JUnit4ClassRunner.java
protected Object createTest() throws Exception { return getTestClass().getConstructor().newInstance(); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
private void runWithTimeout(final long timeout) { runBeforesThenTestThenAfters(new Runnable() { public void run() { ExecutorService service= Executors.newSingleThreadExecutor(); Callable<Object> callable= new Callable<Object>() { public Object call() throws Exception { runTestMethod(); return null; } }; Future<Object> result= service.submit(callable); service.shutdown(); try { boolean terminated= service.awaitTermination(timeout, TimeUnit.MILLISECONDS); if (!terminated) service.shutdownNow(); result.get(0, TimeUnit.MILLISECONDS); // throws the exception if one occurred during the invocation } catch (TimeoutException e) { addFailure(new Exception(String.format("test timed out after %d milliseconds", timeout))); } catch (Exception e) { addFailure(e); } } }); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
public void run() { ExecutorService service= Executors.newSingleThreadExecutor(); Callable<Object> callable= new Callable<Object>() { public Object call() throws Exception { runTestMethod(); return null; } }; Future<Object> result= service.submit(callable); service.shutdown(); try { boolean terminated= service.awaitTermination(timeout, TimeUnit.MILLISECONDS); if (!terminated) service.shutdownNow(); result.get(0, TimeUnit.MILLISECONDS); // throws the exception if one occurred during the invocation } catch (TimeoutException e) { addFailure(new Exception(String.format("test timed out after %d milliseconds", timeout))); } catch (Exception e) { addFailure(e); } }
// in main/java/org/junit/internal/runners/MethodRoadie.java
public Object call() throws Exception { runTestMethod(); return null; }
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
Override public Runner runnerForClass(Class<?> testClass) throws Exception { RunWith annotation= testClass.getAnnotation(RunWith.class); if (annotation != null) return buildRunner(annotation.value(), testClass); return null; }
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
public Runner buildRunner(Class<? extends Runner> runnerClass, Class<?> testClass) throws Exception { try { return runnerClass.getConstructor(Class.class).newInstance( new Object[] { testClass }); } catch (NoSuchMethodException e) { try { return runnerClass.getConstructor(Class.class, RunnerBuilder.class).newInstance( new Object[] { testClass, fSuiteBuilder }); } catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); } } }
// in main/java/org/junit/runners/Parameterized.java
Override public Object createTest() throws Exception { return getTestClass().getOnlyConstructor().newInstance(fParameters); }
// in main/java/org/junit/runners/Parameterized.java
private FrameworkMethod getParametersMethod() throws Exception { List<FrameworkMethod> methods= getTestClass().getAnnotatedMethods( Parameters.class); for (FrameworkMethod each : methods) { if (each.isStatic() && each.isPublic()) return each; } throw new Exception("No public static parameters method on class " + getTestClass().getName()); }
// in main/java/org/junit/runners/Parameterized.java
private void createRunnersForParameters(Iterable<Object[]> allParameters, String namePattern) throws InitializationError, Exception { try { int i= 0; for (Object[] parametersOfSingleTest : allParameters) { String name= nameFor(namePattern, i, parametersOfSingleTest); TestClassRunnerForParameters runner= new TestClassRunnerForParameters( getTestClass().getJavaClass(), parametersOfSingleTest, name); runners.add(runner); ++i; } } catch (ClassCastException e) { throw parametersMethodReturnedWrongType(); } }
// in main/java/org/junit/runners/Parameterized.java
private Exception parametersMethodReturnedWrongType() throws Exception { String className= getTestClass().getName(); String methodName= getParametersMethod().getName(); String message= MessageFormat.format( "{0}.{1}() must return an Iterable of arrays.", className, methodName); return new Exception(message); }
// in main/java/org/junit/runners/BlockJUnit4ClassRunner.java
protected Object createTest() throws Exception { return getTestClass().getOnlyConstructor().newInstance(); }
(Lib) AssertionError 5
              
// in main/java/org/junit/rules/ExpectedException.java
Override public void evaluate() throws Throwable { try { fNext.evaluate(); } catch (AssumptionViolatedException e) { optionallyHandleException(e, handleAssumptionViolatedExceptions); return; } catch (AssertionError e) { optionallyHandleException(e, handleAssertionErrors); return; } catch (Throwable e) { handleException(e); return; } if (fMatcher != null) throw new AssertionError("Expected test to throw " + StringDescription.toString(fMatcher)); }
// in main/java/org/junit/internal/runners/statements/ExpectException.java
Override public void evaluate() throws Exception { boolean complete = false; try { fNext.evaluate(); complete = true; } catch (AssumptionViolatedException e) { throw e; } catch (Throwable e) { if (!fExpected.isAssignableFrom(e.getClass())) { String message= "Unexpected exception, expected<" + fExpected.getName() + "> but was<" + e.getClass().getName() + ">"; throw new Exception(message, e); } } if (complete) throw new AssertionError("Expected exception: " + fExpected.getName()); }
// in main/java/org/junit/Assert.java
static public void fail(String message) { if (message == null) throw new AssertionError(); throw new AssertionError(message); }
// in main/java/org/junit/Assert.java
public static <T> void assertThat(String reason, T actual, Matcher<? super T> matcher) { if (!matcher.matches(actual)) { Description description= new StringDescription(); description.appendText(reason); description.appendText("\nExpected: "); description.appendDescriptionOf(matcher); description.appendText("\n got: "); description.appendValue(actual); description.appendText("\n"); throw new java.lang.AssertionError(description.toString()); } }
0 0
(Lib) FailedBefore 4
              
// in main/java/org/junit/internal/runners/MethodRoadie.java
private void runBefores() throws FailedBefore { try { try { List<Method> befores= fTestMethod.getBefores(); for (Method before : befores) before.invoke(fTest); } catch (InvocationTargetException e) { throw e.getTargetException(); } } catch (AssumptionViolatedException e) { throw new FailedBefore(); } catch (Throwable e) { addFailure(e); throw new FailedBefore(); } }
// in main/java/org/junit/internal/runners/ClassRoadie.java
private void runBefores() throws FailedBefore { try { try { List<Method> befores= fTestClass.getBefores(); for (Method before : befores) before.invoke(null); } catch (InvocationTargetException e) { throw e.getTargetException(); } } catch (org.junit.internal.AssumptionViolatedException e) { throw new FailedBefore(); } catch (Throwable e) { addFailure(e); throw new FailedBefore(); } }
4
              
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (AssumptionViolatedException e) { throw new FailedBefore(); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Throwable e) { addFailure(e); throw new FailedBefore(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (org.junit.internal.AssumptionViolatedException e) { throw new FailedBefore(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (Throwable e) { addFailure(e); throw new FailedBefore(); }
2
              
// in main/java/org/junit/internal/runners/MethodRoadie.java
private void runBefores() throws FailedBefore { try { try { List<Method> befores= fTestMethod.getBefores(); for (Method before : befores) before.invoke(fTest); } catch (InvocationTargetException e) { throw e.getTargetException(); } } catch (AssumptionViolatedException e) { throw new FailedBefore(); } catch (Throwable e) { addFailure(e); throw new FailedBefore(); } }
// in main/java/org/junit/internal/runners/ClassRoadie.java
private void runBefores() throws FailedBefore { try { try { List<Method> befores= fTestClass.getBefores(); for (Method before : befores) before.invoke(null); } catch (InvocationTargetException e) { throw e.getTargetException(); } } catch (org.junit.internal.AssumptionViolatedException e) { throw new FailedBefore(); } catch (Throwable e) { addFailure(e); throw new FailedBefore(); } }
(Lib) IllegalArgumentException 4 0 2
              
// in main/java/org/junit/internal/runners/TestMethod.java
public void invoke(Object test) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { fMethod.invoke(test); }
// in main/java/org/junit/runners/model/FrameworkField.java
public Object get(Object target) throws IllegalArgumentException, IllegalAccessException { return fField.get(target); }
(Domain) AssertionFailedError 2
              
// in main/java/junit/framework/Assert.java
static public void fail(String message) { if (message == null) { throw new AssertionFailedError(); } throw new AssertionFailedError(message); }
0 0
(Domain) ComparisonFailure 2
              
// in main/java/junit/framework/Assert.java
static public void assertEquals(String message, String expected, String actual) { if (expected == null && actual == null) return; if (expected != null && expected.equals(actual)) return; String cleanMessage= message == null ? "" : message; throw new ComparisonFailure(cleanMessage, expected, actual); }
// in main/java/org/junit/Assert.java
static public void assertEquals(String message, Object expected, Object actual) { if (equalsRegardingNull(expected, actual)) return; else if (expected instanceof String && actual instanceof String) { String cleanMessage= message == null ? "" : message; throw new ComparisonFailure(cleanMessage, (String) expected, (String) actual); } else failNotEquals(message, expected, actual); }
0 0
(Domain) CouldNotGenerateValueException 2
              
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
Override public Object getValue() throws CouldNotGenerateValueException { try { return fMethod.invokeExplosively(null); } catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: argument length is checked"); } catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getMethods returned an inaccessible method"); } catch (Throwable e) { throw new CouldNotGenerateValueException(); // do nothing, just look for more values } }
// in main/java/org/junit/experimental/theories/internal/Assignments.java
public Object[] getActualValues(int start, int stop, boolean nullsOk) throws CouldNotGenerateValueException { Object[] values= new Object[stop - start]; for (int i= start; i < stop; i++) { Object value= fAssigned.get(i).getValue(); if (value == null && !nullsOk) throw new CouldNotGenerateValueException(); values[i - start]= value; } return values; }
1
              
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (Throwable e) { throw new CouldNotGenerateValueException(); // do nothing, just look for more values }
9
              
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
Override public Object getValue() throws CouldNotGenerateValueException { try { return fMethod.invokeExplosively(null); } catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: argument length is checked"); } catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getMethods returned an inaccessible method"); } catch (Throwable e) { throw new CouldNotGenerateValueException(); // do nothing, just look for more values } }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
Override public String getDescription() throws CouldNotGenerateValueException { return fMethod.getName(); }
// in main/java/org/junit/experimental/theories/internal/Assignments.java
public Object[] getActualValues(int start, int stop, boolean nullsOk) throws CouldNotGenerateValueException { Object[] values= new Object[stop - start]; for (int i= start; i < stop; i++) { Object value= fAssigned.get(i).getValue(); if (value == null && !nullsOk) throw new CouldNotGenerateValueException(); values[i - start]= value; } return values; }
// in main/java/org/junit/experimental/theories/internal/Assignments.java
public Object[] getConstructorArguments(boolean nullsOk) throws CouldNotGenerateValueException { return getActualValues(0, getConstructorParameterCount(), nullsOk); }
// in main/java/org/junit/experimental/theories/internal/Assignments.java
public Object[] getMethodArguments(boolean nullsOk) throws CouldNotGenerateValueException { return getActualValues(getConstructorParameterCount(), fAssigned.size(), nullsOk); }
// in main/java/org/junit/experimental/theories/internal/Assignments.java
public Object[] getAllArguments(boolean nullsOk) throws CouldNotGenerateValueException { return getActualValues(0, fAssigned.size(), nullsOk); }
// in main/java/org/junit/experimental/theories/internal/Assignments.java
public Object[] getArgumentStrings(boolean nullsOk) throws CouldNotGenerateValueException { Object[] values= new Object[fAssigned.size()]; for (int i= 0; i < values.length; i++) { values[i]= fAssigned.get(i).getDescription(); } return values; }
// in main/java/org/junit/experimental/theories/PotentialAssignment.java
public static PotentialAssignment forValue(final String name, final Object value) { return new PotentialAssignment() { @Override public Object getValue() throws CouldNotGenerateValueException { return value; } @Override public String toString() { return String.format("[%s]", value); } @Override public String getDescription() throws CouldNotGenerateValueException { return name; } }; }
// in main/java/org/junit/experimental/theories/PotentialAssignment.java
Override public Object getValue() throws CouldNotGenerateValueException { return value; }
// in main/java/org/junit/experimental/theories/PotentialAssignment.java
Override public String getDescription() throws CouldNotGenerateValueException { return name; }
(Lib) IllegalStateException 2
              
// in main/java/org/junit/rules/TemporaryFolder.java
public File newFile(String fileName) throws IOException { File file= new File(getRoot(), fileName); if (!file.createNewFile()) throw new IllegalStateException( "a file with the name \'" + fileName + "\' already exists in the test folder"); return file; }
// in main/java/org/junit/rules/TemporaryFolder.java
public File getRoot() { if (folder == null) { throw new IllegalStateException( "the temporary folder has not yet been created"); } return folder; }
0 0
(Domain) NoTestsRemainException 2
              
// in main/java/org/junit/internal/runners/JUnit4ClassRunner.java
public void filter(Filter filter) throws NoTestsRemainException { for (Iterator<Method> iter= fTestMethods.iterator(); iter.hasNext();) { Method method= iter.next(); if (!filter.shouldRun(methodDescription(method))) iter.remove(); } if (fTestMethods.isEmpty()) throw new NoTestsRemainException(); }
// in main/java/org/junit/runners/ParentRunner.java
public void filter(Filter filter) throws NoTestsRemainException { for (Iterator<T> iter = getFilteredChildren().iterator(); iter.hasNext(); ) { T each = iter.next(); if (shouldRun(filter, each)) try { filter.apply(each); } catch (NoTestsRemainException e) { iter.remove(); } else iter.remove(); } if (getFilteredChildren().isEmpty()) { throw new NoTestsRemainException(); } }
0 6
              
// in main/java/junit/framework/JUnit4TestAdapter.java
public void filter(Filter filter) throws NoTestsRemainException { filter.apply(fRunner); }
// in main/java/org/junit/runner/manipulation/Filter.java
Override public void apply(Object child) throws NoTestsRemainException { // do nothing }
// in main/java/org/junit/runner/manipulation/Filter.java
public void apply(Object child) throws NoTestsRemainException { if (!(child instanceof Filterable)) return; Filterable filterable= (Filterable) child; filterable.filter(this); }
// in main/java/org/junit/internal/runners/JUnit38ClassRunner.java
public void filter(Filter filter) throws NoTestsRemainException { if (getTest() instanceof Filterable) { Filterable adapter= (Filterable) getTest(); adapter.filter(filter); } else if (getTest() instanceof TestSuite) { TestSuite suite= (TestSuite) getTest(); TestSuite filtered= new TestSuite(suite.getName()); int n= suite.testCount(); for (int i= 0; i < n; i++) { Test test= suite.testAt(i); if (filter.shouldRun(makeDescription(test))) filtered.addTest(test); } setTest(filtered); } }
// in main/java/org/junit/internal/runners/JUnit4ClassRunner.java
public void filter(Filter filter) throws NoTestsRemainException { for (Iterator<Method> iter= fTestMethods.iterator(); iter.hasNext();) { Method method= iter.next(); if (!filter.shouldRun(methodDescription(method))) iter.remove(); } if (fTestMethods.isEmpty()) throw new NoTestsRemainException(); }
// in main/java/org/junit/runners/ParentRunner.java
public void filter(Filter filter) throws NoTestsRemainException { for (Iterator<T> iter = getFilteredChildren().iterator(); iter.hasNext(); ) { T each = iter.next(); if (shouldRun(filter, each)) try { filter.apply(each); } catch (NoTestsRemainException e) { iter.remove(); } else iter.remove(); } if (getFilteredChildren().isEmpty()) { throw new NoTestsRemainException(); } }
(Domain) ArrayComparisonFailure 1
              
// in main/java/org/junit/internal/ComparisonCriteria.java
public void arrayEquals(String message, Object expecteds, Object actuals) throws ArrayComparisonFailure { if (expecteds == actuals) return; String header= message == null ? "" : message + ": "; int expectedsLength= assertArraysAreSameLength(expecteds, actuals, header); for (int i= 0; i < expectedsLength; i++) { Object expected= Array.get(expecteds, i); Object actual= Array.get(actuals, i); if (isArray(expected) && isArray(actual)) { try { arrayEquals(message, expected, actual); } catch (ArrayComparisonFailure e) { e.addDimension(i); throw e; } } else try { assertElementsEqual(expected, actual); } catch (AssertionError e) { throw new ArrayComparisonFailure(header, e, i); } } }
1
              
// in main/java/org/junit/internal/ComparisonCriteria.java
catch (AssertionError e) { throw new ArrayComparisonFailure(header, e, i); }
10
              
// in main/java/org/junit/internal/ComparisonCriteria.java
public void arrayEquals(String message, Object expecteds, Object actuals) throws ArrayComparisonFailure { if (expecteds == actuals) return; String header= message == null ? "" : message + ": "; int expectedsLength= assertArraysAreSameLength(expecteds, actuals, header); for (int i= 0; i < expectedsLength; i++) { Object expected= Array.get(expecteds, i); Object actual= Array.get(actuals, i); if (isArray(expected) && isArray(actual)) { try { arrayEquals(message, expected, actual); } catch (ArrayComparisonFailure e) { e.addDimension(i); throw e; } } else try { assertElementsEqual(expected, actual); } catch (AssertionError e) { throw new ArrayComparisonFailure(header, e, i); } } }
// in main/java/org/junit/Assert.java
public static void assertArrayEquals(String message, Object[] expecteds, Object[] actuals) throws ArrayComparisonFailure { internalArrayEquals(message, expecteds, actuals); }
// in main/java/org/junit/Assert.java
public static void assertArrayEquals(String message, byte[] expecteds, byte[] actuals) throws ArrayComparisonFailure { internalArrayEquals(message, expecteds, actuals); }
// in main/java/org/junit/Assert.java
public static void assertArrayEquals(String message, char[] expecteds, char[] actuals) throws ArrayComparisonFailure { internalArrayEquals(message, expecteds, actuals); }
// in main/java/org/junit/Assert.java
public static void assertArrayEquals(String message, short[] expecteds, short[] actuals) throws ArrayComparisonFailure { internalArrayEquals(message, expecteds, actuals); }
// in main/java/org/junit/Assert.java
public static void assertArrayEquals(String message, int[] expecteds, int[] actuals) throws ArrayComparisonFailure { internalArrayEquals(message, expecteds, actuals); }
// in main/java/org/junit/Assert.java
public static void assertArrayEquals(String message, long[] expecteds, long[] actuals) throws ArrayComparisonFailure { internalArrayEquals(message, expecteds, actuals); }
// in main/java/org/junit/Assert.java
public static void assertArrayEquals(String message, double[] expecteds, double[] actuals, double delta) throws ArrayComparisonFailure { new InexactComparisonCriteria(delta).arrayEquals(message, expecteds, actuals); }
// in main/java/org/junit/Assert.java
public static void assertArrayEquals(String message, float[] expecteds, float[] actuals, float delta) throws ArrayComparisonFailure { new InexactComparisonCriteria(delta).arrayEquals(message, expecteds, actuals); }
// in main/java/org/junit/Assert.java
private static void internalArrayEquals(String message, Object expecteds, Object actuals) throws ArrayComparisonFailure { new ExactComparisonCriteria().arrayEquals(message, expecteds, actuals); }
(Domain) AssumptionViolatedException 1
              
// in main/java/org/junit/Assume.java
public static <T> void assumeThat(T actual, Matcher<T> matcher) { if (!matcher.matches(actual)) throw new AssumptionViolatedException(actual, matcher); }
0 0
(Domain) CouldNotReadCoreException 1
              
// in main/java/org/junit/experimental/max/MaxHistory.java
private static MaxHistory readHistory(File storedResults) throws CouldNotReadCoreException { try { FileInputStream file= new FileInputStream(storedResults); try { ObjectInputStream stream= new ObjectInputStream(file); try { return (MaxHistory) stream.readObject(); } finally { stream.close(); } } finally { file.close(); } } catch (Exception e) { throw new CouldNotReadCoreException(e); } }
1
              
// in main/java/org/junit/experimental/max/MaxHistory.java
catch (Exception e) { throw new CouldNotReadCoreException(e); }
1
              
// in main/java/org/junit/experimental/max/MaxHistory.java
private static MaxHistory readHistory(File storedResults) throws CouldNotReadCoreException { try { FileInputStream file= new FileInputStream(storedResults); try { ObjectInputStream stream= new ObjectInputStream(file); try { return (MaxHistory) stream.readObject(); } finally { stream.close(); } } finally { file.close(); } } catch (Exception e) { throw new CouldNotReadCoreException(e); } }
(Lib) Error 1
              
// in main/java/org/junit/internal/matchers/TypeSafeMatcher.java
private static Class<?> findExpectedType(Class<?> fromClass) { for (Class<?> c = fromClass; c != Object.class; c = c.getSuperclass()) { for (Method method : MethodSorter.getDeclaredMethods(c)) { if (isMatchesSafelyMethod(method)) { return method.getParameterTypes()[0]; } } } throw new Error("Cannot determine correct type for matchesSafely() method."); }
0 0
(Domain) ParameterizedAssertionError 1
              
// in main/java/org/junit/experimental/theories/Theories.java
protected void reportParameterizedError(Throwable e, Object... params) throws Throwable { if (params.length == 0) throw e; throw new ParameterizedAssertionError(e, fTestMethod.getName(), params); }
0 0
(Domain) StoppedByUserException 1
              
// in main/java/org/junit/runner/notification/RunNotifier.java
public void fireTestStarted(final Description description) throws StoppedByUserException { if (fPleaseStop) throw new StoppedByUserException(); new SafeNotifier() { @Override protected void notifyListener(RunListener each) throws Exception { each.testStarted(description); }; }.run(); }
0 1
              
// in main/java/org/junit/runner/notification/RunNotifier.java
public void fireTestStarted(final Description description) throws StoppedByUserException { if (fPleaseStop) throw new StoppedByUserException(); new SafeNotifier() { @Override protected void notifyListener(RunListener each) throws Exception { each.testStarted(description); }; }.run(); }
(Domain) MultipleFailureException 1 0 0
Explicit thrown (throw new...): 54/78
Explicit thrown ratio: 69.2%
Builder thrown ratio: 10.3%
Variable thrown ratio: 20.5%
Checked Runtime Total
Domain 13 3 16
Lib 5 19 24
Total 18 22

Caught Exceptions Summary

A (Domain) exception is defined in the application. A (Lib) exception is defined in the JDK or in a library. An exception can be caught, and it happens that the catch block contains a throw (e.g. for wrapping a low-level exception). Hovering over a number triggers showing code snippets from the application code.

Type Exception Caught
(directly)
Caught
with Thrown
(Lib) Throwable 25
            
// in main/java/junit/framework/TestResult.java
catch (Throwable e) { addError(test, e); }
// in main/java/junit/framework/TestCase.java
catch (Throwable running) { exception= running; }
// in main/java/junit/framework/TestCase.java
catch (Throwable tearingDown) { if (exception == null) exception= tearingDown; }
// in main/java/org/junit/rules/ExpectedException.java
catch (Throwable e) { handleException(e); return; }
// in main/java/org/junit/rules/TestWatcher.java
catch (Throwable t) { failed(t, description); throw t; }
// in main/java/org/junit/rules/TestWatchman.java
catch (Throwable t) { failed(t, method); throw t; }
// in main/java/org/junit/rules/ErrorCollector.java
catch (Throwable e) { addError(e); return null; }
// in main/java/org/junit/experimental/theories/Theories.java
catch (Throwable e) { reportParameterizedError(e, complete .getArgumentStrings(nullsOk())); }
// in main/java/org/junit/experimental/theories/internal/ParameterizedAssertionError.java
catch (Throwable e) { return "[toString failed]"; }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (Throwable e) { throw new CouldNotGenerateValueException(); // do nothing, just look for more values }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (Throwable e) { // ignore and move on }
// in main/java/org/junit/internal/runners/statements/FailOnTimeout.java
catch (Throwable e) { fExceptionThrownByOriginalStatement= e; }
// in main/java/org/junit/internal/runners/statements/RunAfters.java
catch (Throwable e) { errors.add(e); }
// in main/java/org/junit/internal/runners/statements/RunAfters.java
catch (Throwable e) { errors.add(e); }
// in main/java/org/junit/internal/runners/statements/ExpectException.java
catch (Throwable e) { if (!fExpected.isAssignableFrom(e.getClass())) { String message= "Unexpected exception, expected<" + fExpected.getName() + "> but was<" + e.getClass().getName() + ">"; throw new Exception(message, e); } }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Throwable e) { addFailure(e); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Throwable e) { addFailure(e); throw new FailedBefore(); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Throwable e) { addFailure(e); // Untested, but seems impossible }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (Throwable e) { addFailure(e); throw new FailedBefore(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (Throwable e) { addFailure(e); // Untested, but seems impossible }
// in main/java/org/junit/runners/ParentRunner.java
catch (Throwable e) { eachNotifier.addFailure(e); }
// in main/java/org/junit/runners/ParentRunner.java
catch (Throwable e) { testNotifier.addFailure(e); }
// in main/java/org/junit/runners/model/TestClass.java
catch (Throwable e) { throw new RuntimeException( "Exception in " + each.getName(), e); }
// in main/java/org/junit/runners/model/RunnerBuilder.java
catch (Throwable e) { return new ErrorReportingRunner(testClass, e); }
// in main/java/org/junit/runners/BlockJUnit4ClassRunner.java
catch (Throwable e) { return new Fail(e); }
7
            
// in main/java/org/junit/rules/TestWatcher.java
catch (Throwable t) { failed(t, description); throw t; }
// in main/java/org/junit/rules/TestWatchman.java
catch (Throwable t) { failed(t, method); throw t; }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (Throwable e) { throw new CouldNotGenerateValueException(); // do nothing, just look for more values }
// in main/java/org/junit/internal/runners/statements/ExpectException.java
catch (Throwable e) { if (!fExpected.isAssignableFrom(e.getClass())) { String message= "Unexpected exception, expected<" + fExpected.getName() + "> but was<" + e.getClass().getName() + ">"; throw new Exception(message, e); } }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Throwable e) { addFailure(e); throw new FailedBefore(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (Throwable e) { addFailure(e); throw new FailedBefore(); }
// in main/java/org/junit/runners/model/TestClass.java
catch (Throwable e) { throw new RuntimeException( "Exception in " + each.getName(), e); }
(Lib) Exception 14
            
// in main/java/junit/runner/BaseTestRunner.java
catch(Exception e) { runFailed("Error: "+e.toString()); return null; }
// in main/java/junit/runner/BaseTestRunner.java
catch(Exception e) { // try to extract a test suite automatically clearStatus(); return new TestSuite(testClass); }
// in main/java/junit/runner/BaseTestRunner.java
catch (Exception IOException) { return stack; // return the stack unfiltered }
// in main/java/junit/textui/TestRunner.java
catch(Exception e) { }
// in main/java/junit/textui/TestRunner.java
catch(Exception e) { System.err.println(e.getMessage()); System.exit(EXCEPTION_EXIT); }
// in main/java/junit/textui/TestRunner.java
catch (Exception e) { throw new Exception("Could not create and run test suite: " + e); }
// in main/java/org/junit/runner/notification/RunNotifier.java
catch (Exception e) { failures.add(new Failure(Description.TEST_MECHANISM, e)); }
// in main/java/org/junit/experimental/max/MaxHistory.java
catch (Exception e) { throw new CouldNotReadCoreException(e); }
// in main/java/org/junit/experimental/results/FailureList.java
catch (Exception e) { throw new RuntimeException("I can't believe this happened"); }
// in main/java/org/junit/experimental/ParallelComputer.java
catch (Exception e) { e.printStackTrace(); }
// in main/java/org/junit/internal/runners/MethodValidator.java
catch (Exception e) { fErrors.add(new Exception("Test class should have public zero-argument constructor", e)); }
// in main/java/org/junit/internal/runners/JUnit4ClassRunner.java
catch (Exception e) { testAborted(notifier, description, e); return; }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Exception e) { addFailure(e); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Exception e) { throw new RuntimeException("test should never throw an exception to this level"); }
4
            
// in main/java/junit/textui/TestRunner.java
catch (Exception e) { throw new Exception("Could not create and run test suite: " + e); }
// in main/java/org/junit/experimental/max/MaxHistory.java
catch (Exception e) { throw new CouldNotReadCoreException(e); }
// in main/java/org/junit/experimental/results/FailureList.java
catch (Exception e) { throw new RuntimeException("I can't believe this happened"); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Exception e) { throw new RuntimeException("test should never throw an exception to this level"); }
(Lib) InvocationTargetException 11
            
// in main/java/junit/runner/BaseTestRunner.java
catch (InvocationTargetException e) { runFailed("Failed to invoke suite():" + e.getTargetException().toString()); return null; }
// in main/java/junit/framework/TestSuite.java
catch (InvocationTargetException e) { return(warning("Exception in constructor: "+name+" ("+exceptionToString(e.getTargetException())+")")); }
// in main/java/junit/framework/TestCase.java
catch (InvocationTargetException e) { e.fillInStackTrace(); throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/JUnit4ClassRunner.java
catch (InvocationTargetException e) { testAborted(notifier, description, e.getCause()); return; }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (InvocationTargetException e) { Throwable actual= e.getTargetException(); if (actual instanceof AssumptionViolatedException) return; else if (!fTestMethod.expectsException()) addFailure(actual); else if (fTestMethod.isUnexpected(actual)) { String message= "Unexpected exception, expected<" + fTestMethod.getExpectedException().getName() + "> but was<" + actual.getClass().getName() + ">"; addFailure(new Exception(message, actual)); } }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (InvocationTargetException e) { addFailure(e.getTargetException()); }
// in main/java/org/junit/internal/runners/model/ReflectiveCallable.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (InvocationTargetException e) { addFailure(e.getTargetException()); }
// in main/java/org/junit/internal/runners/SuiteMethod.java
catch (InvocationTargetException e) { throw e.getCause(); }
5
            
// in main/java/junit/framework/TestCase.java
catch (InvocationTargetException e) { e.fillInStackTrace(); throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/model/ReflectiveCallable.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/SuiteMethod.java
catch (InvocationTargetException e) { throw e.getCause(); }
(Domain) AssumptionViolatedException 9
            
// in main/java/org/junit/rules/ExpectedException.java
catch (AssumptionViolatedException e) { optionallyHandleException(e, handleAssumptionViolatedExceptions); return; }
// in main/java/org/junit/rules/TestWatcher.java
catch (AssumptionViolatedException e) { throw e; }
// in main/java/org/junit/rules/TestWatchman.java
catch (AssumptionViolatedException e) { throw e; }
// in main/java/org/junit/experimental/theories/Theories.java
catch (AssumptionViolatedException e) { handleAssumptionViolation(e); }
// in main/java/org/junit/internal/runners/statements/ExpectException.java
catch (AssumptionViolatedException e) { throw e; }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (AssumptionViolatedException e) { throw new FailedBefore(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (org.junit.internal.AssumptionViolatedException e) { throw new FailedBefore(); }
// in main/java/org/junit/runners/ParentRunner.java
catch (AssumptionViolatedException e) { eachNotifier.addFailedAssumption(e); }
// in main/java/org/junit/runners/ParentRunner.java
catch (AssumptionViolatedException e) { testNotifier.fireTestIgnored(); }
5
            
// in main/java/org/junit/rules/TestWatcher.java
catch (AssumptionViolatedException e) { throw e; }
// in main/java/org/junit/rules/TestWatchman.java
catch (AssumptionViolatedException e) { throw e; }
// in main/java/org/junit/internal/runners/statements/ExpectException.java
catch (AssumptionViolatedException e) { throw e; }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (AssumptionViolatedException e) { throw new FailedBefore(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (org.junit.internal.AssumptionViolatedException e) { throw new FailedBefore(); }
(Lib) NoSuchMethodException 7
            
// in main/java/junit/framework/TestSuite.java
catch (NoSuchMethodException e) { return warning("Class "+theClass.getName()+" has no public constructor TestCase(String name) or TestCase()"); }
// in main/java/junit/framework/TestSuite.java
catch (NoSuchMethodException e) { // fall through }
// in main/java/junit/framework/TestSuite.java
catch (NoSuchMethodException e) { addTest(warning("Class "+theClass.getName()+" has no public constructor TestCase(String name) or TestCase()")); return; }
// in main/java/junit/framework/TestCase.java
catch (NoSuchMethodException e) { fail("Method \""+fName+"\" not found"); }
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
catch (NoSuchMethodException e) { try { return runnerClass.getConstructor(Class.class, RunnerBuilder.class).newInstance( new Object[] { testClass, fSuiteBuilder }); } catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); } }
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); }
// in main/java/org/junit/internal/builders/SuiteMethodBuilder.java
catch (NoSuchMethodException e) { return false; }
1
            
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
catch (NoSuchMethodException e) { try { return runnerClass.getConstructor(Class.class, RunnerBuilder.class).newInstance( new Object[] { testClass, fSuiteBuilder }); } catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); } }
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); }
(Lib) IllegalAccessException 6
            
// in main/java/junit/runner/BaseTestRunner.java
catch (IllegalAccessException e) { runFailed("Failed to invoke suite():" + e.toString()); return null; }
// in main/java/junit/framework/TestSuite.java
catch (IllegalAccessException e) { return(warning("Cannot access test case: "+name+" ("+exceptionToString(e)+")")); }
// in main/java/junit/framework/TestCase.java
catch (IllegalAccessException e) { e.fillInStackTrace(); throw e; }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getMethods returned an inaccessible method"); }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getFields returned an inaccessible field"); }
// in main/java/org/junit/runners/model/TestClass.java
catch (IllegalAccessException e) { throw new RuntimeException( "How did getFields return a field we couldn't access?", e); }
4
            
// in main/java/junit/framework/TestCase.java
catch (IllegalAccessException e) { e.fillInStackTrace(); throw e; }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getMethods returned an inaccessible method"); }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getFields returned an inaccessible field"); }
// in main/java/org/junit/runners/model/TestClass.java
catch (IllegalAccessException e) { throw new RuntimeException( "How did getFields return a field we couldn't access?", e); }
(Lib) ClassNotFoundException 4
            
// in main/java/junit/runner/BaseTestRunner.java
catch (ClassNotFoundException e) { String clazz= e.getMessage(); if (clazz == null) clazz= suiteClassName; runFailed("Class not found \""+clazz+"\""); return null; }
// in main/java/org/junit/runner/JUnitCore.java
catch (ClassNotFoundException e) { system.out().println("Could not find class: " + each); Description description= Description.createSuiteDescription(each); Failure failure= new Failure(description, e); missingClasses.add(failure); }
// in main/java/org/junit/runner/Description.java
catch (ClassNotFoundException e) { return null; }
// in main/java/org/junit/experimental/max/MaxCore.java
catch (ClassNotFoundException e) { return null; }
0
(Domain) InitializationError 3
            
// in main/java/org/junit/runner/Request.java
catch (InitializationError e) { throw new RuntimeException( "Bug in saff's brain: Suite constructor, called as above, should always complete"); }
// in main/java/org/junit/experimental/max/MaxCore.java
catch (InitializationError e) { return new ErrorReportingRunner(null, e); }
// in main/java/org/junit/runners/Suite.java
catch (InitializationError e) { throw new RuntimeException("This shouldn't be possible"); }
2
            
// in main/java/org/junit/runner/Request.java
catch (InitializationError e) { throw new RuntimeException( "Bug in saff's brain: Suite constructor, called as above, should always complete"); }
// in main/java/org/junit/runners/Suite.java
catch (InitializationError e) { throw new RuntimeException("This shouldn't be possible"); }
(Domain) NoTestsRemainException 3
            
// in main/java/org/junit/experimental/categories/Categories.java
catch (NoTestsRemainException e) { throw new InitializationError(e); }
// in main/java/org/junit/internal/requests/FilterRequest.java
catch (NoTestsRemainException e) { return new ErrorReportingRunner(Filter.class, new Exception(String .format("No tests found matching %s from %s", fFilter .describe(), fRequest.toString()))); }
// in main/java/org/junit/runners/ParentRunner.java
catch (NoTestsRemainException e) { iter.remove(); }
1
            
// in main/java/org/junit/experimental/categories/Categories.java
catch (NoTestsRemainException e) { throw new InitializationError(e); }
(Lib) AssertionError 2
            
// in main/java/org/junit/rules/ExpectedException.java
catch (AssertionError e) { optionallyHandleException(e, handleAssertionErrors); return; }
// in main/java/org/junit/internal/ComparisonCriteria.java
catch (AssertionError e) { throw new ArrayComparisonFailure(header, e, i); }
1
            
// in main/java/org/junit/internal/ComparisonCriteria.java
catch (AssertionError e) { throw new ArrayComparisonFailure(header, e, i); }
(Lib) FailedBefore 2
            
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (FailedBefore e) { }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (FailedBefore e) { }
0
(Lib) IOException 2
            
// in main/java/junit/runner/BaseTestRunner.java
catch (IOException e) { try { if (is != null) is.close(); } catch (IOException e1) { } }
// in main/java/junit/runner/BaseTestRunner.java
catch (IOException e1) { }
// in main/java/junit/runner/BaseTestRunner.java
catch (Exception IOException) { return stack; // return the stack unfiltered }
0
(Lib) IllegalArgumentException 2
            
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: argument length is checked"); }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: field from getClass doesn't exist on object"); }
2
            
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: argument length is checked"); }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: field from getClass doesn't exist on object"); }
(Lib) InterruptedException 2
            
// in main/java/junit/extensions/ActiveTestSuite.java
catch (InterruptedException e) { return; // ignore }
// in main/java/org/junit/internal/runners/statements/FailOnTimeout.java
catch (InterruptedException e) { //don't log the InterruptedException }
0
(Domain) ArrayComparisonFailure 1
            
// in main/java/org/junit/internal/ComparisonCriteria.java
catch (ArrayComparisonFailure e) { e.addDimension(i); throw e; }
1
            
// in main/java/org/junit/internal/ComparisonCriteria.java
catch (ArrayComparisonFailure e) { e.addDimension(i); throw e; }
(Domain) AssertionFailedError 1
            
// in main/java/junit/framework/TestResult.java
catch (AssertionFailedError e) { addFailure(test, e); }
0
(Lib) ClassCastException 1
            
// in main/java/org/junit/runners/Parameterized.java
catch (ClassCastException e) { throw parametersMethodReturnedWrongType(); }
1
            
// in main/java/org/junit/runners/Parameterized.java
catch (ClassCastException e) { throw parametersMethodReturnedWrongType(); }
(Domain) CouldNotGenerateValueException 1
            
// in main/java/org/junit/experimental/theories/Theories.java
catch (CouldNotGenerateValueException e) { // ignore }
0
(Domain) CouldNotReadCoreException 1
            
// in main/java/org/junit/experimental/max/MaxHistory.java
catch (CouldNotReadCoreException e) { e.printStackTrace(); file.delete(); }
0
(Lib) InstantiationException 1
            
// in main/java/junit/framework/TestSuite.java
catch (InstantiationException e) { return(warning("Cannot instantiate test case: "+name+" ("+exceptionToString(e)+")")); }
0
(Lib) NumberFormatException 1
            
// in main/java/junit/runner/BaseTestRunner.java
catch (NumberFormatException ne) { }
0
(Domain) StoppedByUserException 1
            
// in main/java/org/junit/runners/ParentRunner.java
catch (StoppedByUserException e) { throw e; }
1
            
// in main/java/org/junit/runners/ParentRunner.java
catch (StoppedByUserException e) { throw e; }
(Lib) ThreadDeath 1
            
// in main/java/junit/framework/TestResult.java
catch (ThreadDeath e) { // don't catch ThreadDeath by accident throw e; }
1
            
// in main/java/junit/framework/TestResult.java
catch (ThreadDeath e) { // don't catch ThreadDeath by accident throw e; }
(Lib) TimeoutException 1
            
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (TimeoutException e) { addFailure(new Exception(String.format("test timed out after %d milliseconds", timeout))); }
0

Exception Recast Summary

There is a common practice of throwing exceptions from within a catch block (e.g. for wrapping a low-level exception). The following table summarizes the usage of this practice in the application. The last column gives the number of times it happens for a pair of exceptions. The graph below the table graphically renders the same information. For a given node, its color represents its origin (blue means library exception, orange means domain exception); the left-most number is the number of times it is thrown, the right-most is the number of times it is caught.

Catch Throw
(Lib) Exception
(Lib) Exception
(Domain) CouldNotReadCoreException
(Lib) RuntimeException
1
                    
// in main/java/junit/textui/TestRunner.java
catch (Exception e) { throw new Exception("Could not create and run test suite: " + e); }
1
                    
// in main/java/org/junit/experimental/max/MaxHistory.java
catch (Exception e) { throw new CouldNotReadCoreException(e); }
2
                    
// in main/java/org/junit/experimental/results/FailureList.java
catch (Exception e) { throw new RuntimeException("I can't believe this happened"); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Exception e) { throw new RuntimeException("test should never throw an exception to this level"); }
(Domain) NoTestsRemainException
(Domain) InitializationError
1
                    
// in main/java/org/junit/experimental/categories/Categories.java
catch (NoTestsRemainException e) { throw new InitializationError(e); }
(Domain) InitializationError
(Lib) RuntimeException
2
                    
// in main/java/org/junit/runner/Request.java
catch (InitializationError e) { throw new RuntimeException( "Bug in saff's brain: Suite constructor, called as above, should always complete"); }
// in main/java/org/junit/runners/Suite.java
catch (InitializationError e) { throw new RuntimeException("This shouldn't be possible"); }
(Lib) InvocationTargetException
Unknown
5
                    
// in main/java/junit/framework/TestCase.java
catch (InvocationTargetException e) { e.fillInStackTrace(); throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/model/ReflectiveCallable.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/SuiteMethod.java
catch (InvocationTargetException e) { throw e.getCause(); }
(Lib) IllegalAccessException
(Lib) RuntimeException
Unknown
3
                    
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getMethods returned an inaccessible method"); }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getFields returned an inaccessible field"); }
// in main/java/org/junit/runners/model/TestClass.java
catch (IllegalAccessException e) { throw new RuntimeException( "How did getFields return a field we couldn't access?", e); }
1
                    
// in main/java/junit/framework/TestCase.java
catch (IllegalAccessException e) { e.fillInStackTrace(); throw e; }
(Domain) StoppedByUserException
Unknown
1
                    
// in main/java/org/junit/runners/ParentRunner.java
catch (StoppedByUserException e) { throw e; }
(Domain) AssumptionViolatedException
(Lib) FailedBefore
Unknown
2
                    
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (AssumptionViolatedException e) { throw new FailedBefore(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (org.junit.internal.AssumptionViolatedException e) { throw new FailedBefore(); }
3
                    
// in main/java/org/junit/rules/TestWatcher.java
catch (AssumptionViolatedException e) { throw e; }
// in main/java/org/junit/rules/TestWatchman.java
catch (AssumptionViolatedException e) { throw e; }
// in main/java/org/junit/internal/runners/statements/ExpectException.java
catch (AssumptionViolatedException e) { throw e; }
(Lib) ThreadDeath
Unknown
1
                    
// in main/java/junit/framework/TestResult.java
catch (ThreadDeath e) { // don't catch ThreadDeath by accident throw e; }
(Lib) Throwable
(Domain) CouldNotGenerateValueException
(Lib) Exception
(Lib) FailedBefore
(Lib) RuntimeException
Unknown
1
                    
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (Throwable e) { throw new CouldNotGenerateValueException(); // do nothing, just look for more values }
1
                    
// in main/java/org/junit/internal/runners/statements/ExpectException.java
catch (Throwable e) { if (!fExpected.isAssignableFrom(e.getClass())) { String message= "Unexpected exception, expected<" + fExpected.getName() + "> but was<" + e.getClass().getName() + ">"; throw new Exception(message, e); } }
2
                    
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Throwable e) { addFailure(e); throw new FailedBefore(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (Throwable e) { addFailure(e); throw new FailedBefore(); }
1
                    
// in main/java/org/junit/runners/model/TestClass.java
catch (Throwable e) { throw new RuntimeException( "Exception in " + each.getName(), e); }
2
                    
// in main/java/org/junit/rules/TestWatcher.java
catch (Throwable t) { failed(t, description); throw t; }
// in main/java/org/junit/rules/TestWatchman.java
catch (Throwable t) { failed(t, method); throw t; }
(Lib) NoSuchMethodException
(Domain) InitializationError
1
                    
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
catch (NoSuchMethodException e) { try { return runnerClass.getConstructor(Class.class, RunnerBuilder.class).newInstance( new Object[] { testClass, fSuiteBuilder }); } catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); } }
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); }
(Lib) IllegalArgumentException
(Lib) RuntimeException
2
                    
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: argument length is checked"); }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: field from getClass doesn't exist on object"); }
(Lib) AssertionError
(Domain) ArrayComparisonFailure
1
                    
// in main/java/org/junit/internal/ComparisonCriteria.java
catch (AssertionError e) { throw new ArrayComparisonFailure(header, e, i); }
(Domain) ArrayComparisonFailure
Unknown
1
                    
// in main/java/org/junit/internal/ComparisonCriteria.java
catch (ArrayComparisonFailure e) { e.addDimension(i); throw e; }
(Lib) ClassCastException
Unknown
1
                    
// in main/java/org/junit/runners/Parameterized.java
catch (ClassCastException e) { throw parametersMethodReturnedWrongType(); }

Caught / Thrown Exception

Not all exceptions are thrown AND caught in the same project. The following table gives the exceptions types with respect to this. The lower left hand side sell lists all exceptions thrown but not caught (prevalent for libraries), the upper right-hand side lists all exceptions caught but not thrown (usually coming from external dependencies).

Thrown Not Thrown
Caught
Type Name
(Lib) Exception
(Domain) NoTestsRemainException
(Domain) CouldNotReadCoreException
(Domain) CouldNotGenerateValueException
(Domain) InitializationError
(Domain) StoppedByUserException
(Domain) AssumptionViolatedException
(Domain) AssertionFailedError
(Lib) IllegalArgumentException
(Lib) AssertionError
(Domain) ArrayComparisonFailure
(Lib) FailedBefore
Type Name
(Lib) ClassNotFoundException
(Lib) InvocationTargetException
(Lib) IllegalAccessException
(Lib) IOException
(Lib) NumberFormatException
(Lib) ThreadDeath
(Lib) Throwable
(Lib) NoSuchMethodException
(Lib) InstantiationException
(Lib) InterruptedException
(Lib) TimeoutException
(Lib) ClassCastException
Not caught
Type Name
(Lib) RuntimeException
(Domain) ComparisonFailure
(Lib) IllegalStateException
(Domain) ParameterizedAssertionError
(Lib) Error
(Domain) MultipleFailureException

Methods called in Catch and Finally Blocks

The following shows the methods that are called inside catch blocks (first column) and finally blocks (second column). For each method, we give the number of times it is called in a catch block (second sub-column), and the total number of calls (third sub-column). If the method name is red, it means that it is only called from catch/finally blocks. Hovering over a number triggers showing code snippets from the application code.

Catch Finally
Method Nbr Nbr total
addFailure 14
                  
// in main/java/junit/framework/TestResult.java
catch (AssertionFailedError e) { addFailure(test, e); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (TimeoutException e) { addFailure(new Exception(String.format("test timed out after %d milliseconds", timeout))); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Exception e) { addFailure(e); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (InvocationTargetException e) { Throwable actual= e.getTargetException(); if (actual instanceof AssumptionViolatedException) return; else if (!fTestMethod.expectsException()) addFailure(actual); else if (fTestMethod.isUnexpected(actual)) { String message= "Unexpected exception, expected<" + fTestMethod.getExpectedException().getName() + "> but was<" + actual.getClass().getName() + ">"; addFailure(new Exception(message, actual)); } }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Throwable e) { addFailure(e); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Throwable e) { addFailure(e); throw new FailedBefore(); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (InvocationTargetException e) { addFailure(e.getTargetException()); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Throwable e) { addFailure(e); // Untested, but seems impossible }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (Throwable e) { addFailure(e); throw new FailedBefore(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (InvocationTargetException e) { addFailure(e.getTargetException()); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (Throwable e) { addFailure(e); // Untested, but seems impossible }
// in main/java/org/junit/runners/ParentRunner.java
catch (Throwable e) { eachNotifier.addFailure(e); }
// in main/java/org/junit/runners/ParentRunner.java
catch (Throwable e) { testNotifier.addFailure(e); }
17
getTargetException
9
                  
// in main/java/junit/runner/BaseTestRunner.java
catch (InvocationTargetException e) { runFailed("Failed to invoke suite():" + e.getTargetException().toString()); return null; }
// in main/java/junit/framework/TestSuite.java
catch (InvocationTargetException e) { return(warning("Exception in constructor: "+name+" ("+exceptionToString(e.getTargetException())+")")); }
// in main/java/junit/framework/TestCase.java
catch (InvocationTargetException e) { e.fillInStackTrace(); throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (InvocationTargetException e) { Throwable actual= e.getTargetException(); if (actual instanceof AssumptionViolatedException) return; else if (!fTestMethod.expectsException()) addFailure(actual); else if (fTestMethod.isUnexpected(actual)) { String message= "Unexpected exception, expected<" + fTestMethod.getExpectedException().getName() + "> but was<" + actual.getClass().getName() + ">"; addFailure(new Exception(message, actual)); } }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (InvocationTargetException e) { addFailure(e.getTargetException()); }
// in main/java/org/junit/internal/runners/model/ReflectiveCallable.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (InvocationTargetException e) { addFailure(e.getTargetException()); }
9
getName 7
                  
// in main/java/junit/framework/TestSuite.java
catch (NoSuchMethodException e) { return warning("Class "+theClass.getName()+" has no public constructor TestCase(String name) or TestCase()"); }
// in main/java/junit/framework/TestSuite.java
catch (NoSuchMethodException e) { addTest(warning("Class "+theClass.getName()+" has no public constructor TestCase(String name) or TestCase()")); return; }
// in main/java/org/junit/internal/runners/statements/ExpectException.java
catch (Throwable e) { if (!fExpected.isAssignableFrom(e.getClass())) { String message= "Unexpected exception, expected<" + fExpected.getName() + "> but was<" + e.getClass().getName() + ">"; throw new Exception(message, e); } }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (InvocationTargetException e) { Throwable actual= e.getTargetException(); if (actual instanceof AssumptionViolatedException) return; else if (!fTestMethod.expectsException()) addFailure(actual); else if (fTestMethod.isUnexpected(actual)) { String message= "Unexpected exception, expected<" + fTestMethod.getExpectedException().getName() + "> but was<" + actual.getClass().getName() + ">"; addFailure(new Exception(message, actual)); } }
// in main/java/org/junit/runners/model/TestClass.java
catch (Throwable e) { throw new RuntimeException( "Exception in " + each.getName(), e); }
78
add 5
                  
// in main/java/org/junit/runner/notification/RunNotifier.java
catch (Exception e) { failures.add(new Failure(Description.TEST_MECHANISM, e)); }
// in main/java/org/junit/runner/JUnitCore.java
catch (ClassNotFoundException e) { system.out().println("Could not find class: " + each); Description description= Description.createSuiteDescription(each); Failure failure= new Failure(description, e); missingClasses.add(failure); }
// in main/java/org/junit/internal/runners/MethodValidator.java
catch (Exception e) { fErrors.add(new Exception("Test class should have public zero-argument constructor", e)); }
// in main/java/org/junit/internal/runners/statements/RunAfters.java
catch (Throwable e) { errors.add(e); }
// in main/java/org/junit/internal/runners/statements/RunAfters.java
catch (Throwable e) { errors.add(e); }
62
warning 5
                  
// in main/java/junit/framework/TestSuite.java
catch (NoSuchMethodException e) { return warning("Class "+theClass.getName()+" has no public constructor TestCase(String name) or TestCase()"); }
// in main/java/junit/framework/TestSuite.java
catch (InstantiationException e) { return(warning("Cannot instantiate test case: "+name+" ("+exceptionToString(e)+")")); }
// in main/java/junit/framework/TestSuite.java
catch (InvocationTargetException e) { return(warning("Exception in constructor: "+name+" ("+exceptionToString(e.getTargetException())+")")); }
// in main/java/junit/framework/TestSuite.java
catch (IllegalAccessException e) { return(warning("Cannot access test case: "+name+" ("+exceptionToString(e)+")")); }
// in main/java/junit/framework/TestSuite.java
catch (NoSuchMethodException e) { addTest(warning("Class "+theClass.getName()+" has no public constructor TestCase(String name) or TestCase()")); return; }
9
runFailed 4
                  
// in main/java/junit/runner/BaseTestRunner.java
catch (ClassNotFoundException e) { String clazz= e.getMessage(); if (clazz == null) clazz= suiteClassName; runFailed("Class not found \""+clazz+"\""); return null; }
// in main/java/junit/runner/BaseTestRunner.java
catch(Exception e) { runFailed("Error: "+e.toString()); return null; }
// in main/java/junit/runner/BaseTestRunner.java
catch (InvocationTargetException e) { runFailed("Failed to invoke suite():" + e.getTargetException().toString()); return null; }
// in main/java/junit/runner/BaseTestRunner.java
catch (IllegalAccessException e) { runFailed("Failed to invoke suite():" + e.toString()); return null; }
5
toString 4
                  
// in main/java/junit/runner/BaseTestRunner.java
catch(Exception e) { runFailed("Error: "+e.toString()); return null; }
// in main/java/junit/runner/BaseTestRunner.java
catch (InvocationTargetException e) { runFailed("Failed to invoke suite():" + e.getTargetException().toString()); return null; }
// in main/java/junit/runner/BaseTestRunner.java
catch (IllegalAccessException e) { runFailed("Failed to invoke suite():" + e.toString()); return null; }
// in main/java/org/junit/internal/requests/FilterRequest.java
catch (NoTestsRemainException e) { return new ErrorReportingRunner(Filter.class, new Exception(String .format("No tests found matching %s from %s", fFilter .describe(), fRequest.toString()))); }
43
ErrorReportingRunner 3
                  
// in main/java/org/junit/experimental/max/MaxCore.java
catch (InitializationError e) { return new ErrorReportingRunner(null, e); }
// in main/java/org/junit/internal/requests/FilterRequest.java
catch (NoTestsRemainException e) { return new ErrorReportingRunner(Filter.class, new Exception(String .format("No tests found matching %s from %s", fFilter .describe(), fRequest.toString()))); }
// in main/java/org/junit/runners/model/RunnerBuilder.java
catch (Throwable e) { return new ErrorReportingRunner(testClass, e); }
4
exceptionToString
3
                  
// in main/java/junit/framework/TestSuite.java
catch (InstantiationException e) { return(warning("Cannot instantiate test case: "+name+" ("+exceptionToString(e)+")")); }
// in main/java/junit/framework/TestSuite.java
catch (InvocationTargetException e) { return(warning("Exception in constructor: "+name+" ("+exceptionToString(e.getTargetException())+")")); }
// in main/java/junit/framework/TestSuite.java
catch (IllegalAccessException e) { return(warning("Cannot access test case: "+name+" ("+exceptionToString(e)+")")); }
3
format 3
                  
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (TimeoutException e) { addFailure(new Exception(String.format("test timed out after %d milliseconds", timeout))); }
// in main/java/org/junit/internal/requests/FilterRequest.java
catch (NoTestsRemainException e) { return new ErrorReportingRunner(Filter.class, new Exception(String .format("No tests found matching %s from %s", fFilter .describe(), fRequest.toString()))); }
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
catch (NoSuchMethodException e) { try { return runnerClass.getConstructor(Class.class, RunnerBuilder.class).newInstance( new Object[] { testClass, fSuiteBuilder }); } catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); } }
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); }
25
getClass 3
                  
// in main/java/org/junit/internal/runners/statements/ExpectException.java
catch (Throwable e) { if (!fExpected.isAssignableFrom(e.getClass())) { String message= "Unexpected exception, expected<" + fExpected.getName() + "> but was<" + e.getClass().getName() + ">"; throw new Exception(message, e); } }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (InvocationTargetException e) { Throwable actual= e.getTargetException(); if (actual instanceof AssumptionViolatedException) return; else if (!fTestMethod.expectsException()) addFailure(actual); else if (fTestMethod.isUnexpected(actual)) { String message= "Unexpected exception, expected<" + fTestMethod.getExpectedException().getName() + "> but was<" + actual.getClass().getName() + ">"; addFailure(new Exception(message, actual)); } }
14
Failure 2
                  
// in main/java/org/junit/runner/notification/RunNotifier.java
catch (Exception e) { failures.add(new Failure(Description.TEST_MECHANISM, e)); }
// in main/java/org/junit/runner/JUnitCore.java
catch (ClassNotFoundException e) { system.out().println("Could not find class: " + each); Description description= Description.createSuiteDescription(each); Failure failure= new Failure(description, e); missingClasses.add(failure); }
9
addError 2
                  
// in main/java/junit/framework/TestResult.java
catch (Throwable e) { addError(test, e); }
// in main/java/org/junit/rules/ErrorCollector.java
catch (Throwable e) { addError(e); return null; }
9
failed
2
                  
// in main/java/org/junit/rules/TestWatcher.java
catch (Throwable t) { failed(t, description); throw t; }
// in main/java/org/junit/rules/TestWatchman.java
catch (Throwable t) { failed(t, method); throw t; }
2
fillInStackTrace
2
                  
// in main/java/junit/framework/TestCase.java
catch (InvocationTargetException e) { e.fillInStackTrace(); throw e.getTargetException(); }
// in main/java/junit/framework/TestCase.java
catch (IllegalAccessException e) { e.fillInStackTrace(); throw e; }
2
getCause 2
                  
// in main/java/org/junit/internal/runners/JUnit4ClassRunner.java
catch (InvocationTargetException e) { testAborted(notifier, description, e.getCause()); return; }
// in main/java/org/junit/internal/runners/SuiteMethod.java
catch (InvocationTargetException e) { throw e.getCause(); }
3
getMessage 2
                  
// in main/java/junit/runner/BaseTestRunner.java
catch (ClassNotFoundException e) { String clazz= e.getMessage(); if (clazz == null) clazz= suiteClassName; runFailed("Class not found \""+clazz+"\""); return null; }
// in main/java/junit/textui/TestRunner.java
catch(Exception e) { System.err.println(e.getMessage()); System.exit(EXCEPTION_EXIT); }
12
optionallyHandleException
2
                  
// in main/java/org/junit/rules/ExpectedException.java
catch (AssumptionViolatedException e) { optionallyHandleException(e, handleAssumptionViolatedExceptions); return; }
// in main/java/org/junit/rules/ExpectedException.java
catch (AssertionError e) { optionallyHandleException(e, handleAssertionErrors); return; }
2
printStackTrace 2
                  
// in main/java/org/junit/experimental/max/MaxHistory.java
catch (CouldNotReadCoreException e) { e.printStackTrace(); file.delete(); }
// in main/java/org/junit/experimental/ParallelComputer.java
catch (Exception e) { e.printStackTrace(); }
6
println 2
                  
// in main/java/junit/textui/TestRunner.java
catch(Exception e) { System.err.println(e.getMessage()); System.exit(EXCEPTION_EXIT); }
// in main/java/org/junit/runner/JUnitCore.java
catch (ClassNotFoundException e) { system.out().println("Could not find class: " + each); Description description= Description.createSuiteDescription(each); Failure failure= new Failure(description, e); missingClasses.add(failure); }
32
testAborted
2
                  
// in main/java/org/junit/internal/runners/JUnit4ClassRunner.java
catch (InvocationTargetException e) { testAborted(notifier, description, e.getCause()); return; }
// in main/java/org/junit/internal/runners/JUnit4ClassRunner.java
catch (Exception e) { testAborted(notifier, description, e); return; }
2
Fail
1
                  
// in main/java/org/junit/runners/BlockJUnit4ClassRunner.java
catch (Throwable e) { return new Fail(e); }
1
TestSuite 1
                  
// in main/java/junit/runner/BaseTestRunner.java
catch(Exception e) { // try to extract a test suite automatically clearStatus(); return new TestSuite(testClass); }
9
addDimension 1
                  
// in main/java/org/junit/internal/ComparisonCriteria.java
catch (ArrayComparisonFailure e) { e.addDimension(i); throw e; }
2
addFailedAssumption
1
                  
// in main/java/org/junit/runners/ParentRunner.java
catch (AssumptionViolatedException e) { eachNotifier.addFailedAssumption(e); }
1
addTest 1
                  
// in main/java/junit/framework/TestSuite.java
catch (NoSuchMethodException e) { addTest(warning("Class "+theClass.getName()+" has no public constructor TestCase(String name) or TestCase()")); return; }
9
clearStatus 1
                  
// in main/java/junit/runner/BaseTestRunner.java
catch(Exception e) { // try to extract a test suite automatically clearStatus(); return new TestSuite(testClass); }
3
close 1
                  
// in main/java/junit/runner/BaseTestRunner.java
catch (IOException e) { try { if (is != null) is.close(); } catch (IOException e1) { } }
5
createSuiteDescription 1
                  
// in main/java/org/junit/runner/JUnitCore.java
catch (ClassNotFoundException e) { system.out().println("Could not find class: " + each); Description description= Description.createSuiteDescription(each); Failure failure= new Failure(description, e); missingClasses.add(failure); }
10
delete 1
                  
// in main/java/org/junit/experimental/max/MaxHistory.java
catch (CouldNotReadCoreException e) { e.printStackTrace(); file.delete(); }
4
describe 1
                  
// in main/java/org/junit/internal/requests/FilterRequest.java
catch (NoTestsRemainException e) { return new ErrorReportingRunner(Filter.class, new Exception(String .format("No tests found matching %s from %s", fFilter .describe(), fRequest.toString()))); }
3
exit 1
                  
// in main/java/junit/textui/TestRunner.java
catch(Exception e) { System.err.println(e.getMessage()); System.exit(EXCEPTION_EXIT); }
5
expectsException 1
                  
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (InvocationTargetException e) { Throwable actual= e.getTargetException(); if (actual instanceof AssumptionViolatedException) return; else if (!fTestMethod.expectsException()) addFailure(actual); else if (fTestMethod.isUnexpected(actual)) { String message= "Unexpected exception, expected<" + fTestMethod.getExpectedException().getName() + "> but was<" + actual.getClass().getName() + ">"; addFailure(new Exception(message, actual)); } }
3
fail 1
                  
// in main/java/junit/framework/TestCase.java
catch (NoSuchMethodException e) { fail("Method \""+fName+"\" not found"); }
20
fireTestIgnored 1
                  
// in main/java/org/junit/runners/ParentRunner.java
catch (AssumptionViolatedException e) { testNotifier.fireTestIgnored(); }
5
getArgumentStrings
1
                  
// in main/java/org/junit/experimental/theories/Theories.java
catch (Throwable e) { reportParameterizedError(e, complete .getArgumentStrings(nullsOk())); }
1
getConstructor 1
                  
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
catch (NoSuchMethodException e) { try { return runnerClass.getConstructor(Class.class, RunnerBuilder.class).newInstance( new Object[] { testClass, fSuiteBuilder }); } catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); } }
7
getExpectedException 1
                  
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (InvocationTargetException e) { Throwable actual= e.getTargetException(); if (actual instanceof AssumptionViolatedException) return; else if (!fTestMethod.expectsException()) addFailure(actual); else if (fTestMethod.isUnexpected(actual)) { String message= "Unexpected exception, expected<" + fTestMethod.getExpectedException().getName() + "> but was<" + actual.getClass().getName() + ">"; addFailure(new Exception(message, actual)); } }
6
getSimpleName 1
                  
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
catch (NoSuchMethodException e) { try { return runnerClass.getConstructor(Class.class, RunnerBuilder.class).newInstance( new Object[] { testClass, fSuiteBuilder }); } catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); } }
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); }
2
handleAssumptionViolation
1
                  
// in main/java/org/junit/experimental/theories/Theories.java
catch (AssumptionViolatedException e) { handleAssumptionViolation(e); }
1
handleException 1
                  
// in main/java/org/junit/rules/ExpectedException.java
catch (Throwable e) { handleException(e); return; }
2
isAssignableFrom 1
                  
// in main/java/org/junit/internal/runners/statements/ExpectException.java
catch (Throwable e) { if (!fExpected.isAssignableFrom(e.getClass())) { String message= "Unexpected exception, expected<" + fExpected.getName() + "> but was<" + e.getClass().getName() + ">"; throw new Exception(message, e); } }
11
isUnexpected
1
                  
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (InvocationTargetException e) { Throwable actual= e.getTargetException(); if (actual instanceof AssumptionViolatedException) return; else if (!fTestMethod.expectsException()) addFailure(actual); else if (fTestMethod.isUnexpected(actual)) { String message= "Unexpected exception, expected<" + fTestMethod.getExpectedException().getName() + "> but was<" + actual.getClass().getName() + ">"; addFailure(new Exception(message, actual)); } }
1
newInstance 1
                  
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
catch (NoSuchMethodException e) { try { return runnerClass.getConstructor(Class.class, RunnerBuilder.class).newInstance( new Object[] { testClass, fSuiteBuilder }); } catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); } }
9
nullsOk 1
                  
// in main/java/org/junit/experimental/theories/Theories.java
catch (Throwable e) { reportParameterizedError(e, complete .getArgumentStrings(nullsOk())); }
3
out 1
                  
// in main/java/org/junit/runner/JUnitCore.java
catch (ClassNotFoundException e) { system.out().println("Could not find class: " + each); Description description= Description.createSuiteDescription(each); Failure failure= new Failure(description, e); missingClasses.add(failure); }
5
parametersMethodReturnedWrongType 1
                  
// in main/java/org/junit/runners/Parameterized.java
catch (ClassCastException e) { throw parametersMethodReturnedWrongType(); }
2
remove 1
                  
// in main/java/org/junit/runners/ParentRunner.java
catch (NoTestsRemainException e) { iter.remove(); }
6
reportParameterizedError
1
                  
// in main/java/org/junit/experimental/theories/Theories.java
catch (Throwable e) { reportParameterizedError(e, complete .getArgumentStrings(nullsOk())); }
1
Method Nbr Nbr total
close 3
                  
// in main/java/junit/runner/BaseTestRunner.java
finally { fos.close(); }
// in main/java/org/junit/experimental/max/MaxHistory.java
finally { stream.close(); }
// in main/java/org/junit/experimental/max/MaxHistory.java
finally { file.close(); }
5
finished 2
                  
// in main/java/org/junit/rules/TestWatcher.java
finally { finished(description); }
// in main/java/org/junit/rules/TestWatchman.java
finally { finished(method); }
3
fireTestFinished 2
                  
// in main/java/org/junit/internal/runners/MethodRoadie.java
finally { fNotifier.fireTestFinished(fDescription); }
// in main/java/org/junit/runners/ParentRunner.java
finally { eachNotifier.fireTestFinished(); }
6
runAfters
2
                  
// in main/java/org/junit/internal/runners/MethodRoadie.java
finally { runAfters(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
finally { runAfters(); }
2
add 1
                  
// in main/java/org/junit/internal/runners/statements/RunAfters.java
finally { for (FrameworkMethod each : fAfters) try { each.invokeExplosively(fTarget); } catch (Throwable e) { errors.add(e); } }
62
after 1
                  
// in main/java/org/junit/rules/ExternalResource.java
finally { after(); }
3
invokeExplosively 1
                  
// in main/java/org/junit/internal/runners/statements/RunAfters.java
finally { for (FrameworkMethod each : fAfters) try { each.invokeExplosively(fTarget); } catch (Throwable e) { errors.add(e); } }
8
removeListener 1
                  
// in main/java/org/junit/runner/JUnitCore.java
finally { removeListener(listener); }
2
removeParent
1
                  
// in main/java/org/junit/runners/model/RunnerBuilder.java
finally { removeParent(parent); }
1
runFinished
1
                  
// in main/java/junit/extensions/ActiveTestSuite.java
finally { ActiveTestSuite.this.runFinished(); }
1
tearDown 1
                  
// in main/java/junit/framework/TestCase.java
finally { try { tearDown(); } catch (Throwable tearingDown) { if (exception == null) exception= tearingDown; } }
2

Reference Table

This table concatenates the results of the previous tables.

Checked/Runtime Type Exception Thrown Thrown from Catch Declared Caught directly Caught
with Thrown
Caught
with Thrown Runtime
unknown (Lib) . 0 0 0 0 0 0
unknown (Domain) ArrayComparisonFailure
public class ArrayComparisonFailure extends AssertionError {

	private static final long serialVersionUID= 1L;
	
	private List<Integer> fIndices= new ArrayList<Integer>();
	private final String fMessage;
	private final AssertionError fCause;

	/**
	 * Construct a new <code>ArrayComparisonFailure</code> with an error text and the array's
	 * dimension that was not equal
	 * @param cause the exception that caused the array's content to fail the assertion test 
	 * @param index the array position of the objects that are not equal.
	 * @see Assert#assertArrayEquals(String, Object[], Object[])
	 */
	public ArrayComparisonFailure(String message, AssertionError cause, int index) {
		fMessage= message;
		fCause= cause;
		addDimension(index);
	}

	public void addDimension(int index) {
		fIndices.add(0, index);
	}

	@Override
	public String getMessage() {
		StringBuilder builder= new StringBuilder();
		if (fMessage != null)
			builder.append(fMessage);
		builder.append("arrays first differed at element ");
		for (int each : fIndices) {
			builder.append("[");
			builder.append(each);
			builder.append("]");
		}
		builder.append("; ");
		builder.append(fCause.getMessage());
		return builder.toString();
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override public String toString() {
		return getMessage();
	}
}
1
            
// in main/java/org/junit/internal/ComparisonCriteria.java
public void arrayEquals(String message, Object expecteds, Object actuals) throws ArrayComparisonFailure { if (expecteds == actuals) return; String header= message == null ? "" : message + ": "; int expectedsLength= assertArraysAreSameLength(expecteds, actuals, header); for (int i= 0; i < expectedsLength; i++) { Object expected= Array.get(expecteds, i); Object actual= Array.get(actuals, i); if (isArray(expected) && isArray(actual)) { try { arrayEquals(message, expected, actual); } catch (ArrayComparisonFailure e) { e.addDimension(i); throw e; } } else try { assertElementsEqual(expected, actual); } catch (AssertionError e) { throw new ArrayComparisonFailure(header, e, i); } } }
1
            
// in main/java/org/junit/internal/ComparisonCriteria.java
catch (AssertionError e) { throw new ArrayComparisonFailure(header, e, i); }
10
            
// in main/java/org/junit/internal/ComparisonCriteria.java
public void arrayEquals(String message, Object expecteds, Object actuals) throws ArrayComparisonFailure { if (expecteds == actuals) return; String header= message == null ? "" : message + ": "; int expectedsLength= assertArraysAreSameLength(expecteds, actuals, header); for (int i= 0; i < expectedsLength; i++) { Object expected= Array.get(expecteds, i); Object actual= Array.get(actuals, i); if (isArray(expected) && isArray(actual)) { try { arrayEquals(message, expected, actual); } catch (ArrayComparisonFailure e) { e.addDimension(i); throw e; } } else try { assertElementsEqual(expected, actual); } catch (AssertionError e) { throw new ArrayComparisonFailure(header, e, i); } } }
// in main/java/org/junit/Assert.java
public static void assertArrayEquals(String message, Object[] expecteds, Object[] actuals) throws ArrayComparisonFailure { internalArrayEquals(message, expecteds, actuals); }
// in main/java/org/junit/Assert.java
public static void assertArrayEquals(String message, byte[] expecteds, byte[] actuals) throws ArrayComparisonFailure { internalArrayEquals(message, expecteds, actuals); }
// in main/java/org/junit/Assert.java
public static void assertArrayEquals(String message, char[] expecteds, char[] actuals) throws ArrayComparisonFailure { internalArrayEquals(message, expecteds, actuals); }
// in main/java/org/junit/Assert.java
public static void assertArrayEquals(String message, short[] expecteds, short[] actuals) throws ArrayComparisonFailure { internalArrayEquals(message, expecteds, actuals); }
// in main/java/org/junit/Assert.java
public static void assertArrayEquals(String message, int[] expecteds, int[] actuals) throws ArrayComparisonFailure { internalArrayEquals(message, expecteds, actuals); }
// in main/java/org/junit/Assert.java
public static void assertArrayEquals(String message, long[] expecteds, long[] actuals) throws ArrayComparisonFailure { internalArrayEquals(message, expecteds, actuals); }
// in main/java/org/junit/Assert.java
public static void assertArrayEquals(String message, double[] expecteds, double[] actuals, double delta) throws ArrayComparisonFailure { new InexactComparisonCriteria(delta).arrayEquals(message, expecteds, actuals); }
// in main/java/org/junit/Assert.java
public static void assertArrayEquals(String message, float[] expecteds, float[] actuals, float delta) throws ArrayComparisonFailure { new InexactComparisonCriteria(delta).arrayEquals(message, expecteds, actuals); }
// in main/java/org/junit/Assert.java
private static void internalArrayEquals(String message, Object expecteds, Object actuals) throws ArrayComparisonFailure { new ExactComparisonCriteria().arrayEquals(message, expecteds, actuals); }
1
            
// in main/java/org/junit/internal/ComparisonCriteria.java
catch (ArrayComparisonFailure e) { e.addDimension(i); throw e; }
1
            
// in main/java/org/junit/internal/ComparisonCriteria.java
catch (ArrayComparisonFailure e) { e.addDimension(i); throw e; }
0
unknown (Lib) AssertionError 5
            
// in main/java/org/junit/rules/ExpectedException.java
Override public void evaluate() throws Throwable { try { fNext.evaluate(); } catch (AssumptionViolatedException e) { optionallyHandleException(e, handleAssumptionViolatedExceptions); return; } catch (AssertionError e) { optionallyHandleException(e, handleAssertionErrors); return; } catch (Throwable e) { handleException(e); return; } if (fMatcher != null) throw new AssertionError("Expected test to throw " + StringDescription.toString(fMatcher)); }
// in main/java/org/junit/internal/runners/statements/ExpectException.java
Override public void evaluate() throws Exception { boolean complete = false; try { fNext.evaluate(); complete = true; } catch (AssumptionViolatedException e) { throw e; } catch (Throwable e) { if (!fExpected.isAssignableFrom(e.getClass())) { String message= "Unexpected exception, expected<" + fExpected.getName() + "> but was<" + e.getClass().getName() + ">"; throw new Exception(message, e); } } if (complete) throw new AssertionError("Expected exception: " + fExpected.getName()); }
// in main/java/org/junit/Assert.java
static public void fail(String message) { if (message == null) throw new AssertionError(); throw new AssertionError(message); }
// in main/java/org/junit/Assert.java
public static <T> void assertThat(String reason, T actual, Matcher<? super T> matcher) { if (!matcher.matches(actual)) { Description description= new StringDescription(); description.appendText(reason); description.appendText("\nExpected: "); description.appendDescriptionOf(matcher); description.appendText("\n got: "); description.appendValue(actual); description.appendText("\n"); throw new java.lang.AssertionError(description.toString()); } }
0 0 2
            
// in main/java/org/junit/rules/ExpectedException.java
catch (AssertionError e) { optionallyHandleException(e, handleAssertionErrors); return; }
// in main/java/org/junit/internal/ComparisonCriteria.java
catch (AssertionError e) { throw new ArrayComparisonFailure(header, e, i); }
1
            
// in main/java/org/junit/internal/ComparisonCriteria.java
catch (AssertionError e) { throw new ArrayComparisonFailure(header, e, i); }
0
unknown (Domain) AssertionFailedError
public class AssertionFailedError extends AssertionError {

	private static final long serialVersionUID= 1L;

	public AssertionFailedError() {
	}

	public AssertionFailedError(String message) {
		super(defaultString(message));
	}

	private static String defaultString(String message) {
		return message == null ? "" : message;
	}
}
2
            
// in main/java/junit/framework/Assert.java
static public void fail(String message) { if (message == null) { throw new AssertionFailedError(); } throw new AssertionFailedError(message); }
0 0 1
            
// in main/java/junit/framework/TestResult.java
catch (AssertionFailedError e) { addFailure(test, e); }
0 0
runtime (Domain) AssumptionViolatedException
public class AssumptionViolatedException extends RuntimeException implements SelfDescribing {
	private static final long serialVersionUID= 1L;

	private final Object fValue;

	private final Matcher<?> fMatcher;

	public AssumptionViolatedException(Object value, Matcher<?> matcher) {
		super(value instanceof Throwable ? (Throwable) value : null);
		fValue= value;
		fMatcher= matcher;
	}
	
	public AssumptionViolatedException(String assumption) {
		this(assumption, null);
	}

	@Override
	public String getMessage() {
		return StringDescription.asString(this);
	}

	public void describeTo(Description description) {
		if (fMatcher != null) {
			description.appendText("got: ");
			description.appendValue(fValue);
			description.appendText(", expected: ");
			description.appendDescriptionOf(fMatcher);
		} else {
			description.appendText("failed assumption: " + fValue);
		}
	}
}
1
            
// in main/java/org/junit/Assume.java
public static <T> void assumeThat(T actual, Matcher<T> matcher) { if (!matcher.matches(actual)) throw new AssumptionViolatedException(actual, matcher); }
0 0 9
            
// in main/java/org/junit/rules/ExpectedException.java
catch (AssumptionViolatedException e) { optionallyHandleException(e, handleAssumptionViolatedExceptions); return; }
// in main/java/org/junit/rules/TestWatcher.java
catch (AssumptionViolatedException e) { throw e; }
// in main/java/org/junit/rules/TestWatchman.java
catch (AssumptionViolatedException e) { throw e; }
// in main/java/org/junit/experimental/theories/Theories.java
catch (AssumptionViolatedException e) { handleAssumptionViolation(e); }
// in main/java/org/junit/internal/runners/statements/ExpectException.java
catch (AssumptionViolatedException e) { throw e; }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (AssumptionViolatedException e) { throw new FailedBefore(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (org.junit.internal.AssumptionViolatedException e) { throw new FailedBefore(); }
// in main/java/org/junit/runners/ParentRunner.java
catch (AssumptionViolatedException e) { eachNotifier.addFailedAssumption(e); }
// in main/java/org/junit/runners/ParentRunner.java
catch (AssumptionViolatedException e) { testNotifier.fireTestIgnored(); }
5
            
// in main/java/org/junit/rules/TestWatcher.java
catch (AssumptionViolatedException e) { throw e; }
// in main/java/org/junit/rules/TestWatchman.java
catch (AssumptionViolatedException e) { throw e; }
// in main/java/org/junit/internal/runners/statements/ExpectException.java
catch (AssumptionViolatedException e) { throw e; }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (AssumptionViolatedException e) { throw new FailedBefore(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (org.junit.internal.AssumptionViolatedException e) { throw new FailedBefore(); }
0
unknown (Lib) ClassCastException 0 0 0 1
            
// in main/java/org/junit/runners/Parameterized.java
catch (ClassCastException e) { throw parametersMethodReturnedWrongType(); }
1
            
// in main/java/org/junit/runners/Parameterized.java
catch (ClassCastException e) { throw parametersMethodReturnedWrongType(); }
0
unknown (Lib) ClassNotFoundException 0 0 1
            
// in main/java/junit/runner/BaseTestRunner.java
protected Class<?> loadSuiteClass(String suiteClassName) throws ClassNotFoundException { return Class.forName(suiteClassName); }
4
            
// in main/java/junit/runner/BaseTestRunner.java
catch (ClassNotFoundException e) { String clazz= e.getMessage(); if (clazz == null) clazz= suiteClassName; runFailed("Class not found \""+clazz+"\""); return null; }
// in main/java/org/junit/runner/JUnitCore.java
catch (ClassNotFoundException e) { system.out().println("Could not find class: " + each); Description description= Description.createSuiteDescription(each); Failure failure= new Failure(description, e); missingClasses.add(failure); }
// in main/java/org/junit/runner/Description.java
catch (ClassNotFoundException e) { return null; }
// in main/java/org/junit/experimental/max/MaxCore.java
catch (ClassNotFoundException e) { return null; }
0 0
unknown (Domain) ComparisonFailure
public class ComparisonFailure extends AssertionFailedError {
	private static final int MAX_CONTEXT_LENGTH= 20;
	private static final long serialVersionUID= 1L;
	
	private String fExpected;
	private String fActual;

	/**
	 * Constructs a comparison failure.
	 * @param message the identifying message or null
	 * @param expected the expected string value
	 * @param actual the actual string value
	 */
	public ComparisonFailure (String message, String expected, String actual) {
		super (message);
		fExpected= expected;
		fActual= actual;
	}
	
	/**
	 * Returns "..." in place of common prefix and "..." in
	 * place of common suffix between expected and actual.
	 * 
	 * @see Throwable#getMessage()
	 */
	@Override
	public String getMessage() {
		return new ComparisonCompactor(MAX_CONTEXT_LENGTH, fExpected, fActual).compact(super.getMessage());
	}
	
	/**
	 * Gets the actual string value
	 * @return the actual string value
	 */
	public String getActual() {
		return fActual;
	}
	/**
	 * Gets the expected string value
	 * @return the expected string value
	 */
	public String getExpected() {
		return fExpected;
	}
}public class ComparisonFailure extends AssertionError {	
	/** 
	 * The maximum length for fExpected and fActual. If it is exceeded, the strings should be shortened. 
	 * @see ComparisonCompactor
	 */
	private static final int MAX_CONTEXT_LENGTH= 20;
	private static final long serialVersionUID= 1L;
	
	private String fExpected;
	private String fActual;

	/**
	 * Constructs a comparison failure.
	 * @param message the identifying message or null
	 * @param expected the expected string value
	 * @param actual the actual string value
	 */
	public ComparisonFailure (String message, String expected, String actual) {
		super (message);
		fExpected= expected;
		fActual= actual;
	}
	
	/**
	 * Returns "..." in place of common prefix and "..." in
	 * place of common suffix between expected and actual.
	 * 
	 * @see Throwable#getMessage()
	 */
	@Override
	public String getMessage() {
		return new ComparisonCompactor(MAX_CONTEXT_LENGTH, fExpected, fActual).compact(super.getMessage());
	}
	
	/**
	 * Returns the actual string value
	 * @return the actual string value
	 */
	public String getActual() {
		return fActual;
	}
	/**
	 * Returns the expected string value
	 * @return the expected string value
	 */
	public String getExpected() {
		return fExpected;
	}
	
	private static class ComparisonCompactor {
		private static final String ELLIPSIS= "...";
		private static final String DELTA_END= "]";
		private static final String DELTA_START= "[";
		
		/**
		 * The maximum length for <code>expected</code> and <code>actual</code>. When <code>contextLength</code> 
		 * is exceeded, the Strings are shortened
		 */
		private int fContextLength;
		private String fExpected;
		private String fActual;
		private int fPrefix;
		private int fSuffix;

		/**
		 * @param contextLength the maximum length for <code>expected</code> and <code>actual</code>. When contextLength 
		 * is exceeded, the Strings are shortened
		 * @param expected the expected string value
		 * @param actual the actual string value
		 */
		public ComparisonCompactor(int contextLength, String expected, String actual) {
			fContextLength= contextLength;
			fExpected= expected;
			fActual= actual;
		}

		private String compact(String message) {
			if (fExpected == null || fActual == null || areStringsEqual())
				return Assert.format(message, fExpected, fActual);

			findCommonPrefix();
			findCommonSuffix();
			String expected= compactString(fExpected);
			String actual= compactString(fActual);
			return Assert.format(message, expected, actual);
		}

		private String compactString(String source) {
			String result= DELTA_START + source.substring(fPrefix, source.length() - fSuffix + 1) + DELTA_END;
			if (fPrefix > 0)
				result= computeCommonPrefix() + result;
			if (fSuffix > 0)
				result= result + computeCommonSuffix();
			return result;
		}

		private void findCommonPrefix() {
			fPrefix= 0;
			int end= Math.min(fExpected.length(), fActual.length());
			for (; fPrefix < end; fPrefix++) {
				if (fExpected.charAt(fPrefix) != fActual.charAt(fPrefix))
					break;
			}
		}

		private void findCommonSuffix() {
			int expectedSuffix= fExpected.length() - 1;
			int actualSuffix= fActual.length() - 1;
			for (; actualSuffix >= fPrefix && expectedSuffix >= fPrefix; actualSuffix--, expectedSuffix--) {
				if (fExpected.charAt(expectedSuffix) != fActual.charAt(actualSuffix))
					break;
			}
			fSuffix=  fExpected.length() - expectedSuffix;
		}

		private String computeCommonPrefix() {
			return (fPrefix > fContextLength ? ELLIPSIS : "") + fExpected.substring(Math.max(0, fPrefix - fContextLength), fPrefix);
		}

		private String computeCommonSuffix() {
			int end= Math.min(fExpected.length() - fSuffix + 1 + fContextLength, fExpected.length());
			return fExpected.substring(fExpected.length() - fSuffix + 1, end) + (fExpected.length() - fSuffix + 1 < fExpected.length() - fContextLength ? ELLIPSIS : "");
		}

		private boolean areStringsEqual() {
			return fExpected.equals(fActual);
		}
	}
}
2
            
// in main/java/junit/framework/Assert.java
static public void assertEquals(String message, String expected, String actual) { if (expected == null && actual == null) return; if (expected != null && expected.equals(actual)) return; String cleanMessage= message == null ? "" : message; throw new ComparisonFailure(cleanMessage, expected, actual); }
// in main/java/org/junit/Assert.java
static public void assertEquals(String message, Object expected, Object actual) { if (equalsRegardingNull(expected, actual)) return; else if (expected instanceof String && actual instanceof String) { String cleanMessage= message == null ? "" : message; throw new ComparisonFailure(cleanMessage, (String) expected, (String) actual); } else failNotEquals(message, expected, actual); }
0 0 0 0 0
checked (Domain) CouldNotGenerateValueException
public static class CouldNotGenerateValueException extends Exception {
		private static final long serialVersionUID= 1L;
	}
2
            
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
Override public Object getValue() throws CouldNotGenerateValueException { try { return fMethod.invokeExplosively(null); } catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: argument length is checked"); } catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getMethods returned an inaccessible method"); } catch (Throwable e) { throw new CouldNotGenerateValueException(); // do nothing, just look for more values } }
// in main/java/org/junit/experimental/theories/internal/Assignments.java
public Object[] getActualValues(int start, int stop, boolean nullsOk) throws CouldNotGenerateValueException { Object[] values= new Object[stop - start]; for (int i= start; i < stop; i++) { Object value= fAssigned.get(i).getValue(); if (value == null && !nullsOk) throw new CouldNotGenerateValueException(); values[i - start]= value; } return values; }
1
            
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (Throwable e) { throw new CouldNotGenerateValueException(); // do nothing, just look for more values }
9
            
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
Override public Object getValue() throws CouldNotGenerateValueException { try { return fMethod.invokeExplosively(null); } catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: argument length is checked"); } catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getMethods returned an inaccessible method"); } catch (Throwable e) { throw new CouldNotGenerateValueException(); // do nothing, just look for more values } }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
Override public String getDescription() throws CouldNotGenerateValueException { return fMethod.getName(); }
// in main/java/org/junit/experimental/theories/internal/Assignments.java
public Object[] getActualValues(int start, int stop, boolean nullsOk) throws CouldNotGenerateValueException { Object[] values= new Object[stop - start]; for (int i= start; i < stop; i++) { Object value= fAssigned.get(i).getValue(); if (value == null && !nullsOk) throw new CouldNotGenerateValueException(); values[i - start]= value; } return values; }
// in main/java/org/junit/experimental/theories/internal/Assignments.java
public Object[] getConstructorArguments(boolean nullsOk) throws CouldNotGenerateValueException { return getActualValues(0, getConstructorParameterCount(), nullsOk); }
// in main/java/org/junit/experimental/theories/internal/Assignments.java
public Object[] getMethodArguments(boolean nullsOk) throws CouldNotGenerateValueException { return getActualValues(getConstructorParameterCount(), fAssigned.size(), nullsOk); }
// in main/java/org/junit/experimental/theories/internal/Assignments.java
public Object[] getAllArguments(boolean nullsOk) throws CouldNotGenerateValueException { return getActualValues(0, fAssigned.size(), nullsOk); }
// in main/java/org/junit/experimental/theories/internal/Assignments.java
public Object[] getArgumentStrings(boolean nullsOk) throws CouldNotGenerateValueException { Object[] values= new Object[fAssigned.size()]; for (int i= 0; i < values.length; i++) { values[i]= fAssigned.get(i).getDescription(); } return values; }
// in main/java/org/junit/experimental/theories/PotentialAssignment.java
public static PotentialAssignment forValue(final String name, final Object value) { return new PotentialAssignment() { @Override public Object getValue() throws CouldNotGenerateValueException { return value; } @Override public String toString() { return String.format("[%s]", value); } @Override public String getDescription() throws CouldNotGenerateValueException { return name; } }; }
// in main/java/org/junit/experimental/theories/PotentialAssignment.java
Override public Object getValue() throws CouldNotGenerateValueException { return value; }
// in main/java/org/junit/experimental/theories/PotentialAssignment.java
Override public String getDescription() throws CouldNotGenerateValueException { return name; }
1
            
// in main/java/org/junit/experimental/theories/Theories.java
catch (CouldNotGenerateValueException e) { // ignore }
0 0
checked (Domain) CouldNotReadCoreException
public class CouldNotReadCoreException extends Exception {
	private static final long serialVersionUID= 1L;

	/**
	 * Constructs
	 */
	public CouldNotReadCoreException(Throwable e) {
		super(e);
	}
}
1
            
// in main/java/org/junit/experimental/max/MaxHistory.java
private static MaxHistory readHistory(File storedResults) throws CouldNotReadCoreException { try { FileInputStream file= new FileInputStream(storedResults); try { ObjectInputStream stream= new ObjectInputStream(file); try { return (MaxHistory) stream.readObject(); } finally { stream.close(); } } finally { file.close(); } } catch (Exception e) { throw new CouldNotReadCoreException(e); } }
1
            
// in main/java/org/junit/experimental/max/MaxHistory.java
catch (Exception e) { throw new CouldNotReadCoreException(e); }
1
            
// in main/java/org/junit/experimental/max/MaxHistory.java
private static MaxHistory readHistory(File storedResults) throws CouldNotReadCoreException { try { FileInputStream file= new FileInputStream(storedResults); try { ObjectInputStream stream= new ObjectInputStream(file); try { return (MaxHistory) stream.readObject(); } finally { stream.close(); } } finally { file.close(); } } catch (Exception e) { throw new CouldNotReadCoreException(e); } }
1
            
// in main/java/org/junit/experimental/max/MaxHistory.java
catch (CouldNotReadCoreException e) { e.printStackTrace(); file.delete(); }
0 0
runtime (Lib) Error 1
            
// in main/java/org/junit/internal/matchers/TypeSafeMatcher.java
private static Class<?> findExpectedType(Class<?> fromClass) { for (Class<?> c = fromClass; c != Object.class; c = c.getSuperclass()) { for (Method method : MethodSorter.getDeclaredMethods(c)) { if (isMatchesSafelyMethod(method)) { return method.getParameterTypes()[0]; } } } throw new Error("Cannot determine correct type for matchesSafely() method."); }
0 0 0 0 0
checked (Lib) Exception 5
            
// in main/java/junit/textui/TestRunner.java
public TestResult start(String args[]) throws Exception { String testCase= ""; String method= ""; boolean wait= false; for (int i= 0; i < args.length; i++) { if (args[i].equals("-wait")) wait= true; else if (args[i].equals("-c")) testCase= extractClassName(args[++i]); else if (args[i].equals("-m")) { String arg= args[++i]; int lastIndex= arg.lastIndexOf('.'); testCase= arg.substring(0, lastIndex); method= arg.substring(lastIndex + 1); } else if (args[i].equals("-v")) System.err.println("JUnit " + Version.id() + " by Kent Beck and Erich Gamma"); else testCase= args[i]; } if (testCase.equals("")) throw new Exception("Usage: TestRunner [-wait] testCaseName, where name is the name of the TestCase class"); try { if (!method.equals("")) return runSingleMethod(testCase, method, wait); Test suite= getTest(testCase); return doRun(suite, wait); } catch (Exception e) { throw new Exception("Could not create and run test suite: " + e); } }
// in main/java/org/junit/internal/runners/statements/ExpectException.java
Override public void evaluate() throws Exception { boolean complete = false; try { fNext.evaluate(); complete = true; } catch (AssumptionViolatedException e) { throw e; } catch (Throwable e) { if (!fExpected.isAssignableFrom(e.getClass())) { String message= "Unexpected exception, expected<" + fExpected.getName() + "> but was<" + e.getClass().getName() + ">"; throw new Exception(message, e); } } if (complete) throw new AssertionError("Expected exception: " + fExpected.getName()); }
// in main/java/org/junit/internal/runners/SuiteMethod.java
public static Test testFromSuiteMethod(Class<?> klass) throws Throwable { Method suiteMethod= null; Test suite= null; try { suiteMethod= klass.getMethod("suite"); if (! Modifier.isStatic(suiteMethod.getModifiers())) { throw new Exception(klass.getName() + ".suite() must be static"); } suite= (Test) suiteMethod.invoke(null); // static method } catch (InvocationTargetException e) { throw e.getCause(); } return suite; }
// in main/java/org/junit/runners/Parameterized.java
private FrameworkMethod getParametersMethod() throws Exception { List<FrameworkMethod> methods= getTestClass().getAnnotatedMethods( Parameters.class); for (FrameworkMethod each : methods) { if (each.isStatic() && each.isPublic()) return each; } throw new Exception("No public static parameters method on class " + getTestClass().getName()); }
2
            
// in main/java/junit/textui/TestRunner.java
catch (Exception e) { throw new Exception("Could not create and run test suite: " + e); }
// in main/java/org/junit/internal/runners/statements/ExpectException.java
catch (Throwable e) { if (!fExpected.isAssignableFrom(e.getClass())) { String message= "Unexpected exception, expected<" + fExpected.getName() + "> but was<" + e.getClass().getName() + ">"; throw new Exception(message, e); } }
47
            
// in main/java/junit/framework/JUnit4TestAdapterCache.java
public RunNotifier getNotifier(final TestResult result, final JUnit4TestAdapter adapter) { RunNotifier notifier = new RunNotifier(); notifier.addListener(new RunListener() { @Override public void testFailure(Failure failure) throws Exception { result.addError(asTest(failure.getDescription()), failure.getException()); } @Override public void testFinished(Description description) throws Exception { result.endTest(asTest(description)); } @Override public void testStarted(Description description) throws Exception { result.startTest(asTest(description)); } }); return notifier; }
// in main/java/junit/framework/JUnit4TestAdapterCache.java
Override public void testFailure(Failure failure) throws Exception { result.addError(asTest(failure.getDescription()), failure.getException()); }
// in main/java/junit/framework/JUnit4TestAdapterCache.java
Override public void testFinished(Description description) throws Exception { result.endTest(asTest(description)); }
// in main/java/junit/framework/JUnit4TestAdapterCache.java
Override public void testStarted(Description description) throws Exception { result.startTest(asTest(description)); }
// in main/java/junit/framework/TestCase.java
protected void setUp() throws Exception { }
// in main/java/junit/framework/TestCase.java
protected void tearDown() throws Exception { }
// in main/java/junit/textui/TestRunner.java
public TestResult start(String args[]) throws Exception { String testCase= ""; String method= ""; boolean wait= false; for (int i= 0; i < args.length; i++) { if (args[i].equals("-wait")) wait= true; else if (args[i].equals("-c")) testCase= extractClassName(args[++i]); else if (args[i].equals("-m")) { String arg= args[++i]; int lastIndex= arg.lastIndexOf('.'); testCase= arg.substring(0, lastIndex); method= arg.substring(lastIndex + 1); } else if (args[i].equals("-v")) System.err.println("JUnit " + Version.id() + " by Kent Beck and Erich Gamma"); else testCase= args[i]; } if (testCase.equals("")) throw new Exception("Usage: TestRunner [-wait] testCaseName, where name is the name of the TestCase class"); try { if (!method.equals("")) return runSingleMethod(testCase, method, wait); Test suite= getTest(testCase); return doRun(suite, wait); } catch (Exception e) { throw new Exception("Could not create and run test suite: " + e); } }
// in main/java/junit/textui/TestRunner.java
protected TestResult runSingleMethod(String testCase, String method, boolean wait) throws Exception { Class<? extends TestCase> testClass= loadSuiteClass(testCase).asSubclass(TestCase.class); Test test= TestSuite.createTest(testClass, method); return doRun(test, wait); }
// in main/java/junit/extensions/TestSetup.java
Override public void run(final TestResult result) { Protectable p= new Protectable() { public void protect() throws Exception { setUp(); basicRun(result); tearDown(); } }; result.runProtected(this, p); }
// in main/java/junit/extensions/TestSetup.java
public void protect() throws Exception { setUp(); basicRun(result); tearDown(); }
// in main/java/junit/extensions/TestSetup.java
protected void setUp() throws Exception { }
// in main/java/junit/extensions/TestSetup.java
protected void tearDown() throws Exception { }
// in main/java/org/junit/runner/notification/RunNotifier.java
public void fireTestRunStarted(final Description description) { new SafeNotifier() { @Override protected void notifyListener(RunListener each) throws Exception { each.testRunStarted(description); }; }.run(); }
// in main/java/org/junit/runner/notification/RunNotifier.java
Override protected void notifyListener(RunListener each) throws Exception { each.testRunStarted(description); }
// in main/java/org/junit/runner/notification/RunNotifier.java
public void fireTestRunFinished(final Result result) { new SafeNotifier() { @Override protected void notifyListener(RunListener each) throws Exception { each.testRunFinished(result); }; }.run(); }
// in main/java/org/junit/runner/notification/RunNotifier.java
Override protected void notifyListener(RunListener each) throws Exception { each.testRunFinished(result); }
// in main/java/org/junit/runner/notification/RunNotifier.java
public void fireTestStarted(final Description description) throws StoppedByUserException { if (fPleaseStop) throw new StoppedByUserException(); new SafeNotifier() { @Override protected void notifyListener(RunListener each) throws Exception { each.testStarted(description); }; }.run(); }
// in main/java/org/junit/runner/notification/RunNotifier.java
Override protected void notifyListener(RunListener each) throws Exception { each.testStarted(description); }
// in main/java/org/junit/runner/notification/RunNotifier.java
private void fireTestFailures(List<RunListener> listeners, final List<Failure> failures) { if (!failures.isEmpty()) new SafeNotifier(listeners) { @Override protected void notifyListener(RunListener listener) throws Exception { for (Failure each : failures) listener.testFailure(each); }; }.run(); }
// in main/java/org/junit/runner/notification/RunNotifier.java
Override protected void notifyListener(RunListener listener) throws Exception { for (Failure each : failures) listener.testFailure(each); }
// in main/java/org/junit/runner/notification/RunNotifier.java
public void fireTestAssumptionFailed(final Failure failure) { new SafeNotifier() { @Override protected void notifyListener(RunListener each) throws Exception { each.testAssumptionFailure(failure); }; }.run(); }
// in main/java/org/junit/runner/notification/RunNotifier.java
Override protected void notifyListener(RunListener each) throws Exception { each.testAssumptionFailure(failure); }
// in main/java/org/junit/runner/notification/RunNotifier.java
public void fireTestIgnored(final Description description) { new SafeNotifier() { @Override protected void notifyListener(RunListener each) throws Exception { each.testIgnored(description); } }.run(); }
// in main/java/org/junit/runner/notification/RunNotifier.java
Override protected void notifyListener(RunListener each) throws Exception { each.testIgnored(description); }
// in main/java/org/junit/runner/notification/RunNotifier.java
public void fireTestFinished(final Description description) { new SafeNotifier() { @Override protected void notifyListener(RunListener each) throws Exception { each.testFinished(description); }; }.run(); }
// in main/java/org/junit/runner/notification/RunNotifier.java
Override protected void notifyListener(RunListener each) throws Exception { each.testFinished(description); }
// in main/java/org/junit/runner/notification/RunListener.java
public void testRunStarted(Description description) throws Exception { }
// in main/java/org/junit/runner/notification/RunListener.java
public void testRunFinished(Result result) throws Exception { }
// in main/java/org/junit/runner/notification/RunListener.java
public void testStarted(Description description) throws Exception { }
// in main/java/org/junit/runner/notification/RunListener.java
public void testFinished(Description description) throws Exception { }
// in main/java/org/junit/runner/notification/RunListener.java
public void testFailure(Failure failure) throws Exception { }
// in main/java/org/junit/runner/notification/RunListener.java
public void testIgnored(Description description) throws Exception { }
// in main/java/org/junit/runner/Result.java
Override public void testRunStarted(Description description) throws Exception { fStartTime= System.currentTimeMillis(); }
// in main/java/org/junit/runner/Result.java
Override public void testRunFinished(Result result) throws Exception { long endTime= System.currentTimeMillis(); fRunTime+= endTime - fStartTime; }
// in main/java/org/junit/runner/Result.java
Override public void testFinished(Description description) throws Exception { fCount.getAndIncrement(); }
// in main/java/org/junit/runner/Result.java
Override public void testFailure(Failure failure) throws Exception { fFailures.add(failure); }
// in main/java/org/junit/runner/Result.java
Override public void testIgnored(Description description) throws Exception { fIgnoreCount.getAndIncrement(); }
// in main/java/org/junit/rules/ErrorCollector.java
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; } }); }
// in main/java/org/junit/rules/ErrorCollector.java
public Object call() throws Exception { assertThat(reason, value, matcher); return value; }
// in main/java/org/junit/experimental/max/MaxHistory.java
Override public void testStarted(Description description) throws Exception { starts.put(description, System.nanoTime()); // Get most accurate // possible time }
// in main/java/org/junit/experimental/max/MaxHistory.java
Override public void testFinished(Description description) throws Exception { long end= System.nanoTime(); long start= starts.get(description); putTestDuration(description, end - start); }
// in main/java/org/junit/experimental/max/MaxHistory.java
Override public void testFailure(Failure failure) throws Exception { putTestFailureTimestamp(failure.getDescription(), overallStart); }
// in main/java/org/junit/experimental/max/MaxHistory.java
Override public void testRunFinished(Result result) throws Exception { save(); }
// in main/java/org/junit/experimental/theories/Theories.java
protected void runWithCompleteAssignment(final Assignments complete) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, Throwable { new BlockJUnit4ClassRunner(getTestClass().getJavaClass()) { @Override protected void collectInitializationErrors( List<Throwable> errors) { // do nothing } @Override public Statement methodBlock(FrameworkMethod method) { final Statement statement= super.methodBlock(method); return new Statement() { @Override public void evaluate() throws Throwable { try { statement.evaluate(); handleDataPointSuccess(); } catch (AssumptionViolatedException e) { handleAssumptionViolation(e); } catch (Throwable e) { reportParameterizedError(e, complete .getArgumentStrings(nullsOk())); } } }; } @Override protected Statement methodInvoker(FrameworkMethod method, Object test) { return methodCompletesWithParameters(method, complete, test); } @Override public Object createTest() throws Exception { return getTestClass().getOnlyConstructor().newInstance( complete.getConstructorArguments(nullsOk())); } }.methodBlock(fTestMethod).evaluate(); }
// in main/java/org/junit/experimental/theories/Theories.java
Override public Object createTest() throws Exception { return getTestClass().getOnlyConstructor().newInstance( complete.getConstructorArguments(nullsOk())); }
// in main/java/org/junit/experimental/theories/internal/Assignments.java
public static Assignments allUnassigned(Method testMethod, TestClass testClass) throws Exception { List<ParameterSignature> signatures; signatures= ParameterSignature.signatures(testClass .getOnlyConstructor()); signatures.addAll(ParameterSignature.signatures(testMethod)); return new Assignments(new ArrayList<PotentialAssignment>(), signatures, testClass); }
// in main/java/org/junit/experimental/ParallelComputer.java
private static <T> Runner parallelize(Runner runner) { if (runner instanceof ParentRunner<?>) { ((ParentRunner<?>) runner).setScheduler(new RunnerScheduler() { private final List<Future<Object>> fResults= new ArrayList<Future<Object>>(); private final ExecutorService fService= Executors .newCachedThreadPool(); public void schedule(final Runnable childStatement) { fResults.add(fService.submit(new Callable<Object>() { public Object call() throws Exception { childStatement.run(); return null; } })); }
// in main/java/org/junit/experimental/ParallelComputer.java
public void schedule(final Runnable childStatement) { fResults.add(fService.submit(new Callable<Object>() { public Object call() throws Exception { childStatement.run(); return null; } }
// in main/java/org/junit/experimental/ParallelComputer.java
public Object call() throws Exception { childStatement.run(); return null; }
// in main/java/org/junit/internal/runners/statements/FailOnTimeout.java
private void throwTimeoutException(StatementThread thread) throws Exception { Exception exception= new Exception(String.format( "test timed out after %d milliseconds", fTimeout)); exception.setStackTrace(thread.getStackTrace()); throw exception; }
// in main/java/org/junit/internal/runners/statements/ExpectException.java
Override public void evaluate() throws Exception { boolean complete = false; try { fNext.evaluate(); complete = true; } catch (AssumptionViolatedException e) { throw e; } catch (Throwable e) { if (!fExpected.isAssignableFrom(e.getClass())) { String message= "Unexpected exception, expected<" + fExpected.getName() + "> but was<" + e.getClass().getName() + ">"; throw new Exception(message, e); } } if (complete) throw new AssertionError("Expected exception: " + fExpected.getName()); }
// in main/java/org/junit/internal/runners/JUnit4ClassRunner.java
protected Object createTest() throws Exception { return getTestClass().getConstructor().newInstance(); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
private void runWithTimeout(final long timeout) { runBeforesThenTestThenAfters(new Runnable() { public void run() { ExecutorService service= Executors.newSingleThreadExecutor(); Callable<Object> callable= new Callable<Object>() { public Object call() throws Exception { runTestMethod(); return null; } }; Future<Object> result= service.submit(callable); service.shutdown(); try { boolean terminated= service.awaitTermination(timeout, TimeUnit.MILLISECONDS); if (!terminated) service.shutdownNow(); result.get(0, TimeUnit.MILLISECONDS); // throws the exception if one occurred during the invocation } catch (TimeoutException e) { addFailure(new Exception(String.format("test timed out after %d milliseconds", timeout))); } catch (Exception e) { addFailure(e); } } }); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
public void run() { ExecutorService service= Executors.newSingleThreadExecutor(); Callable<Object> callable= new Callable<Object>() { public Object call() throws Exception { runTestMethod(); return null; } }; Future<Object> result= service.submit(callable); service.shutdown(); try { boolean terminated= service.awaitTermination(timeout, TimeUnit.MILLISECONDS); if (!terminated) service.shutdownNow(); result.get(0, TimeUnit.MILLISECONDS); // throws the exception if one occurred during the invocation } catch (TimeoutException e) { addFailure(new Exception(String.format("test timed out after %d milliseconds", timeout))); } catch (Exception e) { addFailure(e); } }
// in main/java/org/junit/internal/runners/MethodRoadie.java
public Object call() throws Exception { runTestMethod(); return null; }
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
Override public Runner runnerForClass(Class<?> testClass) throws Exception { RunWith annotation= testClass.getAnnotation(RunWith.class); if (annotation != null) return buildRunner(annotation.value(), testClass); return null; }
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
public Runner buildRunner(Class<? extends Runner> runnerClass, Class<?> testClass) throws Exception { try { return runnerClass.getConstructor(Class.class).newInstance( new Object[] { testClass }); } catch (NoSuchMethodException e) { try { return runnerClass.getConstructor(Class.class, RunnerBuilder.class).newInstance( new Object[] { testClass, fSuiteBuilder }); } catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); } } }
// in main/java/org/junit/runners/Parameterized.java
Override public Object createTest() throws Exception { return getTestClass().getOnlyConstructor().newInstance(fParameters); }
// in main/java/org/junit/runners/Parameterized.java
private FrameworkMethod getParametersMethod() throws Exception { List<FrameworkMethod> methods= getTestClass().getAnnotatedMethods( Parameters.class); for (FrameworkMethod each : methods) { if (each.isStatic() && each.isPublic()) return each; } throw new Exception("No public static parameters method on class " + getTestClass().getName()); }
// in main/java/org/junit/runners/Parameterized.java
private void createRunnersForParameters(Iterable<Object[]> allParameters, String namePattern) throws InitializationError, Exception { try { int i= 0; for (Object[] parametersOfSingleTest : allParameters) { String name= nameFor(namePattern, i, parametersOfSingleTest); TestClassRunnerForParameters runner= new TestClassRunnerForParameters( getTestClass().getJavaClass(), parametersOfSingleTest, name); runners.add(runner); ++i; } } catch (ClassCastException e) { throw parametersMethodReturnedWrongType(); } }
// in main/java/org/junit/runners/Parameterized.java
private Exception parametersMethodReturnedWrongType() throws Exception { String className= getTestClass().getName(); String methodName= getParametersMethod().getName(); String message= MessageFormat.format( "{0}.{1}() must return an Iterable of arrays.", className, methodName); return new Exception(message); }
// in main/java/org/junit/runners/BlockJUnit4ClassRunner.java
protected Object createTest() throws Exception { return getTestClass().getOnlyConstructor().newInstance(); }
14
            
// in main/java/junit/runner/BaseTestRunner.java
catch(Exception e) { runFailed("Error: "+e.toString()); return null; }
// in main/java/junit/runner/BaseTestRunner.java
catch(Exception e) { // try to extract a test suite automatically clearStatus(); return new TestSuite(testClass); }
// in main/java/junit/runner/BaseTestRunner.java
catch (Exception IOException) { return stack; // return the stack unfiltered }
// in main/java/junit/textui/TestRunner.java
catch(Exception e) { }
// in main/java/junit/textui/TestRunner.java
catch(Exception e) { System.err.println(e.getMessage()); System.exit(EXCEPTION_EXIT); }
// in main/java/junit/textui/TestRunner.java
catch (Exception e) { throw new Exception("Could not create and run test suite: " + e); }
// in main/java/org/junit/runner/notification/RunNotifier.java
catch (Exception e) { failures.add(new Failure(Description.TEST_MECHANISM, e)); }
// in main/java/org/junit/experimental/max/MaxHistory.java
catch (Exception e) { throw new CouldNotReadCoreException(e); }
// in main/java/org/junit/experimental/results/FailureList.java
catch (Exception e) { throw new RuntimeException("I can't believe this happened"); }
// in main/java/org/junit/experimental/ParallelComputer.java
catch (Exception e) { e.printStackTrace(); }
// in main/java/org/junit/internal/runners/MethodValidator.java
catch (Exception e) { fErrors.add(new Exception("Test class should have public zero-argument constructor", e)); }
// in main/java/org/junit/internal/runners/JUnit4ClassRunner.java
catch (Exception e) { testAborted(notifier, description, e); return; }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Exception e) { addFailure(e); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Exception e) { throw new RuntimeException("test should never throw an exception to this level"); }
4
            
// in main/java/junit/textui/TestRunner.java
catch (Exception e) { throw new Exception("Could not create and run test suite: " + e); }
// in main/java/org/junit/experimental/max/MaxHistory.java
catch (Exception e) { throw new CouldNotReadCoreException(e); }
// in main/java/org/junit/experimental/results/FailureList.java
catch (Exception e) { throw new RuntimeException("I can't believe this happened"); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Exception e) { throw new RuntimeException("test should never throw an exception to this level"); }
2
unknown (Lib) FailedBefore 4
            
// in main/java/org/junit/internal/runners/MethodRoadie.java
private void runBefores() throws FailedBefore { try { try { List<Method> befores= fTestMethod.getBefores(); for (Method before : befores) before.invoke(fTest); } catch (InvocationTargetException e) { throw e.getTargetException(); } } catch (AssumptionViolatedException e) { throw new FailedBefore(); } catch (Throwable e) { addFailure(e); throw new FailedBefore(); } }
// in main/java/org/junit/internal/runners/ClassRoadie.java
private void runBefores() throws FailedBefore { try { try { List<Method> befores= fTestClass.getBefores(); for (Method before : befores) before.invoke(null); } catch (InvocationTargetException e) { throw e.getTargetException(); } } catch (org.junit.internal.AssumptionViolatedException e) { throw new FailedBefore(); } catch (Throwable e) { addFailure(e); throw new FailedBefore(); } }
4
            
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (AssumptionViolatedException e) { throw new FailedBefore(); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Throwable e) { addFailure(e); throw new FailedBefore(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (org.junit.internal.AssumptionViolatedException e) { throw new FailedBefore(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (Throwable e) { addFailure(e); throw new FailedBefore(); }
2
            
// in main/java/org/junit/internal/runners/MethodRoadie.java
private void runBefores() throws FailedBefore { try { try { List<Method> befores= fTestMethod.getBefores(); for (Method before : befores) before.invoke(fTest); } catch (InvocationTargetException e) { throw e.getTargetException(); } } catch (AssumptionViolatedException e) { throw new FailedBefore(); } catch (Throwable e) { addFailure(e); throw new FailedBefore(); } }
// in main/java/org/junit/internal/runners/ClassRoadie.java
private void runBefores() throws FailedBefore { try { try { List<Method> befores= fTestClass.getBefores(); for (Method before : befores) before.invoke(null); } catch (InvocationTargetException e) { throw e.getTargetException(); } } catch (org.junit.internal.AssumptionViolatedException e) { throw new FailedBefore(); } catch (Throwable e) { addFailure(e); throw new FailedBefore(); } }
2
            
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (FailedBefore e) { }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (FailedBefore e) { }
0 0
checked (Lib) IOException 0 0 7
            
// in main/java/junit/runner/BaseTestRunner.java
public static void savePreferences() throws IOException { FileOutputStream fos= new FileOutputStream(getPreferencesFile()); try { getPreferences().store(fos, ""); } finally { fos.close(); } }
// in main/java/org/junit/rules/TemporaryFolder.java
public void create() throws IOException { folder= createTemporaryFolderIn(null); }
// in main/java/org/junit/rules/TemporaryFolder.java
public File newFile(String fileName) throws IOException { File file= new File(getRoot(), fileName); if (!file.createNewFile()) throw new IllegalStateException( "a file with the name \'" + fileName + "\' already exists in the test folder"); return file; }
// in main/java/org/junit/rules/TemporaryFolder.java
public File newFile() throws IOException { return File.createTempFile("junit", null, getRoot()); }
// in main/java/org/junit/rules/TemporaryFolder.java
public File newFolder() throws IOException { return createTemporaryFolderIn(getRoot()); }
// in main/java/org/junit/rules/TemporaryFolder.java
private File createTemporaryFolderIn(File parentFolder) throws IOException { File createdFolder= File.createTempFile("junit", "", parentFolder); createdFolder.delete(); createdFolder.mkdir(); return createdFolder; }
// in main/java/org/junit/experimental/max/MaxHistory.java
private void save() throws IOException { ObjectOutputStream stream= new ObjectOutputStream(new FileOutputStream( fHistoryStore)); stream.writeObject(this); stream.close(); }
2
            
// in main/java/junit/runner/BaseTestRunner.java
catch (IOException e) { try { if (is != null) is.close(); } catch (IOException e1) { } }
// in main/java/junit/runner/BaseTestRunner.java
catch (IOException e1) { }
// in main/java/junit/runner/BaseTestRunner.java
catch (Exception IOException) { return stack; // return the stack unfiltered }
0 0
unknown (Lib) IllegalAccessException 0 0 7
            
// in main/java/org/junit/experimental/theories/Theories.java
protected void runWithIncompleteAssignment(Assignments incomplete) throws InstantiationException, IllegalAccessException, Throwable { for (PotentialAssignment source : incomplete .potentialsForNextUnassigned()) { runWithAssignment(incomplete.assignNext(source)); } }
// in main/java/org/junit/experimental/theories/Theories.java
protected void runWithCompleteAssignment(final Assignments complete) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, Throwable { new BlockJUnit4ClassRunner(getTestClass().getJavaClass()) { @Override protected void collectInitializationErrors( List<Throwable> errors) { // do nothing } @Override public Statement methodBlock(FrameworkMethod method) { final Statement statement= super.methodBlock(method); return new Statement() { @Override public void evaluate() throws Throwable { try { statement.evaluate(); handleDataPointSuccess(); } catch (AssumptionViolatedException e) { handleAssumptionViolation(e); } catch (Throwable e) { reportParameterizedError(e, complete .getArgumentStrings(nullsOk())); } } }; } @Override protected Statement methodInvoker(FrameworkMethod method, Object test) { return methodCompletesWithParameters(method, complete, test); } @Override public Object createTest() throws Exception { return getTestClass().getOnlyConstructor().newInstance( complete.getConstructorArguments(nullsOk())); } }.methodBlock(fTestMethod).evaluate(); }
// in main/java/org/junit/experimental/theories/internal/Assignments.java
public List<PotentialAssignment> potentialsForNextUnassigned() throws InstantiationException, IllegalAccessException { ParameterSignature unassigned= nextUnassigned(); return getSupplier(unassigned).getValueSources(unassigned); }
// in main/java/org/junit/experimental/theories/internal/Assignments.java
public ParameterSupplier getSupplier(ParameterSignature unassigned) throws InstantiationException, IllegalAccessException { ParameterSupplier supplier= getAnnotatedSupplier(unassigned); if (supplier != null) return supplier; return new AllMembersSupplier(fClass); }
// in main/java/org/junit/experimental/theories/internal/Assignments.java
public ParameterSupplier getAnnotatedSupplier(ParameterSignature unassigned) throws InstantiationException, IllegalAccessException { ParametersSuppliedBy annotation= unassigned .findDeepAnnotation(ParametersSuppliedBy.class); if (annotation == null) return null; return annotation.value().newInstance(); }
// in main/java/org/junit/internal/runners/TestMethod.java
public void invoke(Object test) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { fMethod.invoke(test); }
// in main/java/org/junit/runners/model/FrameworkField.java
public Object get(Object target) throws IllegalArgumentException, IllegalAccessException { return fField.get(target); }
6
            
// in main/java/junit/runner/BaseTestRunner.java
catch (IllegalAccessException e) { runFailed("Failed to invoke suite():" + e.toString()); return null; }
// in main/java/junit/framework/TestSuite.java
catch (IllegalAccessException e) { return(warning("Cannot access test case: "+name+" ("+exceptionToString(e)+")")); }
// in main/java/junit/framework/TestCase.java
catch (IllegalAccessException e) { e.fillInStackTrace(); throw e; }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getMethods returned an inaccessible method"); }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getFields returned an inaccessible field"); }
// in main/java/org/junit/runners/model/TestClass.java
catch (IllegalAccessException e) { throw new RuntimeException( "How did getFields return a field we couldn't access?", e); }
4
            
// in main/java/junit/framework/TestCase.java
catch (IllegalAccessException e) { e.fillInStackTrace(); throw e; }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getMethods returned an inaccessible method"); }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getFields returned an inaccessible field"); }
// in main/java/org/junit/runners/model/TestClass.java
catch (IllegalAccessException e) { throw new RuntimeException( "How did getFields return a field we couldn't access?", e); }
3
runtime (Lib) IllegalArgumentException 4 0 2
            
// in main/java/org/junit/internal/runners/TestMethod.java
public void invoke(Object test) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { fMethod.invoke(test); }
// in main/java/org/junit/runners/model/FrameworkField.java
public Object get(Object target) throws IllegalArgumentException, IllegalAccessException { return fField.get(target); }
2
            
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: argument length is checked"); }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: field from getClass doesn't exist on object"); }
2
            
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: argument length is checked"); }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: field from getClass doesn't exist on object"); }
2
runtime (Lib) IllegalStateException 2
            
// in main/java/org/junit/rules/TemporaryFolder.java
public File newFile(String fileName) throws IOException { File file= new File(getRoot(), fileName); if (!file.createNewFile()) throw new IllegalStateException( "a file with the name \'" + fileName + "\' already exists in the test folder"); return file; }
// in main/java/org/junit/rules/TemporaryFolder.java
public File getRoot() { if (folder == null) { throw new IllegalStateException( "the temporary folder has not yet been created"); } return folder; }
0 0 0 0 0
checked (Domain) InitializationError
public class InitializationError extends Exception {
	private static final long serialVersionUID= 1L;
	private final List<Throwable> fErrors;

	/**
	 * Construct a new {@code InitializationError} with one or more
	 * errors {@code errors} as causes
	 */
	public InitializationError(List<Throwable> errors) {
		fErrors= errors;
	}
	
	public InitializationError(Throwable error) {
		this(Arrays.asList(error));
	}
	
	/**
	 * Construct a new {@code InitializationError} with one cause
	 * with message {@code string}
	 */
	public InitializationError(String string) {
		this(new Exception(string));
	}

	/**
	 * Returns one or more Throwables that led to this initialization error.
	 */
	public List<Throwable> getCauses() {
		return fErrors;
	}
}
7
            
// in main/java/org/junit/experimental/categories/Categories.java
private void assertNoDescendantsHaveCategoryAnnotations(Description description) throws InitializationError { for (Description each : description.getChildren()) { if (each.getAnnotation(Category.class) != null) throw new InitializationError("Category annotations on Parameterized classes are not supported on individual methods."); assertNoDescendantsHaveCategoryAnnotations(each); } }
// in main/java/org/junit/internal/runners/MethodValidator.java
public void assertValid() throws InitializationError { if (!fErrors.isEmpty()) throw new InitializationError(fErrors); }
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
public Runner buildRunner(Class<? extends Runner> runnerClass, Class<?> testClass) throws Exception { try { return runnerClass.getConstructor(Class.class).newInstance( new Object[] { testClass }); } catch (NoSuchMethodException e) { try { return runnerClass.getConstructor(Class.class, RunnerBuilder.class).newInstance( new Object[] { testClass, fSuiteBuilder }); } catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); } } }
// in main/java/org/junit/runners/ParentRunner.java
private void validate() throws InitializationError { List<Throwable> errors= new ArrayList<Throwable>(); collectInitializationErrors(errors); if (!errors.isEmpty()) throw new InitializationError(errors); }
// in main/java/org/junit/runners/model/RunnerBuilder.java
Class<?> addParent(Class<?> parent) throws InitializationError { if (!parents.add(parent)) throw new InitializationError(String.format("class '%s' (possibly indirectly) contains itself as a SuiteClass", parent.getName())); return parent; }
2
            
// in main/java/org/junit/experimental/categories/Categories.java
catch (NoTestsRemainException e) { throw new InitializationError(e); }
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
catch (NoSuchMethodException e) { try { return runnerClass.getConstructor(Class.class, RunnerBuilder.class).newInstance( new Object[] { testClass, fSuiteBuilder }); } catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); } }
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); }
23
            
// in main/java/org/junit/runner/Computer.java
public Runner getSuite(final RunnerBuilder builder, Class<?>[] classes) throws InitializationError { return new Suite(new RunnerBuilder() { @Override public Runner runnerForClass(Class<?> testClass) throws Throwable { return getRunner(builder, testClass); } }, classes); }
// in main/java/org/junit/experimental/categories/Categories.java
private void assertNoCategorizedDescendentsOfUncategorizeableParents(Description description) throws InitializationError { if (!canHaveCategorizedChildren(description)) assertNoDescendantsHaveCategoryAnnotations(description); for (Description each : description.getChildren()) assertNoCategorizedDescendentsOfUncategorizeableParents(each); }
// in main/java/org/junit/experimental/categories/Categories.java
private void assertNoDescendantsHaveCategoryAnnotations(Description description) throws InitializationError { for (Description each : description.getChildren()) { if (each.getAnnotation(Category.class) != null) throw new InitializationError("Category annotations on Parameterized classes are not supported on individual methods."); assertNoDescendantsHaveCategoryAnnotations(each); } }
// in main/java/org/junit/experimental/ParallelComputer.java
Override public Runner getSuite(RunnerBuilder builder, java.lang.Class<?>[] classes) throws InitializationError { Runner suite= super.getSuite(builder, classes); return fClasses ? parallelize(suite) : suite; }
// in main/java/org/junit/internal/runners/MethodValidator.java
public void assertValid() throws InitializationError { if (!fErrors.isEmpty()) throw new InitializationError(fErrors); }
// in main/java/org/junit/internal/runners/JUnit4ClassRunner.java
protected void validate() throws InitializationError { MethodValidator methodValidator= new MethodValidator(fTestClass); methodValidator.validateMethodsForDefaultRunner(); methodValidator.assertValid(); }
// in main/java/org/junit/runners/ParentRunner.java
private void validate() throws InitializationError { List<Throwable> errors= new ArrayList<Throwable>(); collectInitializationErrors(errors); if (!errors.isEmpty()) throw new InitializationError(errors); }
// in main/java/org/junit/runners/Parameterized.java
private void createRunnersForParameters(Iterable<Object[]> allParameters, String namePattern) throws InitializationError, Exception { try { int i= 0; for (Object[] parametersOfSingleTest : allParameters) { String name= nameFor(namePattern, i, parametersOfSingleTest); TestClassRunnerForParameters runner= new TestClassRunnerForParameters( getTestClass().getJavaClass(), parametersOfSingleTest, name); runners.add(runner); ++i; } } catch (ClassCastException e) { throw parametersMethodReturnedWrongType(); } }
// in main/java/org/junit/runners/model/RunnerBuilder.java
Class<?> addParent(Class<?> parent) throws InitializationError { if (!parents.add(parent)) throw new InitializationError(String.format("class '%s' (possibly indirectly) contains itself as a SuiteClass", parent.getName())); return parent; }
// in main/java/org/junit/runners/model/RunnerBuilder.java
public List<Runner> runners(Class<?> parent, Class<?>[] children) throws InitializationError { addParent(parent); try { return runners(children); } finally { removeParent(parent); } }
// in main/java/org/junit/runners/model/RunnerBuilder.java
public List<Runner> runners(Class<?> parent, List<Class<?>> children) throws InitializationError { return runners(parent, children.toArray(new Class<?>[0])); }
3
            
// in main/java/org/junit/runner/Request.java
catch (InitializationError e) { throw new RuntimeException( "Bug in saff's brain: Suite constructor, called as above, should always complete"); }
// in main/java/org/junit/experimental/max/MaxCore.java
catch (InitializationError e) { return new ErrorReportingRunner(null, e); }
// in main/java/org/junit/runners/Suite.java
catch (InitializationError e) { throw new RuntimeException("This shouldn't be possible"); }
2
            
// in main/java/org/junit/runner/Request.java
catch (InitializationError e) { throw new RuntimeException( "Bug in saff's brain: Suite constructor, called as above, should always complete"); }
// in main/java/org/junit/runners/Suite.java
catch (InitializationError e) { throw new RuntimeException("This shouldn't be possible"); }
2
unknown (Lib) InstantiationException 0 0 5
            
// in main/java/org/junit/experimental/theories/Theories.java
protected void runWithIncompleteAssignment(Assignments incomplete) throws InstantiationException, IllegalAccessException, Throwable { for (PotentialAssignment source : incomplete .potentialsForNextUnassigned()) { runWithAssignment(incomplete.assignNext(source)); } }
// in main/java/org/junit/experimental/theories/Theories.java
protected void runWithCompleteAssignment(final Assignments complete) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, Throwable { new BlockJUnit4ClassRunner(getTestClass().getJavaClass()) { @Override protected void collectInitializationErrors( List<Throwable> errors) { // do nothing } @Override public Statement methodBlock(FrameworkMethod method) { final Statement statement= super.methodBlock(method); return new Statement() { @Override public void evaluate() throws Throwable { try { statement.evaluate(); handleDataPointSuccess(); } catch (AssumptionViolatedException e) { handleAssumptionViolation(e); } catch (Throwable e) { reportParameterizedError(e, complete .getArgumentStrings(nullsOk())); } } }; } @Override protected Statement methodInvoker(FrameworkMethod method, Object test) { return methodCompletesWithParameters(method, complete, test); } @Override public Object createTest() throws Exception { return getTestClass().getOnlyConstructor().newInstance( complete.getConstructorArguments(nullsOk())); } }.methodBlock(fTestMethod).evaluate(); }
// in main/java/org/junit/experimental/theories/internal/Assignments.java
public List<PotentialAssignment> potentialsForNextUnassigned() throws InstantiationException, IllegalAccessException { ParameterSignature unassigned= nextUnassigned(); return getSupplier(unassigned).getValueSources(unassigned); }
// in main/java/org/junit/experimental/theories/internal/Assignments.java
public ParameterSupplier getSupplier(ParameterSignature unassigned) throws InstantiationException, IllegalAccessException { ParameterSupplier supplier= getAnnotatedSupplier(unassigned); if (supplier != null) return supplier; return new AllMembersSupplier(fClass); }
// in main/java/org/junit/experimental/theories/internal/Assignments.java
public ParameterSupplier getAnnotatedSupplier(ParameterSignature unassigned) throws InstantiationException, IllegalAccessException { ParametersSuppliedBy annotation= unassigned .findDeepAnnotation(ParametersSuppliedBy.class); if (annotation == null) return null; return annotation.value().newInstance(); }
1
            
// in main/java/junit/framework/TestSuite.java
catch (InstantiationException e) { return(warning("Cannot instantiate test case: "+name+" ("+exceptionToString(e)+")")); }
0 0
unknown (Lib) InterruptedException 0 0 1
            
// in main/java/org/junit/internal/runners/statements/FailOnTimeout.java
private StatementThread evaluateStatement() throws InterruptedException { StatementThread thread= new StatementThread(fOriginalStatement); thread.start(); thread.join(fTimeout); thread.interrupt(); return thread; }
2
            
// in main/java/junit/extensions/ActiveTestSuite.java
catch (InterruptedException e) { return; // ignore }
// in main/java/org/junit/internal/runners/statements/FailOnTimeout.java
catch (InterruptedException e) { //don't log the InterruptedException }
0 0
unknown (Lib) InvocationTargetException 0 0 2
            
// in main/java/org/junit/experimental/theories/Theories.java
protected void runWithCompleteAssignment(final Assignments complete) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, Throwable { new BlockJUnit4ClassRunner(getTestClass().getJavaClass()) { @Override protected void collectInitializationErrors( List<Throwable> errors) { // do nothing } @Override public Statement methodBlock(FrameworkMethod method) { final Statement statement= super.methodBlock(method); return new Statement() { @Override public void evaluate() throws Throwable { try { statement.evaluate(); handleDataPointSuccess(); } catch (AssumptionViolatedException e) { handleAssumptionViolation(e); } catch (Throwable e) { reportParameterizedError(e, complete .getArgumentStrings(nullsOk())); } } }; } @Override protected Statement methodInvoker(FrameworkMethod method, Object test) { return methodCompletesWithParameters(method, complete, test); } @Override public Object createTest() throws Exception { return getTestClass().getOnlyConstructor().newInstance( complete.getConstructorArguments(nullsOk())); } }.methodBlock(fTestMethod).evaluate(); }
// in main/java/org/junit/internal/runners/TestMethod.java
public void invoke(Object test) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { fMethod.invoke(test); }
11
            
// in main/java/junit/runner/BaseTestRunner.java
catch (InvocationTargetException e) { runFailed("Failed to invoke suite():" + e.getTargetException().toString()); return null; }
// in main/java/junit/framework/TestSuite.java
catch (InvocationTargetException e) { return(warning("Exception in constructor: "+name+" ("+exceptionToString(e.getTargetException())+")")); }
// in main/java/junit/framework/TestCase.java
catch (InvocationTargetException e) { e.fillInStackTrace(); throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/JUnit4ClassRunner.java
catch (InvocationTargetException e) { testAborted(notifier, description, e.getCause()); return; }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (InvocationTargetException e) { Throwable actual= e.getTargetException(); if (actual instanceof AssumptionViolatedException) return; else if (!fTestMethod.expectsException()) addFailure(actual); else if (fTestMethod.isUnexpected(actual)) { String message= "Unexpected exception, expected<" + fTestMethod.getExpectedException().getName() + "> but was<" + actual.getClass().getName() + ">"; addFailure(new Exception(message, actual)); } }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (InvocationTargetException e) { addFailure(e.getTargetException()); }
// in main/java/org/junit/internal/runners/model/ReflectiveCallable.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (InvocationTargetException e) { addFailure(e.getTargetException()); }
// in main/java/org/junit/internal/runners/SuiteMethod.java
catch (InvocationTargetException e) { throw e.getCause(); }
5
            
// in main/java/junit/framework/TestCase.java
catch (InvocationTargetException e) { e.fillInStackTrace(); throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/model/ReflectiveCallable.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in main/java/org/junit/internal/runners/SuiteMethod.java
catch (InvocationTargetException e) { throw e.getCause(); }
0
checked (Domain) MultipleFailureException
public class MultipleFailureException extends Exception {
	private static final long serialVersionUID= 1L;
	
	private final List<Throwable> fErrors;

	public MultipleFailureException(List<Throwable> errors) {
		fErrors= new ArrayList<Throwable>(errors);
	}

	public List<Throwable> getFailures() {
		return Collections.unmodifiableList(fErrors);
	}

	@Override
	public String getMessage() {
		StringBuilder sb = new StringBuilder(
				String.format("There were %d errors:", fErrors.size()));
		for (Throwable e : fErrors) {
			sb.append(String.format("\n  %s(%s)", e.getClass().getName(), e.getMessage()));
		}
		return sb.toString();
	}

	/**
	 * Asserts that a list of throwables is empty. If it isn't empty,
	 * will throw {@link MultipleFailureException} (if there are
	 * multiple throwables in the list) or the first element in the list
	 * (if there is only one element).
	 * 
	 * @param errors list to check
	 * @throws Throwable if the list is not empty
	 */
	@SuppressWarnings("deprecation")
	public static void assertEmpty(List<Throwable> errors) throws Throwable {
		if (errors.isEmpty())
			return;
		if (errors.size() == 1)
			throw errors.get(0);

		/*
		 * Many places in the code are documented to throw
		 * org.junit.internal.runners.model.MultipleFailureException.
		 * That class now extends this one, so we throw the internal
		 * exception in case developers have tests that catch
		 * MultipleFailureException.
		 */
		throw new org.junit.internal.runners.model.MultipleFailureException(errors);
	}
1 0 0 0 0 0
unknown (Lib) NoSuchMethodException 0 0 3
            
// in main/java/junit/framework/TestSuite.java
public static Constructor<?> getTestConstructor(Class<?> theClass) throws NoSuchMethodException { try { return theClass.getConstructor(String.class); } catch (NoSuchMethodException e) { // fall through } return theClass.getConstructor(new Class[0]); }
// in main/java/org/junit/experimental/theories/Theories.java
protected void runWithCompleteAssignment(final Assignments complete) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, Throwable { new BlockJUnit4ClassRunner(getTestClass().getJavaClass()) { @Override protected void collectInitializationErrors( List<Throwable> errors) { // do nothing } @Override public Statement methodBlock(FrameworkMethod method) { final Statement statement= super.methodBlock(method); return new Statement() { @Override public void evaluate() throws Throwable { try { statement.evaluate(); handleDataPointSuccess(); } catch (AssumptionViolatedException e) { handleAssumptionViolation(e); } catch (Throwable e) { reportParameterizedError(e, complete .getArgumentStrings(nullsOk())); } } }; } @Override protected Statement methodInvoker(FrameworkMethod method, Object test) { return methodCompletesWithParameters(method, complete, test); } @Override public Object createTest() throws Exception { return getTestClass().getOnlyConstructor().newInstance( complete.getConstructorArguments(nullsOk())); } }.methodBlock(fTestMethod).evaluate(); }
// in main/java/org/junit/internal/runners/TestClass.java
public Constructor<?> getConstructor() throws SecurityException, NoSuchMethodException { return fClass.getConstructor(); }
7
            
// in main/java/junit/framework/TestSuite.java
catch (NoSuchMethodException e) { return warning("Class "+theClass.getName()+" has no public constructor TestCase(String name) or TestCase()"); }
// in main/java/junit/framework/TestSuite.java
catch (NoSuchMethodException e) { // fall through }
// in main/java/junit/framework/TestSuite.java
catch (NoSuchMethodException e) { addTest(warning("Class "+theClass.getName()+" has no public constructor TestCase(String name) or TestCase()")); return; }
// in main/java/junit/framework/TestCase.java
catch (NoSuchMethodException e) { fail("Method \""+fName+"\" not found"); }
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
catch (NoSuchMethodException e) { try { return runnerClass.getConstructor(Class.class, RunnerBuilder.class).newInstance( new Object[] { testClass, fSuiteBuilder }); } catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); } }
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); }
// in main/java/org/junit/internal/builders/SuiteMethodBuilder.java
catch (NoSuchMethodException e) { return false; }
1
            
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
catch (NoSuchMethodException e) { try { return runnerClass.getConstructor(Class.class, RunnerBuilder.class).newInstance( new Object[] { testClass, fSuiteBuilder }); } catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); } }
// in main/java/org/junit/internal/builders/AnnotatedBuilder.java
catch (NoSuchMethodException e2) { String simpleName= runnerClass.getSimpleName(); throw new InitializationError(String.format( CONSTRUCTOR_ERROR_FORMAT, simpleName, simpleName)); }
0
checked (Domain) NoTestsRemainException
public class NoTestsRemainException extends Exception {
	private static final long serialVersionUID = 1L;
}
2
            
// in main/java/org/junit/internal/runners/JUnit4ClassRunner.java
public void filter(Filter filter) throws NoTestsRemainException { for (Iterator<Method> iter= fTestMethods.iterator(); iter.hasNext();) { Method method= iter.next(); if (!filter.shouldRun(methodDescription(method))) iter.remove(); } if (fTestMethods.isEmpty()) throw new NoTestsRemainException(); }
// in main/java/org/junit/runners/ParentRunner.java
public void filter(Filter filter) throws NoTestsRemainException { for (Iterator<T> iter = getFilteredChildren().iterator(); iter.hasNext(); ) { T each = iter.next(); if (shouldRun(filter, each)) try { filter.apply(each); } catch (NoTestsRemainException e) { iter.remove(); } else iter.remove(); } if (getFilteredChildren().isEmpty()) { throw new NoTestsRemainException(); } }
0 6
            
// in main/java/junit/framework/JUnit4TestAdapter.java
public void filter(Filter filter) throws NoTestsRemainException { filter.apply(fRunner); }
// in main/java/org/junit/runner/manipulation/Filter.java
Override public void apply(Object child) throws NoTestsRemainException { // do nothing }
// in main/java/org/junit/runner/manipulation/Filter.java
public void apply(Object child) throws NoTestsRemainException { if (!(child instanceof Filterable)) return; Filterable filterable= (Filterable) child; filterable.filter(this); }
// in main/java/org/junit/internal/runners/JUnit38ClassRunner.java
public void filter(Filter filter) throws NoTestsRemainException { if (getTest() instanceof Filterable) { Filterable adapter= (Filterable) getTest(); adapter.filter(filter); } else if (getTest() instanceof TestSuite) { TestSuite suite= (TestSuite) getTest(); TestSuite filtered= new TestSuite(suite.getName()); int n= suite.testCount(); for (int i= 0; i < n; i++) { Test test= suite.testAt(i); if (filter.shouldRun(makeDescription(test))) filtered.addTest(test); } setTest(filtered); } }
// in main/java/org/junit/internal/runners/JUnit4ClassRunner.java
public void filter(Filter filter) throws NoTestsRemainException { for (Iterator<Method> iter= fTestMethods.iterator(); iter.hasNext();) { Method method= iter.next(); if (!filter.shouldRun(methodDescription(method))) iter.remove(); } if (fTestMethods.isEmpty()) throw new NoTestsRemainException(); }
// in main/java/org/junit/runners/ParentRunner.java
public void filter(Filter filter) throws NoTestsRemainException { for (Iterator<T> iter = getFilteredChildren().iterator(); iter.hasNext(); ) { T each = iter.next(); if (shouldRun(filter, each)) try { filter.apply(each); } catch (NoTestsRemainException e) { iter.remove(); } else iter.remove(); } if (getFilteredChildren().isEmpty()) { throw new NoTestsRemainException(); } }
3
            
// in main/java/org/junit/experimental/categories/Categories.java
catch (NoTestsRemainException e) { throw new InitializationError(e); }
// in main/java/org/junit/internal/requests/FilterRequest.java
catch (NoTestsRemainException e) { return new ErrorReportingRunner(Filter.class, new Exception(String .format("No tests found matching %s from %s", fFilter .describe(), fRequest.toString()))); }
// in main/java/org/junit/runners/ParentRunner.java
catch (NoTestsRemainException e) { iter.remove(); }
1
            
// in main/java/org/junit/experimental/categories/Categories.java
catch (NoTestsRemainException e) { throw new InitializationError(e); }
0
unknown (Lib) NumberFormatException 0 0 0 1
            
// in main/java/junit/runner/BaseTestRunner.java
catch (NumberFormatException ne) { }
0 0
runtime (Domain) ParameterizedAssertionError
public class ParameterizedAssertionError extends RuntimeException {
	private static final long serialVersionUID = 1L;

	public ParameterizedAssertionError(Throwable targetException,
			String methodName, Object... params) {
		super(String.format("%s(%s)", methodName, join(", ", params)),
				targetException);
	}

	@Override public boolean equals(Object obj) {
		return toString().equals(obj.toString());
	}

	public static String join(String delimiter, Object... params) {
		return join(delimiter, Arrays.asList(params));
	}

	public static String join(String delimiter,
			Collection<Object> values) {
		StringBuffer buffer = new StringBuffer();
		Iterator<Object> iter = values.iterator();
		while (iter.hasNext()) {
			Object next = iter.next();
			buffer.append(stringValueOf(next));
			if (iter.hasNext()) {
				buffer.append(delimiter);
			}
		}
		return buffer.toString();
	}

	private static String stringValueOf(Object next) {
		try {
			return String.valueOf(next);
		} catch (Throwable e) {
			return "[toString failed]";
		}
	}
}
1
            
// in main/java/org/junit/experimental/theories/Theories.java
protected void reportParameterizedError(Throwable e, Object... params) throws Throwable { if (params.length == 0) throw e; throw new ParameterizedAssertionError(e, fTestMethod.getName(), params); }
0 0 0 0 0
runtime (Lib) RuntimeException 12
            
// in main/java/junit/framework/JUnit4TestCaseFacade.java
public void run(TestResult result) { throw new RuntimeException( "This test stub created only for informational purposes."); }
// in main/java/org/junit/runner/Request.java
public static Request classes(Computer computer, Class<?>... classes) { try { AllDefaultPossibilitiesBuilder builder= new AllDefaultPossibilitiesBuilder(true); Runner suite= computer.getSuite(builder, classes); return runner(suite); } catch (InitializationError e) { throw new RuntimeException( "Bug in saff's brain: Suite constructor, called as above, should always complete"); } }
// in main/java/org/junit/experimental/max/MaxCore.java
private Runner buildRunner(Description each) { if (each.toString().equals("TestSuite with 0 tests")) return Suite.emptySuite(); if (each.toString().startsWith(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX)) // This is cheating, because it runs the whole class // to get the warning for this method, but we can't do better, // because JUnit 3.8's // thrown away which method the warning is for. return new JUnit38ClassRunner(new TestSuite(getMalformedTestClass(each))); Class<?> type= each.getTestClass(); if (type == null) throw new RuntimeException("Can't build a runner from description [" + each + "]"); String methodName= each.getMethodName(); if (methodName == null) return Request.aClass(type).getRunner(); return Request.method(type, methodName).getRunner(); }
// in main/java/org/junit/experimental/results/FailureList.java
public Result result() { Result result= new Result(); RunListener listener= result.createListener(); for (Failure failure : failures) { try { listener.testFailure(failure); } catch (Exception e) { throw new RuntimeException("I can't believe this happened"); } } return result; }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
Override public Object getValue() throws CouldNotGenerateValueException { try { return fMethod.invokeExplosively(null); } catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: argument length is checked"); } catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getMethods returned an inaccessible method"); } catch (Throwable e) { throw new CouldNotGenerateValueException(); // do nothing, just look for more values } }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
private Object getStaticFieldValue(final Field field) { try { return field.get(null); } catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: field from getClass doesn't exist on object"); } catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getFields returned an inaccessible field"); } }
// in main/java/org/junit/internal/runners/MethodRoadie.java
public void runBeforesThenTestThenAfters(Runnable test) { try { runBefores(); test.run(); } catch (FailedBefore e) { } catch (Exception e) { throw new RuntimeException("test should never throw an exception to this level"); } finally { runAfters(); } }
// in main/java/org/junit/runners/model/TestClass.java
public <T> List<T> getAnnotatedFieldValues(Object test, Class<? extends Annotation> annotationClass, Class<T> valueClass) { List<T> results= new ArrayList<T>(); for (FrameworkField each : getAnnotatedFields(annotationClass)) { try { Object fieldValue= each.get(test); if (valueClass.isInstance(fieldValue)) results.add(valueClass.cast(fieldValue)); } catch (IllegalAccessException e) { throw new RuntimeException( "How did getFields return a field we couldn't access?", e); } } return results; }
// in main/java/org/junit/runners/model/TestClass.java
public <T> List<T> getAnnotatedMethodValues(Object test, Class<? extends Annotation> annotationClass, Class<T> valueClass) { List<T> results= new ArrayList<T>(); for (FrameworkMethod each : getAnnotatedMethods(annotationClass)) { try { Object fieldValue= each.invokeExplosively(test, new Object[]{}); if (valueClass.isInstance(fieldValue)) results.add(valueClass.cast(fieldValue)); } catch (Throwable e) { throw new RuntimeException( "Exception in " + each.getName(), e); } } return results; }
// in main/java/org/junit/runners/Suite.java
public static Runner emptySuite() { try { return new Suite((Class<?>)null, new Class<?>[0]); } catch (InitializationError e) { throw new RuntimeException("This shouldn't be possible"); } }
10
            
// in main/java/org/junit/runner/Request.java
catch (InitializationError e) { throw new RuntimeException( "Bug in saff's brain: Suite constructor, called as above, should always complete"); }
// in main/java/org/junit/experimental/results/FailureList.java
catch (Exception e) { throw new RuntimeException("I can't believe this happened"); }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: argument length is checked"); }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getMethods returned an inaccessible method"); }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalArgumentException e) { throw new RuntimeException( "unexpected: field from getClass doesn't exist on object"); }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (IllegalAccessException e) { throw new RuntimeException( "unexpected: getFields returned an inaccessible field"); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Exception e) { throw new RuntimeException("test should never throw an exception to this level"); }
// in main/java/org/junit/runners/model/TestClass.java
catch (IllegalAccessException e) { throw new RuntimeException( "How did getFields return a field we couldn't access?", e); }
// in main/java/org/junit/runners/model/TestClass.java
catch (Throwable e) { throw new RuntimeException( "Exception in " + each.getName(), e); }
// in main/java/org/junit/runners/Suite.java
catch (InitializationError e) { throw new RuntimeException("This shouldn't be possible"); }
0 0 0 0
runtime (Domain) StoppedByUserException
public class StoppedByUserException extends RuntimeException {
	private static final long serialVersionUID= 1L;
}
1
            
// in main/java/org/junit/runner/notification/RunNotifier.java
public void fireTestStarted(final Description description) throws StoppedByUserException { if (fPleaseStop) throw new StoppedByUserException(); new SafeNotifier() { @Override protected void notifyListener(RunListener each) throws Exception { each.testStarted(description); }; }.run(); }
0 1
            
// in main/java/org/junit/runner/notification/RunNotifier.java
public void fireTestStarted(final Description description) throws StoppedByUserException { if (fPleaseStop) throw new StoppedByUserException(); new SafeNotifier() { @Override protected void notifyListener(RunListener each) throws Exception { each.testStarted(description); }; }.run(); }
1
            
// in main/java/org/junit/runners/ParentRunner.java
catch (StoppedByUserException e) { throw e; }
1
            
// in main/java/org/junit/runners/ParentRunner.java
catch (StoppedByUserException e) { throw e; }
0
unknown (Lib) ThreadDeath 0 0 0 1
            
// in main/java/junit/framework/TestResult.java
catch (ThreadDeath e) { // don't catch ThreadDeath by accident throw e; }
1
            
// in main/java/junit/framework/TestResult.java
catch (ThreadDeath e) { // don't catch ThreadDeath by accident throw e; }
0
checked (Lib) Throwable 0 0 45
            
// in main/java/junit/framework/TestResult.java
protected void run(final TestCase test) { startTest(test); Protectable p= new Protectable() { public void protect() throws Throwable { test.runBare(); } }; runProtected(test, p); endTest(test); }
// in main/java/junit/framework/TestResult.java
public void protect() throws Throwable { test.runBare(); }
// in main/java/junit/framework/TestCase.java
public void runBare() throws Throwable { Throwable exception= null; setUp(); try { runTest(); } catch (Throwable running) { exception= running; } finally { try { tearDown(); } catch (Throwable tearingDown) { if (exception == null) exception= tearingDown; } } if (exception != null) throw exception; }
// in main/java/junit/framework/TestCase.java
protected void runTest() throws Throwable { assertNotNull("TestCase.fName cannot be null", fName); // Some VMs crash when calling getMethod(null,null); Method runMethod= null; try { // use getMethod to get all public inherited // methods. getDeclaredMethods returns all // methods of this class but excludes the // inherited ones. runMethod= getClass().getMethod(fName, (Class[])null); } catch (NoSuchMethodException e) { fail("Method \""+fName+"\" not found"); } if (!Modifier.isPublic(runMethod.getModifiers())) { fail("Method \""+fName+"\" should be public"); } try { runMethod.invoke(this); } catch (InvocationTargetException e) { e.fillInStackTrace(); throw e.getTargetException(); } catch (IllegalAccessException e) { e.fillInStackTrace(); throw e; } }
// in main/java/org/junit/runner/Computer.java
public Runner getSuite(final RunnerBuilder builder, Class<?>[] classes) throws InitializationError { return new Suite(new RunnerBuilder() { @Override public Runner runnerForClass(Class<?> testClass) throws Throwable { return getRunner(builder, testClass); } }, classes); }
// in main/java/org/junit/runner/Computer.java
Override public Runner runnerForClass(Class<?> testClass) throws Throwable { return getRunner(builder, testClass); }
// in main/java/org/junit/runner/Computer.java
protected Runner getRunner(RunnerBuilder builder, Class<?> testClass) throws Throwable { return builder.runnerForClass(testClass); }
// in main/java/org/junit/rules/ExpectedException.java
Override public void evaluate() throws Throwable { try { fNext.evaluate(); } catch (AssumptionViolatedException e) { optionallyHandleException(e, handleAssumptionViolatedExceptions); return; } catch (AssertionError e) { optionallyHandleException(e, handleAssertionErrors); return; } catch (Throwable e) { handleException(e); return; } if (fMatcher != null) throw new AssertionError("Expected test to throw " + StringDescription.toString(fMatcher)); }
// in main/java/org/junit/rules/ExpectedException.java
private void optionallyHandleException(Throwable e, boolean handleException) throws Throwable { if (handleException) handleException(e); else throw e; }
// in main/java/org/junit/rules/ExpectedException.java
private void handleException(Throwable e) throws Throwable { if (fMatcher == null) throw e; assertThat(e, fMatcher); }
// in main/java/org/junit/rules/RunRules.java
Override public void evaluate() throws Throwable { statement.evaluate(); }
// in main/java/org/junit/rules/TestWatcher.java
public Statement apply(final Statement base, final Description description) { return new Statement() { @Override public void evaluate() throws Throwable { starting(description); try { base.evaluate(); succeeded(description); } catch (AssumptionViolatedException e) { throw e; } catch (Throwable t) { failed(t, description); throw t; } finally { finished(description); } } }; }
// in main/java/org/junit/rules/TestWatcher.java
Override public void evaluate() throws Throwable { starting(description); try { base.evaluate(); succeeded(description); } catch (AssumptionViolatedException e) { throw e; } catch (Throwable t) { failed(t, description); throw t; } finally { finished(description); } }
// in main/java/org/junit/rules/TemporaryFolder.java
Override protected void before() throws Throwable { create(); }
// in main/java/org/junit/rules/Verifier.java
public Statement apply(final Statement base, Description description) { return new Statement() { @Override public void evaluate() throws Throwable { base.evaluate(); verify(); } }; }
// in main/java/org/junit/rules/Verifier.java
Override public void evaluate() throws Throwable { base.evaluate(); verify(); }
// in main/java/org/junit/rules/Verifier.java
protected void verify() throws Throwable { }
// in main/java/org/junit/rules/ExternalResource.java
private Statement statement(final Statement base) { return new Statement() { @Override public void evaluate() throws Throwable { before(); try { base.evaluate(); } finally { after(); } } }; }
// in main/java/org/junit/rules/ExternalResource.java
Override public void evaluate() throws Throwable { before(); try { base.evaluate(); } finally { after(); } }
// in main/java/org/junit/rules/ExternalResource.java
protected void before() throws Throwable { // do nothing }
// in main/java/org/junit/rules/TestWatchman.java
public Statement apply(final Statement base, final FrameworkMethod method, Object target) { return new Statement() { @Override public void evaluate() throws Throwable { starting(method); try { base.evaluate(); succeeded(method); } catch (AssumptionViolatedException e) { throw e; } catch (Throwable t) { failed(t, method); throw t; } finally { finished(method); } } }; }
// in main/java/org/junit/rules/TestWatchman.java
Override public void evaluate() throws Throwable { starting(method); try { base.evaluate(); succeeded(method); } catch (AssumptionViolatedException e) { throw e; } catch (Throwable t) { failed(t, method); throw t; } finally { finished(method); } }
// in main/java/org/junit/rules/ErrorCollector.java
Override protected void verify() throws Throwable { MultipleFailureException.assertEmpty(errors); }
// in main/java/org/junit/experimental/theories/Theories.java
Override public void evaluate() throws Throwable { runWithAssignment(Assignments.allUnassigned( fTestMethod.getMethod(), getTestClass())); if (successes == 0) Assert .fail("Never found parameters that satisfied method assumptions. Violated assumptions: " + fInvalidParameters); }
// in main/java/org/junit/experimental/theories/Theories.java
protected void runWithAssignment(Assignments parameterAssignment) throws Throwable { if (!parameterAssignment.isComplete()) { runWithIncompleteAssignment(parameterAssignment); } else { runWithCompleteAssignment(parameterAssignment); } }
// in main/java/org/junit/experimental/theories/Theories.java
protected void runWithIncompleteAssignment(Assignments incomplete) throws InstantiationException, IllegalAccessException, Throwable { for (PotentialAssignment source : incomplete .potentialsForNextUnassigned()) { runWithAssignment(incomplete.assignNext(source)); } }
// in main/java/org/junit/experimental/theories/Theories.java
protected void runWithCompleteAssignment(final Assignments complete) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, Throwable { new BlockJUnit4ClassRunner(getTestClass().getJavaClass()) { @Override protected void collectInitializationErrors( List<Throwable> errors) { // do nothing } @Override public Statement methodBlock(FrameworkMethod method) { final Statement statement= super.methodBlock(method); return new Statement() { @Override public void evaluate() throws Throwable { try { statement.evaluate(); handleDataPointSuccess(); } catch (AssumptionViolatedException e) { handleAssumptionViolation(e); } catch (Throwable e) { reportParameterizedError(e, complete .getArgumentStrings(nullsOk())); } } }; } @Override protected Statement methodInvoker(FrameworkMethod method, Object test) { return methodCompletesWithParameters(method, complete, test); } @Override public Object createTest() throws Exception { return getTestClass().getOnlyConstructor().newInstance( complete.getConstructorArguments(nullsOk())); } }.methodBlock(fTestMethod).evaluate(); }
// in main/java/org/junit/experimental/theories/Theories.java
Override public Statement methodBlock(FrameworkMethod method) { final Statement statement= super.methodBlock(method); return new Statement() { @Override public void evaluate() throws Throwable { try { statement.evaluate(); handleDataPointSuccess(); } catch (AssumptionViolatedException e) { handleAssumptionViolation(e); } catch (Throwable e) { reportParameterizedError(e, complete .getArgumentStrings(nullsOk())); } } }; }
// in main/java/org/junit/experimental/theories/Theories.java
Override public void evaluate() throws Throwable { try { statement.evaluate(); handleDataPointSuccess(); } catch (AssumptionViolatedException e) { handleAssumptionViolation(e); } catch (Throwable e) { reportParameterizedError(e, complete .getArgumentStrings(nullsOk())); } }
// in main/java/org/junit/experimental/theories/Theories.java
private Statement methodCompletesWithParameters( final FrameworkMethod method, final Assignments complete, final Object freshInstance) { return new Statement() { @Override public void evaluate() throws Throwable { try { final Object[] values= complete.getMethodArguments( nullsOk()); method.invokeExplosively(freshInstance, values); } catch (CouldNotGenerateValueException e) { // ignore } } }; }
// in main/java/org/junit/experimental/theories/Theories.java
Override public void evaluate() throws Throwable { try { final Object[] values= complete.getMethodArguments( nullsOk()); method.invokeExplosively(freshInstance, values); } catch (CouldNotGenerateValueException e) { // ignore } }
// in main/java/org/junit/experimental/theories/Theories.java
protected void reportParameterizedError(Throwable e, Object... params) throws Throwable { if (params.length == 0) throw e; throw new ParameterizedAssertionError(e, fTestMethod.getName(), params); }
// in main/java/org/junit/experimental/ParallelComputer.java
Override protected Runner getRunner(RunnerBuilder builder, Class<?> testClass) throws Throwable { Runner runner= super.getRunner(builder, testClass); return fMethods ? parallelize(runner) : runner; }
// in main/java/org/junit/internal/runners/statements/RunBefores.java
Override public void evaluate() throws Throwable { for (FrameworkMethod before : fBefores) before.invokeExplosively(fTarget); fNext.evaluate(); }
// in main/java/org/junit/internal/runners/statements/FailOnTimeout.java
Override public void evaluate() throws Throwable { StatementThread thread= evaluateStatement(); if (!thread.fFinished) throwExceptionForUnfinishedThread(thread); }
// in main/java/org/junit/internal/runners/statements/FailOnTimeout.java
private void throwExceptionForUnfinishedThread(StatementThread thread) throws Throwable { if (thread.fExceptionThrownByOriginalStatement != null) throw thread.fExceptionThrownByOriginalStatement; else throwTimeoutException(thread); }
// in main/java/org/junit/internal/runners/statements/RunAfters.java
Override public void evaluate() throws Throwable { List<Throwable> errors = new ArrayList<Throwable>(); try { fNext.evaluate(); } catch (Throwable e) { errors.add(e); } finally { for (FrameworkMethod each : fAfters) try { each.invokeExplosively(fTarget); } catch (Throwable e) { errors.add(e); } } MultipleFailureException.assertEmpty(errors); }
// in main/java/org/junit/internal/runners/statements/Fail.java
Override public void evaluate() throws Throwable { throw fError; }
// in main/java/org/junit/internal/runners/statements/InvokeMethod.java
Override public void evaluate() throws Throwable { fTestMethod.invokeExplosively(fTarget); }
// in main/java/org/junit/internal/runners/model/ReflectiveCallable.java
public Object run() throws Throwable { try { return runReflectiveCall(); } catch (InvocationTargetException e) { throw e.getTargetException(); } }
// in main/java/org/junit/internal/runners/SuiteMethod.java
public static Test testFromSuiteMethod(Class<?> klass) throws Throwable { Method suiteMethod= null; Test suite= null; try { suiteMethod= klass.getMethod("suite"); if (! Modifier.isStatic(suiteMethod.getModifiers())) { throw new Exception(klass.getName() + ".suite() must be static"); } suite= (Test) suiteMethod.invoke(null); // static method } catch (InvocationTargetException e) { throw e.getCause(); } return suite; }
// in main/java/org/junit/internal/builders/NullBuilder.java
Override public Runner runnerForClass(Class<?> each) throws Throwable { return null; }
// in main/java/org/junit/internal/builders/JUnit3Builder.java
Override public Runner runnerForClass(Class<?> testClass) throws Throwable { if (isPre4Test(testClass)) return new JUnit38ClassRunner(testClass); return null; }
// in main/java/org/junit/internal/builders/JUnit4Builder.java
Override public Runner runnerForClass(Class<?> testClass) throws Throwable { return new BlockJUnit4ClassRunner(testClass); }
// in main/java/org/junit/internal/builders/SuiteMethodBuilder.java
Override public Runner runnerForClass(Class<?> each) throws Throwable { if (hasSuiteMethod(each)) return new SuiteMethod(each); return null; }
// in main/java/org/junit/internal/builders/AllDefaultPossibilitiesBuilder.java
Override public Runner runnerForClass(Class<?> testClass) throws Throwable { List<RunnerBuilder> builders= Arrays.asList( ignoredBuilder(), annotatedBuilder(), suiteMethodBuilder(), junit3Builder(), junit4Builder()); for (RunnerBuilder each : builders) { Runner runner= each.safeRunnerForClass(testClass); if (runner != null) return runner; } return null; }
// in main/java/org/junit/runners/model/FrameworkMethod.java
public Object invokeExplosively(final Object target, final Object... params) throws Throwable { return new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return fMethod.invoke(target, params); } }.run(); }
// in main/java/org/junit/runners/model/FrameworkMethod.java
Override protected Object runReflectiveCall() throws Throwable { return fMethod.invoke(target, params); }
// in main/java/org/junit/runners/BlockJUnit4ClassRunner.java
protected Statement methodBlock(FrameworkMethod method) { Object test; try { test= new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return createTest(); } }.run(); } catch (Throwable e) { return new Fail(e); } Statement statement= methodInvoker(method, test); statement= possiblyExpectingExceptions(method, test, statement); statement= withPotentialTimeout(method, test, statement); statement= withBefores(method, test, statement); statement= withAfters(method, test, statement); statement= withRules(method, test, statement); return statement; }
// in main/java/org/junit/runners/BlockJUnit4ClassRunner.java
Override protected Object runReflectiveCall() throws Throwable { return createTest(); }
25
            
// in main/java/junit/framework/TestResult.java
catch (Throwable e) { addError(test, e); }
// in main/java/junit/framework/TestCase.java
catch (Throwable running) { exception= running; }
// in main/java/junit/framework/TestCase.java
catch (Throwable tearingDown) { if (exception == null) exception= tearingDown; }
// in main/java/org/junit/rules/ExpectedException.java
catch (Throwable e) { handleException(e); return; }
// in main/java/org/junit/rules/TestWatcher.java
catch (Throwable t) { failed(t, description); throw t; }
// in main/java/org/junit/rules/TestWatchman.java
catch (Throwable t) { failed(t, method); throw t; }
// in main/java/org/junit/rules/ErrorCollector.java
catch (Throwable e) { addError(e); return null; }
// in main/java/org/junit/experimental/theories/Theories.java
catch (Throwable e) { reportParameterizedError(e, complete .getArgumentStrings(nullsOk())); }
// in main/java/org/junit/experimental/theories/internal/ParameterizedAssertionError.java
catch (Throwable e) { return "[toString failed]"; }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (Throwable e) { throw new CouldNotGenerateValueException(); // do nothing, just look for more values }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (Throwable e) { // ignore and move on }
// in main/java/org/junit/internal/runners/statements/FailOnTimeout.java
catch (Throwable e) { fExceptionThrownByOriginalStatement= e; }
// in main/java/org/junit/internal/runners/statements/RunAfters.java
catch (Throwable e) { errors.add(e); }
// in main/java/org/junit/internal/runners/statements/RunAfters.java
catch (Throwable e) { errors.add(e); }
// in main/java/org/junit/internal/runners/statements/ExpectException.java
catch (Throwable e) { if (!fExpected.isAssignableFrom(e.getClass())) { String message= "Unexpected exception, expected<" + fExpected.getName() + "> but was<" + e.getClass().getName() + ">"; throw new Exception(message, e); } }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Throwable e) { addFailure(e); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Throwable e) { addFailure(e); throw new FailedBefore(); }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Throwable e) { addFailure(e); // Untested, but seems impossible }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (Throwable e) { addFailure(e); throw new FailedBefore(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (Throwable e) { addFailure(e); // Untested, but seems impossible }
// in main/java/org/junit/runners/ParentRunner.java
catch (Throwable e) { eachNotifier.addFailure(e); }
// in main/java/org/junit/runners/ParentRunner.java
catch (Throwable e) { testNotifier.addFailure(e); }
// in main/java/org/junit/runners/model/TestClass.java
catch (Throwable e) { throw new RuntimeException( "Exception in " + each.getName(), e); }
// in main/java/org/junit/runners/model/RunnerBuilder.java
catch (Throwable e) { return new ErrorReportingRunner(testClass, e); }
// in main/java/org/junit/runners/BlockJUnit4ClassRunner.java
catch (Throwable e) { return new Fail(e); }
7
            
// in main/java/org/junit/rules/TestWatcher.java
catch (Throwable t) { failed(t, description); throw t; }
// in main/java/org/junit/rules/TestWatchman.java
catch (Throwable t) { failed(t, method); throw t; }
// in main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
catch (Throwable e) { throw new CouldNotGenerateValueException(); // do nothing, just look for more values }
// in main/java/org/junit/internal/runners/statements/ExpectException.java
catch (Throwable e) { if (!fExpected.isAssignableFrom(e.getClass())) { String message= "Unexpected exception, expected<" + fExpected.getName() + "> but was<" + e.getClass().getName() + ">"; throw new Exception(message, e); } }
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (Throwable e) { addFailure(e); throw new FailedBefore(); }
// in main/java/org/junit/internal/runners/ClassRoadie.java
catch (Throwable e) { addFailure(e); throw new FailedBefore(); }
// in main/java/org/junit/runners/model/TestClass.java
catch (Throwable e) { throw new RuntimeException( "Exception in " + each.getName(), e); }
1
unknown (Lib) TimeoutException 0 0 0 1
            
// in main/java/org/junit/internal/runners/MethodRoadie.java
catch (TimeoutException e) { addFailure(new Exception(String.format("test timed out after %d milliseconds", timeout))); }
0 0

Miscellanous Metrics

nF = Number of Finally 15
nF = Number of Try-Finally (without catch) 8
Number of Methods with Finally (nMF) 14 / 1003 (1.4%)
Number of Finally with a Continue 0
Number of Finally with a Return 0
Number of Finally with a Throw 0
Number of Finally with a Break 0
Number of different exception types thrown 18
Number of Domain exception types thrown 11
Number of different exception types caught 24
Number of Domain exception types caught 8
Number of exception declarations in signatures 181
Number of different exceptions types declared in method signatures 18
Number of library exceptions types declared in method signatures 12
Number of Domain exceptions types declared in method signatures 6
Number of Catch with a continue 0
Number of Catch with a return 28
Number of Catch with a Break 0
nbIf = Number of If 266
nbFor = Number of For 105
Number of Method with an if 183 / 1003
Number of Methods with a for 98 / 1003
Number of Method starting with a try 25 / 1003 (2.5%)
Number of Expressions 4762
Number of Expressions in try 524 (11%)