[英]How to test a Google Guava Predicate factory kind of class
I have a class called XxxPredicateFactory which return a single predicate or predicate combination. 我有一个称为XxxPredicateFactory的类,该类返回单个谓词或谓词组合。 Something like this: 像这样:
Public class XxxPredicateFactory {
public Predicate<Abc> create() {
if (this) {
return new HelloPredicate<Abc>();
}
else if (that) {
return new WorldPredicate<Abc>();
}
else {
return Predicates.or(new HelloPredicate<Abc>(), new WorldPredicate<Abc>());
}
}
}
For the if and else if, it seems easy to test, but for the else part I am not quite sure how can I test this? 对于if和else if,似乎很容易测试,但是对于else部分,我不太确定如何进行测试? How can I capture this situation? 如何捕捉这种情况?
你能不只是测试返回的谓词返回true
两种东西, HelloPredicate
应该返回true
的和事WorldPredicate
应返回true
的呢?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.