And another question: which library should I include in order to use these 
harnesses? I do have this flink-test-utils_2.11 in my pom, but I cannot find 
the harnesses.

I also have the following in my pom:
flink-core
flink-clients_2.11
flink-scala_2.11
flink-streaming-java_2.11
flink-streaming-java_2.11
flink-connector-kafka-0.11_2.11

Best regards/祝好,

Chang Liu 刘畅


> On 13 Aug 2018, at 04:01, Hequn Cheng <chenghe...@gmail.com> wrote:
> 
> Hi Chang,
> 
> There are some harness tests which can be used to test your function. It is 
> also a common way to test function or operator in flink internal tests. 
> Currently, the harness classes mainly include:
> KeyedOneInputStreamOperatorTestHarness
> KeyedTwoInputStreamOperatorTestHarness
> OneInputStreamOperatorTestHarness
> TwoInputStreamOperatorTestHarness
> You can take a look at the source code of these classes. 
> 
> To be more specific, you can take a look at the 
> testSlidingEventTimeWindowsApply[1], in which the RichSumReducer window 
> function has been tested.
> 
> Best, Hequn
> 
> [1] 
> https://github.com/apache/flink/blob/master/flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/operators/windowing/WindowOperatorTest.java#L213
>  
> <https://github.com/apache/flink/blob/master/flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/operators/windowing/WindowOperatorTest.java#L213>
> 
> 
> On Mon, Aug 13, 2018 at 7:10 AM, Chang Liu <fluency...@gmail.com 
> <mailto:fluency...@gmail.com>> wrote:
> Dear all,
> 
> I have some questions regarding testing in Flink. The more general question 
> is: is there any guideline, template, or best practices that we can follow if 
> we want to test our flink code (more in scala)?
> 
> I know there is this page: 
> https://ci.apache.org/projects/flink/flink-docs-release-1.6/dev/stream/testing.html
>  
> <https://ci.apache.org/projects/flink/flink-docs-release-1.6/dev/stream/testing.html>
>  but not so much written there. And I also did not find a more comprehensive 
> documentation of this library: flink-test-utils_2.11.
> 
> One detailed question: how do you test this WindowFunction below? The return 
> type is Unit right? We cannot do unit test on like, like how the 
> ReduceFunction was tested in the example link above. Then we only have the 
> option of doing integration testing on it?
> <code.png>
> 
> 
> Your ideas would be very helpful :) Thanks in advance !
> 
> Best regards/祝好,
> 
> Chang Liu 刘畅
> 
> 
> 

Reply via email to