Dependencies for Testing #
Flink provides utilities for testing your job that you can add as dependencies.
DataStream API Testing #
You need to add the following dependencies if you want to develop tests for a job built with the DataStream API:
Open the
Check out Project configuration for more details.
pom.xml
file in your project directory and add the following in the dependencies block.
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-test-utils</artifactId>
<version>1.17.2</version>
<scope>test</scope>
</dependency>
Open the
Note: This assumes that you have created your project using our Gradle build script or quickstart script.
Check out Project configuration for more details.
build.gradle
file in your project directory and add the following in the dependencies block.
testCompile "org.apache.flink:flink-test-utils:1.17.2"
Check out Project configuration for more details.
Among the various test utilities, this module provides MiniCluster
, a lightweight configurable Flink cluster runnable in a JUnit test that can directly execute jobs.
For more information on how to use these utilities, check out the section on DataStream API testing
Table API Testing #
If you want to test the Table API & SQL programs locally within your IDE, you can add the following
dependency, in addition to the aforementioned flink-test-utils
:
Open the
Check out Project configuration for more details.
pom.xml
file in your project directory and add the following in the dependencies block.
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-test-utils</artifactId>
<version>1.17.2</version>
<scope>test</scope>
</dependency>
Open the
Note: This assumes that you have created your project using our Gradle build script or quickstart script.
Check out Project configuration for more details.
build.gradle
file in your project directory and add the following in the dependencies block.
testCompile "org.apache.flink:flink-table-test-utils:1.17.2"
Check out Project configuration for more details.
This will automatically bring in the query planner and the runtime, required respectively to plan and execute the queries.
The module flink-table-test-utils
has been introduced in Flink 1.15 and is considered experimental.