當前位置: 首頁>>代碼示例>>Java>>正文


Java Description.toString方法代碼示例

本文整理匯總了Java中org.hamcrest.Description.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java Description.toString方法的具體用法?Java Description.toString怎麽用?Java Description.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.hamcrest.Description的用法示例。


在下文中一共展示了Description.toString方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: assertThatClassIsImmutable

import org.hamcrest.Description; //導入方法依賴的package包/類
/**
 * Assert that the given class adheres to the immutable class rules.
 *
 * @param clazz the class to check
 *
 * @throws java.lang.AssertionError if the class is not an
 *         immutable class
 */
public static void assertThatClassIsImmutable(Class<?> clazz) {
    final ImmutableClassChecker checker = new ImmutableClassChecker();
    if (!checker.isImmutableClass(clazz, false)) {
        final Description toDescription = new StringDescription();
        final Description mismatchDescription = new StringDescription();

        checker.describeTo(toDescription);
        checker.describeMismatch(mismatchDescription);
        final String reason =
                "\n" +
                "Expected: is \"" + toDescription.toString() + "\"\n" +
                "    but : was \"" + mismatchDescription.toString() + "\"";

        throw new AssertionError(reason);
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:25,代碼來源:ImmutableClassChecker.java

示例2: assertThatClassIsImmutableBaseClass

import org.hamcrest.Description; //導入方法依賴的package包/類
/**
 * Assert that the given class adheres to the immutable class rules, but
 * is not declared final.  Classes that need to be inherited from cannot be
 * declared final.
 *
 * @param clazz the class to check
 *
 * @throws java.lang.AssertionError if the class is not an
 *         immutable class
 */
public static void assertThatClassIsImmutableBaseClass(Class<?> clazz) {
    final ImmutableClassChecker checker = new ImmutableClassChecker();
    if (!checker.isImmutableClass(clazz, true)) {
        final Description toDescription = new StringDescription();
        final Description mismatchDescription = new StringDescription();

        checker.describeTo(toDescription);
        checker.describeMismatch(mismatchDescription);
        final String reason =
                "\n" +
                        "Expected: is \"" + toDescription.toString() + "\"\n" +
                        "    but : was \"" + mismatchDescription.toString() + "\"";

        throw new AssertionError(reason);
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:27,代碼來源:ImmutableClassChecker.java

示例3: assertThatClassIsUtility

import org.hamcrest.Description; //導入方法依賴的package包/類
/**
 * Assert that the given class adheres to the utility class rules.
 *
 * @param clazz the class to check
 *
 * @throws java.lang.AssertionError if the class is not a valid
 *         utility class
 */
public static void assertThatClassIsUtility(Class<?> clazz) {
    final UtilityClassChecker checker = new UtilityClassChecker();
    if (!checker.isProperlyDefinedUtilityClass(clazz)) {
        final Description toDescription = new StringDescription();
        final Description mismatchDescription = new StringDescription();

        checker.describeTo(toDescription);
        checker.describeMismatch(mismatchDescription);
        final String reason =
            "\n" +
            "Expected: is \"" + toDescription.toString() + "\"\n" +
            "    but : was \"" + mismatchDescription.toString() + "\"";

        throw new AssertionError(reason);
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:25,代碼來源:UtilityClassChecker.java

示例4: fail

import org.hamcrest.Description; //導入方法依賴的package包/類
static void fail(@Nullable Object actualValue, Matcher<?> matcher) {
  Description description =
      new StringDescription()
          .appendText("\nExpected: ")
          .appendDescriptionOf(matcher)
          .appendText("\n     but: ");
  matcher.describeMismatch(actualValue, description);
  AssertionError assertionError = new AssertionError(description.toString());
  assertionError.setStackTrace(ObjectChecker.trimStackTrace(assertionError.getStackTrace()));
  throw assertionError;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:ObjectChecker.java

示例5: assertThat

import org.hamcrest.Description; //導入方法依賴的package包/類
@Step("Matching Actual - {1} and Expected {2}")
public static <T> void assertThat(String reason, T actual, Matcher<? super T> matcher) {
    if (!matcher.matches(actual)) {
        Description description = new StringDescription();
        description.appendText(reason)
                .appendText("\nExpected: ")
                .appendDescriptionOf(matcher)
                .appendText("\n     but: ");
        matcher.describeMismatch(actual, description);
        
        ScreenShotUtil.takeScreenShot();
        throw new AssertionError(description.toString());
    }
}
 
開發者ID:hemano,項目名稱:cucumber-framework-java,代碼行數:15,代碼來源:UpdateAssert.java


注:本文中的org.hamcrest.Description.toString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。