当前位置: 首页>>代码示例>>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;未经允许,请勿转载。