简体   繁体   English

Spring 批量集成测试

[英]Spring Batch Integration testing


We have several spring batch projects and we want to implement integration tests for them. 我们有几个 spring 批处理项目,我们想为它们实施集成测试。

One of the projects reads from DB and writes to another DB.其中一个项目从数据库读取并写入另一个数据库。
The other project reads from DB and writes to a file.另一个项目从 DB 读取并写入文件。
The other reads from File and writes to DB.另一个从 File 读取并写入 DB。

How can we apply the end-to-end integration test to these projects?我们如何将端到端集成测试应用于这些项目?
How can we run this test in the pipeline?我们如何在管道中运行这个测试?

Thank you.谢谢你。

How can we apply the end-to-end integration test to these projects?我们如何将端到端集成测试应用于这些项目?

The End-To-End Testing of Batch Jobs section from the reference documentation explains that in details and with code examples.参考文档中的“批处理作业的端到端测试”部分详细说明了这一点并附有代码示例。 You can end-to-end test your job by:您可以通过以下方式端到端测试您的工作:

  • creating dummy input data (either input file or database table)创建虚拟输入数据(输入文件或数据库表)
  • run your job as you would do it in production像在生产中一样运行你的工作
  • assert on the results (either output file or database table)断言结果(output 文件或数据库表)

There is a similar question/answer that I will add here for reference: Understanding JobLauncherTestUtils我将在此处添加一个类似的问题/答案以供参考: 了解 JobLauncherTestUtils

How can we run this test in the pipeline?我们如何在管道中运行这个测试?

The Creating a Unit Test Class section shows how to create a unit/integration test class which you can run as part of the test phase of your build pipeline. 创建单元测试 Class部分展示了如何创建单元/集成测试 class,您可以将其作为构建管道的测试阶段的一部分运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM