用于测试的依赖项 #
Flink 提供了用于测试作业的实用程序,您可以将其添加为依赖项。
DataStream API 测试 #
如果要为使用 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.19.1</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.19.1"
Check out Project configuration for more details.
在各种测试实用程序中,该模块提供了 MiniCluster
(一个可配置的轻量级 Flink 集群,能在 JUnit 测试中运行),可以直接执行作业。
有关如何使用这些实用程序的更多细节,请查看 DataStream API 测试。
Table API 测试 #
如果您想在您的 IDE 中本地测试 Table API 和 SQL 程序,除了前述提到的 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.19.1</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.19.1"
Check out Project configuration for more details.
这将自动引入查询计划器和运行时,分别用于计划和执行查询。
flink-table-test-utils
模块已在 Flink 1.15 中引入,目前被认为是实验性的。