org.hamcrest.junit.internal.Matching Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hamcrest-junit Show documentation
Show all versions of hamcrest-junit Show documentation
Classes to use Hamcrest matchers within JUnit tests
/* Copyright (c) 2000-2006 hamcrest.org
*/
package org.hamcrest.junit.internal;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.StringDescription;
public class Matching {
public static void checkMatch(String reason, T actual, Matcher super T> matcher, MismatchAction action) {
if (!matcher.matches(actual)) {
Description description = new StringDescription();
description.appendText(reason)
.appendText("\nExpected: ")
.appendDescriptionOf(matcher)
.appendText("\n but: ");
matcher.describeMismatch(actual, description);
action.mismatch(description.toString());
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy