简体   繁体   English

如何测试Google Guava谓词工厂类的类

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM