All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.junit.internal.AssumptionViolatedException Maven / Gradle / Ivy

Go to download

JUnit is a regression testing framework written by Erich Gamma and Kent Beck. It is used by the developer who implements unit tests in Java.

There is a newer version: 4.11
Show newest version
package org.junit.internal;

import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.SelfDescribing;
import org.hamcrest.StringDescription;

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);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy