首页 > 解决方案 > Hamcrest CombinableMatcher 的评估顺序

问题描述

我想为匹配器编写一个逻辑,例如matcher_1 AND matcher_2 OR matcher_3 and matcher_4hamcrestmatcher_i匹配器的占位符。

我决定这样写CombinableMatcher-

new CombinableMatcher<String>(matcher_1).and(matcher_2).or(matcher_3).and(matcher_4)

现在,问题是匹配器的评估顺序是什么?

会是((((matcher_1) AND matcher_2) OR matcher_3) and matcher_4)还是其他类似的命令((matcher_1 AND matcher_2) OR (matcher_3 and matcher_4))

标签: javamockitohamcrest

解决方案


很高兴看到有人理解编写匹配器的想法。

我想知道你为什么关心匹配器的顺序?理想情况下,这无关紧要,因为您也不知道匹配器被调用的频率。

如果您在此详细程度遇到问题,最好编写自定义匹配器。


推荐阅读