是否可以用“或”逻辑写一个流畅的断言?
例如,要在一行中进行String
startsWith
smth 或 endsWith
smth的测试,而不是像这样的奇怪构造:
Assertions.assertThat(actual.startsWith("a") || actual.endsWith("b")).isTrue();
或更详细
Assertions.assertThat(actual).is(Assertions.anyOf(new Condition<String>() {
@Override
public boolean matches(String value) {
return value.startsWith("a");
}
}, new Condition<String>() {
@Override
public boolean matches(String value) {
return value.startsWith("b");
}
}));