Spring 批量集成测试

Spring Batch Integration testing


我们有几个 spring 批处理项目,我们想为它们实施集成测试。

其中一个项目从数据库读取并写入另一个数据库。
另一个项目从数据库读取并写入文件。
另一个从文件读取并写入数据库。

我们如何将端到端集成测试应用于这些项目?
我们怎样才能运行在管道中进行这个测试?

谢谢。

How can we apply the end-to-end integration test to these projects?

参考文档中的 End-To-End Testing of Batch Jobs 部分通过代码示例详细解释了这一点。您可以通过以下方式端到端测试您的工作:

  • 创建虚拟输入数据(输入文件或数据库 table)
  • 运行 您在生产中的工作
  • 断言结果(输出文件或数据库table)

有一个类似的question/answer我会在这里添加以供参考:

How can we run this test in the pipeline?

Creating a Unit Test Class 部分展示了如何创建 unit/integration 测试 class,您可以 运行 作为构建管道测试阶段的一部分。