我进行了以下测试:
testHarness.processElement2(new StreamRecord<>(element1));
testHarness.processElement1(new StreamRecord<>(new Tuple2<>(id, element2)));
testHarness.setProcessingTime(1); //let's assume it's the correct time for the timer inside the function
softly.assertThat(testHarness.getOutput()).containsExactly(new StreamRecord<>(expectedResult)); //this one is passed
testHarness.setProcessingTime(2); // setting second timer which will trigger different timer
softly.assertThat(testHarness.getOutput()).containsExactly(new StreamRecord<>(expectedResult2)); //fails cause output has expectedResult & expectedResult2
为什么一旦调用getOutput(),TestHarness就不清除其元素?可以通过某种方式实现此功能吗?
答案 0 :(得分:1)
这可以通过在输出中调用clear()来实现:
y_test