问题描述
是否可以使用聚合器聚合多个对象,每个对象都从先前的聚合未使用的第一个索引开始?
在该示例中,第一个参数为true,true
,第二个参数为true,false
,但是它们都使用true,true
。
我尝试使用context.getIndex()
,但是只有在我知道以前聚合器的长度时,该方法才起作用。
public class Test {
@ParameterizedTest
@CsvSource({ "true,true,false" })
void test(@AggregateWith(And.class) boolean first,@AggregateWith(And.class) boolean second) {
assertthat(first).isTrue();
assertthat(second).isFalse();
}
}
class And implements ArgumentsAggregator {
@Override
public Object aggregateArguments(ArgumentsAccessor arguments,ParameterContext context) throws ArgumentsAggregationException {
return arguments.getBoolean(0) && arguments.getBoolean(1);
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)