问题假设进行以下简单测试:@Testpublicvoidtest()throwsException{Objectvalue=1;assertThat(value,greaterThan(0));}测试不会编译,因为“greaterThan”只能应用于类型Comparable的实例。但我想断言value是一个大于零的整数。我如何使用Hamcrest表达这一点?到目前为止我尝试了什么:简单的解决方案是通过像这样转换匹配器来简单地删除泛型:assertThat(value,(Matcher)greaterThan(0));可能,但会生成编译器警告并感觉不对。一个冗长的选择是:@Testpub