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:

Maven

Open the pom.xml file in your project directory and add the following in the dependencies block.

  1. <dependency>
  2. <groupId>org.apache.flink</groupId>
  3. <artifactId>flink-test-utils</artifactId>
  4. <version>1.18.1</version>
  5. <scope>test</scope>
  6. </dependency>

Copied to clipboard!

Check out Project configuration for more details.

Gradle

Open the build.gradle file in your project directory and add the following in the dependencies block.

  1. testCompile "org.apache.flink:flink-test-utils:1.18.1"

Copied to clipboard!

Note: This assumes that you have created your project using our Gradle build script or quickstart script.
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:

Maven

Open the pom.xml file in your project directory and add the following in the dependencies block.

  1. <dependency>
  2. <groupId>org.apache.flink</groupId>
  3. <artifactId>flink-table-test-utils</artifactId>
  4. <version>1.18.1</version>
  5. <scope>test</scope>
  6. </dependency>

Copied to clipboard!

Check out Project configuration for more details.

Gradle

Open the build.gradle file in your project directory and add the following in the dependencies block.

  1. testCompile "org.apache.flink:flink-table-test-utils:1.18.1"

Copied to clipboard!

Note: This assumes that you have created your project using our Gradle build script or quickstart script.
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.